|
| 1 | += Skaffold |
| 2 | +//tag::title[] |
| 3 | +:toc: macro |
| 4 | +ifndef::imagesdir[] |
| 5 | +:imagesdir: docs/img |
| 6 | +endif::[] |
| 7 | +//end::title[] |
| 8 | + |
| 9 | +[caption="Build status", link="https://travis-ci.org/GoogleContainerTools/skaffold"] |
| 10 | +image::https://travis-ci.org/GoogleContainerTools/skaffold.svg?branch=master[Build Status] |
| 11 | + |
| 12 | +//tag::intro[] |
| 13 | +Skaffold is a command line tool that facilitates continuous development for Kubernetes applications. |
| 14 | +You can iterate on your application source code locally then deploy to local or remote Kubernetes clusters. |
| 15 | +Skaffold handles the workflow for building, pushing and deploying your application. |
| 16 | +It can also be used in an automated context such as a CI/CD pipeline to leverage the same workflow and tooling when moving applications to production. |
| 17 | +//end::intro[] |
| 18 | + |
| 19 | +toc::[] |
| 20 | + |
| 21 | +//tag::features[] |
| 22 | + |
| 23 | +== Features |
| 24 | + |
| 25 | +- No server-side component. No overhead to your cluster. |
| 26 | +- Detect changes in your source code and automatically build/push/deploy. |
| 27 | +- Image tag management. Stop worrying about updating the image tags in Kubernetes manifests to push out changes during development. |
| 28 | +- Supports existing tooling and workflows. Build and deploy APIs make each implementation composable to support many different workflows. |
| 29 | +- Support for multiple application components. Build and deploy only the pieces of your stack that have changed. |
| 30 | +- Deploy regularly when saving files or run one off deployments using the same configuration. |
| 31 | +//end::features[] |
| 32 | + |
| 33 | +//tag::pluggability[] |
| 34 | + |
| 35 | +== Pluggability |
| 36 | +Skaffold has a pluggable architecture that allows you to choose the tools in the developer workflow that work best for you. |
| 37 | + |
| 38 | +image::plugability.png[] |
| 39 | +//end::pluggability[] |
| 40 | + |
| 41 | +//tag::operatingmodes[] |
| 42 | + |
| 43 | += Operating modes |
| 44 | +== skaffold dev |
| 45 | +Updates your deployed application continually: |
| 46 | + |
| 47 | +- Watches your source code and the dependencies of your docker images for changes and runs a build and deploy when changes are detected |
| 48 | +- Streams logs from deployed containers |
| 49 | +- Continuous build-deploy loop, only warn on errors |
| 50 | + |
| 51 | +== skaffold run |
| 52 | +Runs a Skaffold pipeline once, exits on any errors in the pipeline. |
| 53 | +Use for: |
| 54 | + |
| 55 | +- Continuous integration or continuous deployment pipelines |
| 56 | +- Sanity checking after iterating on your application |
| 57 | +//end::operatingmodes[] |
| 58 | + |
| 59 | +//tag::demo[] |
| 60 | += Demo |
| 61 | + |
| 62 | +image::intro.gif[Demo] |
| 63 | +//end::demo[] |
| 64 | +//tag::getting_started_local[] |
| 65 | + |
| 66 | += Getting Started with Local Tooling |
| 67 | + |
| 68 | +For getting started with Google Kubernetes Engine and Container Builder link:docs/quickstart-gke.adoc[go here. |
| 69 | +Otherwise continue |
| 70 | +below to get started with a local Kubernetes cluster. |
| 71 | + |
| 72 | +== Installation |
| 73 | + |
| 74 | +You will need the following components to get started with Skaffold: |
| 75 | + |
| 76 | +. skaffold |
| 77 | + - To download the latest Linux build, run: |
| 78 | + - `curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 && chmod +x skaffold && sudo mv skaffold /usr/local/bin` |
| 79 | + - To download the latest OSX build, run: |
| 80 | + - `curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-darwin-amd64 && chmod +x skaffold && sudo mv skaffold /usr/local/bin` |
| 81 | + |
| 82 | +. Kubernetes Cluster |
| 83 | + - link:https://kubernetes.io/docs/tasks/tools/install-minikube/[Minikube], |
| 84 | + link:https://cloud.google.com/kubernetes-engine/docs/how-to/creating-a-container-cluster[GKE], |
| 85 | + link:https://docs.docker.com/docker-for-windows/install/[Docker for Mac (Edge)] and link:https://docs.docker.com/docker-for-mac/install/[Docker for Windows (Edge)] |
| 86 | + have been tested but any Kubernetes cluster will work. |
| 87 | + |
| 88 | +. link:https://kubernetes.io/docs/tasks/tools/install-kubectl/[kubectl] |
| 89 | + - If you're not using Minikube, configure the current-context with your target cluster for development |
| 90 | + |
| 91 | +. docker |
| 92 | + |
| 93 | +. Docker image registry |
| 94 | + - Your docker client should be configured to push to an external docker image repositor. |
| 95 | +If you're using a minikube or Docker for Desktop cluster, you can skip this requirement. |
| 96 | + - If you are using Google Container Registry (GCR), choose one of the following: |
| 97 | + . Use `gcloud`'s Docker credential helper: Run link:https://cloud.google.com/sdk/gcloud/reference/auth/configure-docker[`gcloud auth configure-docker`] |
| 98 | + . Install and configure GCR's standalone cred helper: link:https://github.com/GoogleCloudPlatform/docker-credential-gcr#installation-and-usage[`docker-credential-gcr`] |
| 99 | + . Run `gcloud docker -a` before each development session. |
| 100 | + |
| 101 | +== Iterative Development |
| 102 | + |
| 103 | +. Clone this repository to get access to the examples. |
| 104 | +[source,shell] |
| 105 | +git clone https://github.com/GoogleContainerTools/skaffold |
| 106 | + |
| 107 | +. Change directories to the `getting-started` example. |
| 108 | +[source,shell] |
| 109 | +cd examples/getting-started |
| 110 | + |
| 111 | +. Run `skaffold dev`. |
| 112 | + |
| 113 | +[source,console] |
| 114 | +$ skaffold dev |
| 115 | +Starting build... |
| 116 | +Found [minikube] context, using local docker daemon. |
| 117 | +Sending build context to Docker daemon 6.144kB |
| 118 | +Step 1/5 : FROM golang:1.9.4-alpine3.7 |
| 119 | + ---> fb6e10bf973b |
| 120 | +Step 2/5 : WORKDIR /go/src/github.com/GoogleContainerTools/skaffold/examples/getting-started |
| 121 | + ---> Using cache |
| 122 | + ---> e9d19a54595b |
| 123 | +Step 3/5 : CMD ./app |
| 124 | + ---> Using cache |
| 125 | + ---> 154b6512c4d9 |
| 126 | +Step 4/5 : COPY main.go . |
| 127 | + ---> Using cache |
| 128 | + ---> e097086e73a7 |
| 129 | +Step 5/5 : RUN go build -o app main.go |
| 130 | + ---> Using cache |
| 131 | + ---> 9c4622e8f0e7 |
| 132 | +Successfully built 9c4622e8f0e7 |
| 133 | +Successfully tagged 930080f0965230e824a79b9e7eccffbd:latest |
| 134 | +Successfully tagged gcr.io/k8s-skaffold/skaffold-example:9c4622e8f0e7b5549a61a503bf73366a9cf7f7512aa8e9d64f3327a3c7fded1b |
| 135 | +Build complete in 657.426821ms |
| 136 | +Starting deploy... |
| 137 | +Deploying k8s-pod.yaml... |
| 138 | +Deploy complete in 173.770268ms |
| 139 | +[getting-started] Hello world! |
| 140 | + |
| 141 | +. Skaffold has done the following for you: |
| 142 | + |
| 143 | + - Build an image from the local source code |
| 144 | + - Tag it with its sha256 |
| 145 | + - Sets that image in the Kubernetes manifests defined in `skaffold.yaml` |
| 146 | + - Deploy the Kubernetes manifests using `kubectl apply -f` |
| 147 | + |
| 148 | +. You will see the output of the pod that was deployed: |
| 149 | +[source,console] |
| 150 | +[getting-started] Hello world! |
| 151 | +[getting-started] Hello world! |
| 152 | +[getting-started] Hello world! |
| 153 | + |
| 154 | +Now, update `main.go` |
| 155 | + |
| 156 | +[source,diff] |
| 157 | +----- |
| 158 | +diff --git a/examples/getting-started/main.go b/examples/getting-started/main.go |
| 159 | +index 64b7bdfc..f95e053d 100644 |
| 160 | +--- a/examples/getting-started/main.go |
| 161 | ++++ b/examples/getting-started/main.go |
| 162 | +@@ -7,7 +7,7 @@ import ( |
| 163 | +
|
| 164 | + func main() { |
| 165 | + for { |
| 166 | +- fmt.Println("Hello world!") |
| 167 | ++ fmt.Println("Hello jerry!") |
| 168 | + time.Sleep(time.Second * 1) |
| 169 | + } |
| 170 | + } |
| 171 | +----- |
| 172 | + |
| 173 | +Once you save the file, you should see the pipeline kick off again to redeploy your application: |
| 174 | +[source,console] |
| 175 | +[getting-started] Hello jerry! |
| 176 | +[getting-started] Hello jerry! |
| 177 | + |
| 178 | +== Run a deployment pipeline once |
| 179 | +There may be some cases where you don't want to run build and deploy continuously. |
| 180 | +To run once, use: |
| 181 | +[source,console] |
| 182 | +----- |
| 183 | +$ skaffold run |
| 184 | +----- |
| 185 | + |
| 186 | +//end::getting_started_local[] |
| 187 | + |
| 188 | +//tag::more_examples[] |
| 189 | += More examples |
| 190 | + |
| 191 | +* link:./examples/helm-deployment[Deploying with Helm] |
| 192 | +* link:./examples/microservices[Microservices/Multiple applications] |
| 193 | +* link:./examples/annotated-skaffold.yaml[Annotated skaffold.yaml] |
| 194 | +//end::more_examples[] |
| 195 | + |
| 196 | + |
| 197 | +//tag::community[] |
| 198 | += Community |
| 199 | +- link:https://groups.google.com/forum/#!forum/skaffold-users[skaffold-users mailing list] |
| 200 | +- link:https://kubernetes.slack.com/messages/CABQMSZA6/[#skaffold on Kubernetes Slack] |
| 201 | +//end::community[] |
| 202 | + |
| 203 | + |
0 commit comments