skip to content
Alvin Lucillo

Kustomize basic

/ 1 min read

Kustomize allows us to customize k8s YAML without modifying the original file. For now, without a patch/overlay, here’s how to output the resource.

build command outputs the resulting YAML, and test/ is the location the resources are and the kustomization.yaml. kustomization.yaml provides the resources and their location.

kustomize build test/

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: po
  name: po
spec:
  containers:
  - args:
    - test
    image: nginx
    name: po
    resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}

directory tree:

├── test
   ├── base
   └── po.yaml
   ├── kustomization.yaml
   └── patch

po.yaml

apiVersion: v1
kind: Pod
metadata:
  creationTimestamp: null
  labels:
    run: po
  name: po
spec:
  containers:
    - args:
        - test
      image: nginx
      name: po
      resources: {}
  dnsPolicy: ClusterFirst
  restartPolicy: Always
status: {}

kustomization.yaml

apiVersion: kustomize.config.k8s.io/v1beta1
kind: Kustomization
resources:
  - ./base/po.yaml