Kustomize bases and overlays: dev and prod from one app

Give one Kustomize base a dev overlay and a prod overlay. How the folders fit together, what an overlay file says, and why the namespace must exist first.

GazeekKUBERNETES KUSTOMIZE TUTORIAL·LESSON 2
LESSON 2

Kustomize bases and overlays: dev and prod from one app

Give one Kustomize base a dev overlay and a prod overlay. How the folders fit together, what an overlay file says, and why the namespace must exist first.

0:00 / 1:51

Diagrams in this video · 2Free in archhy

Copy and edit in archhy: One base, two overlays (new tab)
Copy and edit in archhy: The folders (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

  • Lay out a base and two overlays
  • Write an overlay that points at its base
  • Apply one environment at a time
Transcript

Kustomize bases and overlays: dev and prod from one app

Space Llama here. Last time, we wrote an app once, in a base. Today, we turn it into two versions, dev and prod, without copying it.

One base, two overlays

On the left, the base. One Deployment and one Service, both called web. The dev overlay turns on debug logging, and puts the app in the dev namespace. The prod overlay asks for three replicas and a newer image, in the prod namespace. The base doesn't know about either of them. Add a third environment, and you don't touch it.

The folders

On disk, it's just folders. Base has the app's files, and its kustomization. Overlays, dev, has its own kustomization, which points back at the base. Overlays, prod, does the same, with one extra file we'll write later.

The prod overlay

Here's the start of the prod overlay. It's short, because it only lists differences. Resources points at the base, two folders up. Namespace puts the app in the prod namespace. And name prefix adds prod dash to every name. So web becomes prod web.

Apply one environment

To deploy it, first create the namespace. Then apply the overlay's folder, with dash k. Skip the first step, and you'll see, namespaces prod not found. The namespace field uses a namespace. It doesn't make one. And if an older example has a field called bases, use resources instead. Bases is deprecated.

Remember

The base is the shared app. An overlay lists only what's different. Resources joins them together. And create the namespace first.

Practice and what's next

Next, we change the image, the replicas and the labels, without writing a single patch. 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.