-
GCP Account: Sign up for a free trial here.
-
Create a Kubernetes Engine cluster if you don’t already have one.
gcloud container clusters create skaffold --zone us-west1-a
-
Clone the Skaffold repository then change directories to the sample application.
git clone https://github.com/GoogleContainerTools/skaffold.git cd skaffold/examples/getting-started
-
Install
skaffold
.curl -Lo skaffold https://storage.googleapis.com/skaffold/releases/latest/skaffold-linux-amd64 chmod +x skaffold sudo mv skaffold /usr/local/bin
The sample application you will use is a simple Go process that logs a statement every second.
As a new developer on-boarding you need to start Skaffold in dev
mode to begin iterating
on the application and seeing the updates happen in real time.
The development team working on the application
has already setup the Dockerfile, Kubernetes manifests, and Skaffold manifest necessary to get you started.
-
Change the references in
skaffold.yaml
andk8s-pod.yaml
to point to your Container Registry.sed -i -e s#k8s-skaffold#${GOOGLE_CLOUD_PROJECT}#g skaffold.yaml sed -i -e s#k8s-skaffold#${GOOGLE_CLOUD_PROJECT}#g k8s-pod.yaml
-
Take a look at the contents of
skaffold.yaml
. You’ll notice a profile namedgcb
that will be using Google Container Builder to build and push your image. The deploy section is configured to use kubectl to apply the Kubernetes manifests.cat skaffold.yaml
-
Run Skaffold in
dev
mode with thegcb
profile enabled. This will use Container Builder to build a new image from the local source code, push it to your Container Registry and then deploy your application to your Kubernetes Engine cluster.skaffold dev -p gcb
-
You will see the application’s logs printing to the screen.
Starting deploy... Deploying k8s-pod.yaml... Deploy complete. [getting-started getting-started] Hello world! [getting-started getting-started] Hello world! [getting-started getting-started] Hello world!
-
Click the editor toggle button in the top right of the Cloud Shell interface. The Cloud Shell editor is now open and displaying the contents of your Cloud Shell home directory.
-
Navigate to the
skaffold/examples/getting-started
directory in the left hand file navigation pane. -
Click the
main.go
file to open it. -
Edit the
Hello World
message to say something different. Your change will be saved automatically by the editor. Once the save is complete Skaffold will detect that a file has been changed and then rebuild, repush and redeploy the change. You will see your new log line now streaming back from the Kubernetes cluster.