Quickstart

Follow this tutorial to learn about Skaffold on a small Kubernetes app built with Docker inside minikube and deployed with kubectl!

In this quickstart, you will:

  • Install Skaffold,
  • Download a sample go app,
  • Use skaffold dev to build and deploy your app every time your code changes,
  • Use skaffold run to build and deploy your app once, similar to a CI/CD pipeline

Before you begin

Downloading the sample app

  1. Clone the Skaffold repository:

    git clone https://github.com/GoogleContainerTools/skaffold
  2. Change to the examples/getting-started directory.

    cd examples/getting-started

skaffold dev: continuous build & deploy on code changes

Run skaffold dev to build and deploy your app continuously. You should see some outputs similar to the following entries:

Listing files to watch...
 - gcr.io/k8s-skaffold/skaffold-example
List generated in 2.46354ms
Generating tags...
 - gcr.io/k8s-skaffold/skaffold-example -> gcr.io/k8s-skaffold/skaffold-example:v0.39.0-131-g1759410a7-dirty
Tags generated in 65.661438ms
Starting build...
Found [minikube] context, using local docker daemon.
Building [gcr.io/k8s-skaffold/skaffold-example]...
Sending build context to Docker daemon  3.072kB
Step 1/6 : FROM golang:1.12.9-alpine3.10 as builder
 ---> e0d646523991
Step 2/6 : COPY main.go .
 ---> Using cache
 ---> 2d4b0b8a9dda
Step 3/6 : RUN go build -o /app main.go
 ---> Using cache
 ---> 3eae8e329453
Step 4/6 : FROM alpine:3.10
 ---> 961769676411
Step 5/6 : CMD ["./app"]
 ---> Using cache
 ---> ce76e22da3bd
Step 6/6 : COPY --from=builder /app .
 ---> dec4a50e0fd1
Successfully built dec4a50e0fd1
Successfully tagged gcr.io/k8s-skaffold/skaffold-example:v0.39.0-131-g1759410a7-dirty
Build complete in 232.935849ms
Starting test...
Test complete in 4.189µs
Tags used in deployment:
 - Since images are not pushed, they can't be referenced by digest
   They are tagged and referenced by a unique ID instead
 - gcr.io/k8s-skaffold/skaffold-example -> gcr.io/k8s-skaffold/skaffold-example:dec4a50e0fd1ca2f56c6aad2a6c6e1d3806e5f6bd8aa2751e0a10db0d46faaba
Starting deploy...
 - pod/getting-started created
Deploy complete in 374.060415ms
Watching for changes...
[getting-started] Hello world!
[getting-started] Hello world!
[getting-started] Hello world!

skaffold dev watches your local source code and executes your Skaffold pipeline every time a change is detected. skaffold.yaml provides specifications of the workflow - in this example, the pipeline is

  • Building a Docker image from the source using the Dockerfile
  • Tagging the Docker image with the sha256 hash of its contents
  • Updating the Kubernetes manifest, k8s-pod.yaml, to use the image built previously
  • Deploying the Kubernetes manifest using kubectl apply -f
  • Streaming the logs back from the deployed app

Let’s re-trigger the workflow just by a single code change! Update main.go as follows:

package main

import (
	"fmt"
	"time"
)

func main() {
	for {
		fmt.Println("Hello Skaffold!")
		time.Sleep(time.Second * 1)
	}
}

When you save the file, Skaffold will see this change and repeat the workflow described in skaffold.yaml, rebuilding and redeploying your application. Once the pipeline is completed, you should see the changes reflected in the output in the terminal:

[getting-started] Hello Skaffold!

skaffold run: build & deploy once

If you prefer building and deploying once at a time, run skaffold run. Skaffold will perform the workflow described in skaffold.yaml exactly once.

What’s next

For more in-depth topics of Skaffold, explore Configuration, Skaffold Pipeline, and Architecture and Design.

To learn more about how Skaffold builds, tags, and deploys your app, see the How-to Guides on using Builders, Taggers, and Deployers.

Skaffold Tutorials details some of the common use cases of Skaffold.

📣 Please fill out our quick 5-question survey to tell us how satisfied you are with Skaffold, and what improvements we should make. Thank you! 👯

Last modified October 7, 2019: Rework skaffold.dev splash page (ee3710b)