delete
What is delete?
delete: Remove resources by name, label, or file. Deleting a Deployment also removes its Pods. kubectl delete removes resources from a Kubernetes cluster, by name, label or the file that created them. kubectl delete -f deployment.yaml removes everything defined in that file. Deleting a Deployment also removes the pods it manages. Deleting a single pod that belongs to a Deployment does not really remove it; the Deployment starts a replacement straight away. That makes kubectl delete pod a common way to restart a misbehaving pod.
Frequently asked questions about delete
What should you keep in mind with delete?
Be careful with labels and namespaces. kubectl delete pods -l app=web in the wrong namespace, or kubectl delete namespace, can remove far more than intended, including data in persistent volumes depending on their policy. Check your current context with kubectl config current-context before deleting anything, especially when you work with several clusters.
What does an example of delete look like?
kubectl delete pod web-7d9f8c-abc12 kubectl delete -f deployment.yaml At a glance
| Category | Kubernetes |
|---|---|
| Explained by | Reinier de la Parra |
| Updated |