kustomize

Using kustomization.yaml

Print a set of API resources generated from instructions in a kustomization.yaml file.

The argument must be the path to the directory containing the file, or a git repository URL with a path suffix specifying same with respect to the repository root.

Command

  1. $ kubectl kustomize <dir>

Example

Input File

  1. # deployment.yaml
  2. apiVersion: apps/v1
  3. kind: Deployment
  4. metadata:
  5. name: the-deployment
  6. spec:
  7. replicas: 5
  8. template:
  9. containers:
  10. - name: the-container
  11. image: registry/conatiner:latest
  1. # kustomization.yaml
  2. apiVersion: kustomize.config.k8s.io/v1beta1
  3. kind: Kustomization
  4. nameSuffix: -dev
  5. resources:
  6. - deployment.yaml

Command

  1. // deployment.yaml and kustomization.yaml are in the same directory
  2. $ kubectl kustomize

Output

  1. apiVersion: apps/v1
  2. kind: Deployment
  3. metadata:
  4. name: the-deployment-dev
  5. spec:
  6. replicas: 5
  7. template:
  8. containers:
  9. - image: registry/conatiner:latest
  10. name: the-container