Kubernetes Continuous Deployment with Skaffold

Gabriel Boie
5 min readJan 2, 2021


Snow Polo In St. Moritz, Switzerland

The DevOps Big Picture (CI + CD/CD ?)

Continuous Integration + Continuous Delivery/Continuous Deployment

While traditional shops with large architectures are mainly using CI/Continuous Delivery, most avant-garde companies are relying heavily on CI/Continuous Deployments, and some companies are using both. Atlassian is doing a great job explaining these concepts, and their picture is worth a thousand words that I am going to skip.

Figure 1 Continuous Delivery vs. Continuous Deployment

Read more: https://www.atlassian.com/continuous-delivery/principles/continuous-integration-vs-delivery-vs-deployment


Simply put, Skaffold is a command line utility that facilitates Continuous Development (scaffold dev) for Kubernetes-native applications. Of course, you can simply use it to implement CI/Continuous Delivery pipelines as well (scaffold run).

Skaffold is pretty easy to use after some initial setup. You can start the scaffold dev command in a terminal and go about your developer business. With every local source code change, Skaffold is springing into action and is building, testing, tagging, pushing, deploying, and monitoring the artifacts and can also clean-up everything with scaffold delete command. Sounds like a whole lot of useful features. Here is the workflow as described by the Skaffold team:

Figure 2 Skaffold Workflow and Architecture (Skaffold)

You can choose which of these stages you want to implement; you do not have to have them all, you can adapt scaffold as you please to make the best use of it for your specific use case.

Read More: https://skaffold.dev/docs/

Developer Setup

Local machine development is not dead, not even when it comes to Kubernetes. There are advantages to having a Kubernetes environment where you can develop and test your microservices without external dependencies and without spending money on local or cloud infrastructure.

Running Docker-desktop, Minikube, or a full blown Kubernetes cluster locally can speed up your development and initial basic testing. In addition, Skaffold is a great tool that can provide the much needed Continuous Deployment.

There are situations where you have to deploy and integrate to an external Kubernetes cluster: maybe heavy dependencies (i.e. AWS RDS), security constrains, or complex or hybrid architectures that cannot be replicated locally. So long as your kubectl is configured to point to the external k8s cluster, nothing about the scaffold use case is changing.

Getting Started with Skaffold

Assumptions: You already have access to a Kuberntes cluster via kubectl. Either a local k8 cluster simply Docker-Desktopo, Minikube, or other k8s implement tations (Ubuntu, Rancher, etc.) or a remote cluster.

Skaffold runs on Linux, MacOS, Windows or it can run in a Docker container. I will follow the MacOS install, but here is the documentation for all: https://skaffold.dev/docs/install/

curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && \

sudo install skaffold /usr/local/bin/

The fastest way to get started is to use one of the Skaffold examples; there are numerous here: https://github.com/GoogleContainerTools/skaffold/tree/master/examples/nodejs

For this post, I created a repo containing only the source code, Dockerfile and K8s manifests to simplify this example. Clone this locally:

git clone https://github.com/gboie/node-sample-skaffold.git

Notice that, unlike tools like Draft that can automatically generate these, you will need to create your Dockerfile and k8s manifests. In this case, these are already there, but it’s something to keep in mind. However the following command will generate a Skaffold basic pipeline code after a quick scan of your directory.

skaffold init

A new skaffold.yaml was generated and it represents the Skaffold pipeline definition; this is how it looks for our example:

This is a pretty basic example; in short, it builds the Dockerfile and it deploys the k8s manifest file. For advanced configuration and implementing of additional stages, please see: https://skaffold.dev/docs/design/config/

As soon as you execute scaffold dev from inside your root directory (nodejs):

You can see from the output above that a new docker image is being built and tagged and then deployed to my local k8s cluster (Docker-Desktop in this case).

To identify the port of our newly deployed k8s service, run:

kubectl get svc


kubernetes ClusterIP <none> 443/TCP 4d23h

node NodePort <none> 3000:30695/TCP 22s

To validate, you application open your browser at http://localhost:30695

So far so good! Now let’s see the Continuous Deployment at work…

Modify the source code, i.e. change the backend/src/index.js and you will witness CD in motion… I changed “World” with “Gabriel” in that file and, as soon as you save your changes, the Skaffold will hot trigger the new build/tag/deploy job and you can see…

And in browser:

To remove the pod/deployment/service from your kubernetes cluster, simply run skaffold delete

This is a very simplistic approach that shows you how Skaffold implements Continuous Deployment for k8-native application development. The sky is the limit, and I encourage you to look at the official documentation and tutorials at https://skaffold.dev