github.com/GoogleContainerTools/skaffold/v2@v2.13.2/docs-v1/content/en/docs/quickstart/_index.md (about) 1 --- 2 title: "Quickstart" 3 linkTitle: "Quickstart" 4 weight: 20 5 --- 6 {{% tabs %}} 7 8 {{% tab "STANDALONE" %}} 9 10 Follow this tutorial if you're using the Skaffold [standalone binary]({{< relref "../install/#standalone-binary" >}}). It walks through running Skaffold on a small Kubernetes app built with [Docker](https://www.docker.com/) inside [minikube](https://minikube.sigs.k8s.io) 11 and deployed with [kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/)! 12 13 This tutorial uses minikube as Skaffold knows how to build the app using the Docker daemon hosted 14 inside minikube and thus avoiding any need for a registry to host the app's container images. 15 16 17 {{< alert title="Note">}} 18 Aside from `Docker` and `kubectl`, Skaffold also supports a variety of other tools 19 and workflows; see [Tutorials]({{<relref "/docs/tutorials">}}) for 20 more information. 21 {{</alert>}} 22 23 24 In this quickstart, you will: 25 26 * Install Skaffold, and download a sample go app, 27 * Use `skaffold dev` to build and deploy your app every time your code changes, 28 * Use `skaffold run` to build and deploy your app once, similar to a CI/CD pipeline 29 30 ## Set up 31 32 This tutorial requires Skaffold, Minikube, and Kubectl. 33 34 * [Install Skaffold]({{< relref "/docs/install" >}}) 35 * [Install kubectl](https://kubernetes.io/docs/tasks/tools/install-kubectl/) 36 * [Install minikube](https://minikube.sigs.k8s.io/docs/start/) 37 38 ### Start Minikube 39 40 ``` 41 minikube start --profile custom 42 skaffold config set --global local-cluster true 43 eval $(minikube -p custom docker-env) 44 ``` 45 46 {{< alert title="Note">}} 47 If you want to deploy against a different Kubernetes cluster then you will have to install Docker to build this app. 48 Furthermore if you want to deploy to a remote cluster, such as GKE, then you need to set up a container 49 registry such as [GCR](https://cloud.google.com/container-registry) to host the resulting images. 50 {{</alert>}} 51 52 ### Downloading the sample app 53 54 1. Clone the Skaffold repository: 55 56 ```bash 57 git clone --depth 1 https://github.com/GoogleContainerTools/skaffold 58 ``` 59 60 1. Change to the `examples/getting-started` in skaffold directory. 61 62 ```bash 63 cd skaffold/examples/getting-started 64 ``` 65 66 ## `skaffold dev`: continuous build & deploy on code changes 67 68 Run `skaffold dev` to build and deploy your app continuously. 69 You should see some outputs similar to the following entries: 70 71 ``` 72 Listing files to watch... 73 - skaffold-example 74 Generating tags... 75 - skaffold-example -> skaffold-example:v1.1.0-113-g4649f2c16 76 Checking cache... 77 - skaffold-example: Not found. Building 78 Found [docker-desktop] context, using local docker daemon. 79 Building [skaffold-example]... 80 Sending build context to Docker daemon 3.072kB 81 Step 1/6 : FROM golang:1.12.9-alpine3.10 as builder 82 ---> e0d646523991 83 Step 2/6 : COPY main.go . 84 ---> Using cache 85 ---> e4788ffa88e7 86 Step 3/6 : RUN go build -o /app main.go 87 ---> Using cache 88 ---> 686396d9e9cc 89 Step 4/6 : FROM alpine:3.10 90 ---> 965ea09ff2eb 91 Step 5/6 : CMD ["./app"] 92 ---> Using cache 93 ---> be0603b9d79e 94 Step 6/6 : COPY --from=builder /app . 95 ---> Using cache 96 ---> c827aa5a4b12 97 Successfully built c827aa5a4b12 98 Successfully tagged skaffold-example:v1.1.0-113-g4649f2c16 99 Tags used in deployment: 100 - skaffold-example -> skaffold-example:c827aa5a4b12e707163842b803d666eda11b8ec20c7a480198960cfdcb251042 101 local images can't be referenced by digest. They are tagged and referenced by a unique ID instead 102 Starting deploy... 103 - pod/getting-started created 104 Watching for changes... 105 [getting-started] Hello world! 106 [getting-started] Hello world! 107 [getting-started] Hello world! 108 109 ``` 110 111 {{< alert title="Error: Unknown API Version" >}} 112 Skaffold may complain: 113 ``` 114 parsing skaffold config: unknown api version: "skaffold/v2beta13" 115 ``` 116 117 This error indicates that you are not using the latest release of 118 Skaffold. Cloud Shell may lag for several days after a new Skaffold release. 119 Simply [install the latest version of Skaffold]({{< relref "/docs/install" >}}). 120 {{< /alert >}} 121 122 {{< alert title="Error: No push access to specified image repository">}} 123 If you are deploying to a remote cluster, you must run `skaffold dev --default-repo=<my_registry>` 124 where `<my_registry>` is an image registry that you have write-access to. Skaffold then 125 builds and pushes the container images to that location, and non-destructively 126 updates the Kubernetes manifest files to reference those pushed images. 127 {{< /alert >}} 128 129 `skaffold dev` watches your local source code and executes your Skaffold pipeline 130 every time a change is detected. `skaffold.yaml` provides specifications of the 131 workflow - in this example, the pipeline is 132 133 * Building a Docker image from the source using the Dockerfile 134 * Tagging the Docker image with the `sha256` hash of its contents 135 * Updating the Kubernetes manifest, `k8s-pod.yaml`, to use the image built previously 136 * Deploying the Kubernetes manifest using `kubectl apply -f` 137 * Streaming the logs back from the deployed app 138 139 Let's re-trigger the workflow just by a single code change! 140 Update `main.go` as follows: 141 142 ```go 143 package main 144 145 import ( 146 "fmt" 147 "time" 148 ) 149 150 func main() { 151 for { 152 fmt.Println("Hello Skaffold!") 153 time.Sleep(time.Second * 1) 154 } 155 } 156 ``` 157 158 When you save the file, Skaffold will see this change and repeat the workflow described in 159 `skaffold.yaml`, rebuilding and redeploying your application. Once the pipeline 160 is completed, you should see the changes reflected in the output in the terminal: 161 162 ``` 163 [getting-started] Hello Skaffold! 164 ``` 165 166 <span style="font-size: 36pt">✨</span> 167 168 ## `skaffold run`: build & deploy once 169 170 If you prefer building and deploying once at a time, run `skaffold run`. 171 Skaffold will perform the workflow described in `skaffold.yaml` exactly once. 172 173 {{% /tab %}} 174 175 {{% tab "CLOUD CODE" %}} 176 177 Follow these quickstart guides if you're using Skaffold with the [Cloud Code]({{< relref "../install/#managed-ide" >}}) IDE extensions: 178 179 ### [Cloud Code for VSCode](https://cloud.google.com/code/docs/vscode/quickstart-k8s) 180 181 Create, locally develop, debug, and run a Kubernetes application with Cloud Code for VSCode. 182 183 <a href="https://cloud.google.com/code/docs/vscode/quickstart-k8s"></a> 184 185 <br /> 186 187 ### [Cloud Code for IntelliJ](https://cloud.google.com/code/docs/intellij/quickstart-k8s) 188 189 Create, locally develop, debug, and run a Kubernetes application with Cloud Code for IntelliJ. 190 191 <a href="https://cloud.google.com/code/docs/intellij/quickstart-k8s"></a> 192 193 {{% /tab %}} 194 {{% tab "CLOUD SHELL" %}} 195 196 Skip any setup by using Google Cloud Platform's [_Cloud Shell_](http://cloud.google.com/shell), 197 which provides a [browser-based terminal/CLI and editor](https://cloud.google.com/shell#product-demo). 198 Cloud Shell comes with Skaffold, Minikube, and Docker pre-installed, and is free 199 (requires a [Google Account](https://accounts.google.com/SignUp)). 200 201 [](https://ide.cloud.google.com/?walkthrough_tutorial_url=https%3A%2F%2Fwalkthroughs.googleusercontent.com%2Fcontent%2Fgke_cloud_code_create_app%2Fgke_cloud_code_create_app.md) 202 203 {{% /tab %}} 204 {{% /tabs %}} 205 206 ## What's next 207 208 For getting started with your project, see the [Getting Started With Your Project]({{<relref "/docs/workflows/getting-started-with-your-project" >}}) workflow. 209 210 For more in-depth topics of Skaffold, explore [Configuration]({{< relref "/docs/design/config.md" >}}), 211 [Skaffold Pipeline]({{<relref "/docs/pipeline-stages" >}}), and [Architecture and Design]({{< relref "/docs/design" >}}). 212 213 To learn more about how Skaffold builds, tags, and deploys your app, see the How-to Guides on 214 using [Builders]({{<relref "/docs/pipeline-stages/builders" >}}), [Taggers]({{< relref "/docs/pipeline-stages/taggers">}}), and [Deployers]({{< relref "/docs/pipeline-stages/deployers" >}}). 215 216 [Skaffold Tutorials]({{< relref "/docs/tutorials" >}}) details some of the common use cases of Skaffold. 217 218 Questions? See our [Community section]({{< relref "/docs/resources#Community" >}}) for ways to get in touch. 219 220 :mega: **Please fill out our [quick 5-question survey](https://forms.gle/BMTbGQXLWSdn7vEs6)** to tell us how satisfied you are with Skaffold, and what improvements we should make. Thank you! :dancers: