Git Product home page Git Product logo

skaffold-example's Introduction

Skaffold Example

This is a barebones example for the purposes of illustration of how we can leverage Skaffold to develop in a Kubernetes environment.

What does Skaffold do for us?

A: A lot of things - check out the docs for more info, I'm not going to dive into all of the functionality today.

Skaffold's dev workflow is what I'll be focusing on. It chains together three common things:

  • A file watcher with "hot reload" functionality. When source code changes we perform:
    • Automatic docker build (and push if desired)
    • Automatic helm deploy - in our case, to a local minikube cluster

Prerequesites

  • Skaffold
  • Minikube
  • Kubectl
  • Docker
  • Helm3

Quick Bootstrap

Assuming you have all prerequesites installed, go ahead and launch a minikube instance

minikube start --driver=docker --kubernetes-version=1.21.0 --memory 4196 --cpus 4 --disk-size 50Gb

Once this is done, running kubectl config use-context minikube will switch your kubectl to use the minikube context (note: kubectx is a nice tool for switching contexts!)

Because minikube has its own Docker daemon to manage its images, we need to point our local terminal to use minikube's docker daemon so we can build images locally and have them be available in the minikube environment.

Running eval $(minikube docker-env) will do just that. Now any ‘docker’ command you run in this current terminal will run against the docker inside minikube cluster. (See minikube docs)

Now, skaffold dev is the command we'll focus on. Run it and you'll notice:

  1. It'll build the image specified in your repo's Dockerfile, tagging it based on what's in our skaffold.yaml
  2. It'll then use the helm chart and values file specified in skaffold.yaml to deploy the image automatically to our minikube cluster.
  3. It'll port-forward all traffic from 0.0.0.0:9000 -> port 8080 on the deployment we've specified
  4. It'll automatically re-deploy when code changes!

skaffold-example's People

Contributors

mgdaily avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.