Kubernetes: Delete & force delete
6 Kubernetes commands: Delete & force delete. Click a command to see what each part does.
Kubernetes: Delete & force deleteIndex
- Whole sheet137
- Basics: cluster, namespaces & resources17
- Get & list resources23
- Context & namespace3
- Find resources9
- Debug: describe, events, logs8
- Exec, port-forward, copy4
- Deploy, roll out, roll back, scale7
- Cleanup & nodes4
- Services, DNS & networking checks6
- Environment, config & secrets of workloads9
- Create, generate & apply YAML10
- Patch, label, annotate & scale9
- Delete & force delete6
- Nodes, scheduling & access control11
- Productivity: aliases, contexts & output11
Delete & force delete6
kubectl delete po <pod> -n <namespace>Delete a pod (its controller recreates it)CautionWhat each part does
delete po <pod>graceful delete; a Deployment/StatefulSet makes a new one-n <namespace>in this namespace (default: the context's namespace; -A for all)
kubectl delete po <pod> -n <namespace> --grace-period=0 --forceForce delete a stuck podDestructiveWhat each part does
--grace-period=0 --forceremove from the API immediately without waiting for the kubelet (pod stuck in Terminating)
Tip The container may still be running on the node; for StatefulSets this can cause two pods with the same identity.
kubectl delete po,svc -l app=<app> -n <namespace>Delete by labelDestructiveWhat each part does
po,svcseveral types at once-l app=<app>everything with that label
kubectl delete <type> <name> -n <namespace>Delete a resource by type and nameDestructiveWhat each part does
<type> <name>e.g. deploy api, svc api, cm app-config, rs api-7d9f
kubectl delete all --all -n <namespace>Delete everything in a namespace (keep the namespace)DestructiveWhat each part does
allpods, services, deployments, replicasets, statefulsets, jobs (not configmaps, secrets, PVCs)--allevery object of those types
kubectl delete ns <namespace>Delete a namespace and everything in itDestructiveWhat each part does
delete nsremoves the namespace and all objects in it, including PVCs and secrets
Nothing matches.
My DevOps Playbook by Angelo John Calleja