Kubernetes JSONPath and Kustomize Cheat Sheet/Apply and prune kustomization

Apply a kustomization and prune matching managed objects.

Section: Kustomize with kubectl

Apply and prune kustomization

bash
bash
kubectl apply -k overlays/prod --prune -l app.kubernetes.io/managed-by=kustomize
Explanation

Apply a kustomization and prune matching managed objects.

Learn the surrounding workflow

Compare similar commands or jump into common fixes when this command is part of a bigger troubleshooting path.

Related commands

Same sheet · prioritizing Kustomize with kubectl
Render kustomization
Build a kustomization without applying it.
OpenIn sheetbashsame section
Apply kustomization
Apply resources from a kustomization directory.
OpenIn sheetbashsame section
Delete kustomized resources
Delete resources generated by a kustomization.
OpenIn sheetbashsame section
Diff kustomized resources
Preview the changes from a kustomization.
OpenIn sheetbashsame section
Generate configmap YAML dry-run
Generate YAML that can be committed into Kustomize overlays.
OpenIn sheetbashsame section
List pod names
Print all pod names in a namespace.