What is Kustomize? Your first kustomization.yaml

Kustomize lets you write an app's Kubernetes YAML once and change only what differs for each environment. Write your first kustomization.yaml, preview it and apply it, with nothing to install.

GazeekKUBERNETES KUSTOMIZE TUTORIAL·LESSON 1
LESSON 1

What is Kustomize? Your first kustomization.yaml

Kustomize lets you write an app's Kubernetes YAML once and change only what differs for each environment. Write your first kustomization.yaml, preview it and apply it, with nothing to install.

0:00 / 1:57

Diagrams in this video · 2Free in archhy

Copy and edit in archhy: Three copies, or one base (new tab)
Copy and edit in archhy: Look first, then apply (new tab)

Now try it on a real cluster

The videos are free. Gazeek's hands-on labs give you a real Kubernetes cluster in your browser for every lab, with checks that tell you when you've got it right: the practice the CKA and CKAD exams need.

After this lesson you can

  • Say what problem Kustomize solves
  • Write a first kustomization.yaml
  • Preview the result, then apply it
Transcript

What is Kustomize? Your first kustomization.yaml

Space Llama here. You have one app, and three environments. Do you copy the YAML three times? Please don't. In this course, you'll learn Kustomize, step by step, with one small app.

Three copies, or one base

Here's the trouble with copies. You fix a bug in dev, and forget test and prod. Soon, no two match. With Kustomize, you write the app once. That's called the base. Each environment gets an overlay, which lists only what's different. Kustomize puts them together and gives you finished Kubernetes YAML. There are no templates.

Your first kustomization

Let's make one. Our app is a Deployment and a Service, in a folder called base. Beside them, add a file called kustomization dot yaml. The first two lines say what kind of file it is. They're the same every time. Then resources lists the files to include. That's it. You have a kustomization.

Look first, then apply

Now use it. You have your YAML files. The kustomization lists them. Run kubectl kustomize base, and it prints the result. Nothing in the cluster changes. Happy with it? Run kubectl apply dash k base, and it goes to the cluster.

Dash k, not dash f

Kustomize is built into kubectl, so there's nothing to install. Dash k wants the folder. Give it the kustomization file, and it refuses. Use dash f on the folder by mistake, and you'll see, no matches for kind Kustomization. Switch to dash k. But check the cluster too. The other files in the folder may already have been applied.

Remember

So. Write the app once, in a base. List its files in kustomization dot yaml. Preview it with kubectl kustomize. And apply it with dash k.

Practice and what's next

Next, we'll give that base a dev version and a prod version. See you there.

Hands-on labs

Now try it on a real cluster

A real Kubernetes cluster in your browser for every lab, checked as you go.

See the labs

Gazeek Flash · free

Exam questions on your phone

Free questions on Application Deployment: quick-fire batches and timed exams, on the web or Android.