kustomize commands

23 commands, each with a one-line explanation. Click a command to copy it, or its title for details.

Commands 23 shown

  • kustomize build ./overlays/prod

    Render all manifests for an overlay to stdout

  • kubectl apply -k ./overlays/prod

    Build and apply kustomization in one step via kubectl

  • kubectl diff -k ./overlays/prod

    Show what changes before applying

    debug

  • kustomize edit add resource ./deployment.yaml

    Append a resource file to kustomization.yaml

  • kustomize edit set image myapp=registry/myapp:v2.0.0

    Update image tag in kustomization.yaml

  • kustomize edit set namespace production

    Override namespace for all resources in the overlay

  • kustomize edit add label env:production

    Inject a common label into all generated resources

  • kustomize edit add patch --path patch.yaml --kind Deployment --name <name>

    Register a strategic merge patch in kustomization.yaml

  • kustomize cfg list-setters .

    List all settable fields in the kustomization

  • kubectl apply -k ./overlays/prod

    Build kustomize overlay and apply directly to cluster

    k8s · deploy

  • kubectl kustomize ./overlays/prod | head -100

    Render kustomize output without applying

    k8s · preview

  • kustomize edit set image myapp=myapp:v1.2.3

    Update image tag in kustomization.yaml

    k8s · image · deploy

  • kustomize edit add configmap my-config --from-literal=key=value

    Add a ConfigMap generator entry to kustomization.yaml

    k8s · configmap

  • kustomize build ./overlays/prod | grep "^kind:"

    Quickly list all resource kinds in a kustomize build

    k8s · resources

  • # Add patchesStrategicMerge in kustomization.yaml

    Use patchesStrategicMerge to partially override base resources

    k8s · patch · strategic-merge

  • cat > patch.yaml <<EOF apiVersion: apps/v1 kind: Deployment metadata: name: myapp spec: replicas: 3 template: spec: containers: - name: myapp resources: limits: memory: 512Mi EOF echo 'patches:\n- path: patch.yaml' >> kustomization.yaml

    Create a strategic merge patch and register it in kustomization.yaml

    k8s · patch · strategic-merge

  • kustomize build --enable-helm ./overlay

    Render helmCharts: block to manifests; note: needs helm in PATH

    gitops · k8s

  • cat <<'EOF' >> kustomization.yaml components: - ../../components/monitoring EOF

    Mixin reusable patches/resources via components: (Kustomize v4+)

    gitops · k8s

  • cat <<'EOF' >> kustomization.yaml replacements: - source: {kind: ConfigMap, name: cfg, fieldPath: data.host} targets: - select: {kind: Deployment} fieldPaths: [spec.template.spec.containers.0.env.0.value] EOF

    modern: replacements: copies a field cross-resource, replaces deprecated vars:

    gitops · k8s

  • cat <<'EOF' >> kustomization.yaml patches: - target: {kind: Deployment, labelSelector: app=api} patch: |- - op: replace path: /spec/replicas value: 3 EOF

    JSON6902 patch applied to all matching targets, no separate file

    gitops · k8s

  • kustomize edit set image app=registry.example.com/app@sha256:<id>

    Pin by immutable digest; newName+digest also settable in images: block

    gitops · security · k8s

  • cat <<'EOF' >> kustomization.yaml secretGenerator: - name: db-creds literals: [PASSWORD=s3cr3t] generatorOptions: disableNameSuffixHash: true EOF

    note: disableNameSuffixHash keeps stable name but breaks rollout-on-change

    secrets · gitops · k8s

  • cat <<'EOF' >> kustomization.yaml openapi: path: crd-schema.json EOF

    Teach kustomize CRD merge/list semantics so patches merge correctly

    gitops · k8s