liveBook · Manning

Kustomize overlay

As explained in Acing the Certified Kubernetes Administrator Exam, Second Edition

An overlay is a Kustomize configuration layer that applies environment-specific customizations to a shared set of Kubernetes manifests.

A Kustomize overlay is an environment-specific configuration layer that modifies shared Kubernetes manifests while keeping YAML configurations DRY. Kustomize uses kustomization.yaml files and integrates directly with kubectl, so no separate CLI is required. section 5.3.2 section 5.5

Use an overlay when an application shares a base configuration but needs environment-specific changes:

  • Keep common resources such as a Deployment and Service in a base directory. section 5.3.2
  • Create a directory such as overlays/staging with its own kustomization.yaml. section 5.3.2
  • Reference the base and apply a patch that changes only the staging requirements. section 5.3.2
  • Render or apply the selected configuration with kubectl and verify the resulting Deployment and Service. section 5.3.2

Staging overlay with three replicas

A base kustomization lists deployment.yaml and service.yaml. The staging overlay references ../../base and applies a JSON patch targeting Deployment my-app, replacing /spec/replicas with 3. Applying the overlay produces the staging desired state without editing the shared base files.

resources:
- ../../base

patches:
- target:
    kind: Deployment
    name: my-app
  patch: |-
    - op: replace
      path: /spec/replicas
      value: 3

Inspect the overlay definition to see how a base directory and targeted replica patch combine into an environment-specific configuration. section 5.3.2

How Acing the Certified Kubernetes Administrator Exam, Second Edition covers it

How deep it goes
Explains the base-overlay structure and a replica patch, but does not detail package management or dependency handling.
Examples
Uses a Deployment and Service base plus a staging patch that changes my-app replicas to three.
What it assumes
Assumes basic Kubernetes YAML resources and kubectl usage while demonstrating base and overlay organization.
What you can do after
Operate/configure environment-specific Kubernetes resources with kustomization.yaml files and kubectl apply -k.
How it connects
Connects Kubernetes manifests, Deployments, Services, kubectl, GitOps, and Helm.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Acing the Certified Kubernetes Administrator Exam, Second Edition. The section links point to the parts of the book it draws on.