Skaffold is a command line tool that facilitates continuous development for Kubernetes-native applications. Skaffold handles the workflow for building, pushing, and deploying your application, and it provides building blocks for creating CI/CD pipelines. This enables you to focus on iterating on your application locally while Skaffold continuously deploys to your local or remote Kubernetes cluster. To learn more about Skaffold, refer to the project docs here.
In order to demonstrate the steps to set up Skaffold with Rancher Desktop, a sample nodejs app example is provided within the Rancher Desktop docs repository here.
Important: Skaffold only works with
dockerd(Moby). Therefore, make sure to select your runtime as
dockerdfrom the Kubernetes Settings panel in the Rancher Desktop UI.
Visit https://skaffold.dev/docs/install/ to install Skaffold.
Clone the Rancher Desktop docs repository and navigate to the
express-samplein a terminal as follows:
Per the Skaffold docs,
skaffold initwalks through your project directory and looks for any build configuration files such as
We will select
package.jsonin our example. This will generate the initial configuration file that you can modify as needed. When prompted, select
yesto write your config to
In your editor, review your
manifests.yamlfiles. Note that in
manifests.yaml, you will have a deployment config as well as a service config. It is only necessary to have 1
replicafor testing purposes.
Back in your terminal, you'll notice that you will have two options:
skaffold runthat lets you build and deploy, and
skaffold devthat allows you to enter development mode with auto-redeploy. We will use
skaffold devin this example.
As you will need to have push access to the image repository, you can either use your docker login, or you can set up a local registry:
- Docker Hub
- Local Registry
skaffold dev, use your docker login if you have a Docker Hub account. Then, in the files
skaffold devwill push the built image to DockerHub.You can set up a local registry by first running this command:
docker run -d -p 5000:5000 --restart=always --name registry registry:2
skaffold dev --default-repo=localhost:5000
As you go through your development, Skaffold will detect any changes and will automatically go through the build and deployment process again. You will be able to see any changes reflected in the cluster.
Point your web browser to
localhost:3000, and you will see the