Build and deploy Kubernetes applications with Skaffold and kustomize | Coder Society

Build and deploy Kubernetes applications with Skaffold and kustomize

Learn how to build and deploy Kubernetes applications with Skaffold and kustomize.

Koji Wakayama

Koji Wakayama

December 30, 2018

Build and deploy Kubernetes applications with Skaffold and kustomize

Skaffold

Skaffold is a command line tool that facilitates continuous development for Kubernetes applications. You can iterate on your application source code locally then deploy to local or remote Kubernetes clusters.

Skaffold handles the workflow for building, pushing and deploying your application. It also provides building blocks and describe customizations for a CI/CD pipeline.

see Skaffold’s README and website

kustomize

kustomize lets you customize raw, template-free YAML files for multiple purposes, leaving the original YAML untouched and usable as is.

kustomize targets kubernetes; it understands and can patch kubernetes style API objects. It’s like make, in that what it does is declared in a file, and it’s like sed, in that it emits editted text.

see kustomize’s README and website

Prerequisites

Install Skaffold

On macOS you can install Skaffold with Homebrew.

brew install skaffold

You can find installation instructions for other platforms here: https://github.com/GoogleContainerTools/skaffold/releases

Install kustomize

On macOS you can install kustomize with Homebrew.

brew install kustomize

You can find installation instructions for other platforms here: https://github.com/kubernetes-sigs/kustomize/blob/master/docs/INSTALL.md

Download Skaffold’s kustomize example

Clone the Skaffold repository and cd into the kustomize example directory.

git clone [https://github.com/GoogleContainerTools/skaffold](https://github.com/GoogleContainerTools/skaffold) cd skaffold/examples/kustomize

Run skaffold

You can run following command to deploy the application to your Kubernetes cluster.

❯ skaffold run Starting build... Build complete in 41.003µs Starting test... Test complete in 4.239µs Starting deploy... deployment.apps "kustomize-test" created Deploy complete in 3.548712675s You can also run [skaffold run --tail] to get the logs

Use skaffold dev to build and deploy your app every time your code changes.

❯ skaffold dev Starting build... Build complete in 20.354µs Starting test... Test complete in 3.863µs Starting deploy... deployment.apps "kustomize-test" unchanged Deploy complete in 531.523251ms Watching for changes every 1s...

Verify deployment

Verify the deployment with kubectl.

❯ kubectl get pods NAME READY STATUS RESTARTS AGE kustomize-test-6557bbc789-7m57b 1/1 Running 0 1m

Clean up

Clean up and remove the k8s pod.

❯ skaffold delete Cleaning up... deployment.apps "kustomize-test" deleted Cleanup complete in 5.754931332s

Content worth reading – right to your inbox.

By submitting you agree to us processing your personal data according to our privacy policy

A Coder Society member working at a cafe bar

For freelancers

Become part of Coder Society to work with us on innovative projects.

Recommended articles