liveBook · Manning

Kustomization.yaml

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

A kustomization file is a Kustomize configuration document that declares resources and customization transformations for a Kubernetes application.

A kustomization.yaml file declares Kubernetes resources and the transformations applied to them. Kustomize keeps shared base YAML separate from environment-specific overlays, supporting DRY configuration and GitOps workflows. section 5.3.2

Use the file to:

  • List resources such as a Deployment and Service. section 5.3.2
  • Apply a base configuration with kubectl apply -k base/. section 5.3.2
  • Create overlays that customize a base for staging, production, or development. section 5.3.2

Base resources and a staging overlay

Create deployment.yaml and service.yaml under base/, then reference them from kustomization.yaml. A staging kustomization can reference ../../base and patch the Deployment named my-app, replacing /spec/replicas with 3. Apply the base with kubectl apply -k base/ and verify the result with kubectl get deploy,svc. section 5.3.2

resources:
- deployment.yaml
- service.yaml

Shows the minimal resources list for a base kustomization. section 5.3.2

resources:
- ../../base

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

Shows an overlay referencing a base and applying a JSON patch to increase replicas. section 5.3.2

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

How deep it goes
Defines resources, demonstrates base application and staging patches, and stops short of package management and dependency handling.
Examples
Uses deployment.yaml, service.yaml, a base directory, and a staging overlay that replaces Deployment replicas with 3.
What it assumes
Assumes familiarity with Kubernetes Deployments, Services, YAML manifests, and kubectl-generated dry-run output.
What you can do after
Operate Kustomize by creating a base, applying it with kubectl apply -k, adding an overlay, and verifying Deployments and Services.
How it connects
Connects Kubernetes manifests, Kustomize bases, overlays, kubectl, Deployments, Services, 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.