lifecycle
kubectl delete
Deletes one or more resources by name, label, or manifest. Supports graceful termination, forced eviction of stuck pods, and cascading deletion of owned objects.
kubectl delete ([-f FILENAME] | TYPE [NAME | -l label | --all]) [flags] Common flags
| Flag | Purpose |
|---|---|
| -f, --filename | Delete every resource defined in a file, directory, or URL. |
| -l, --selector | Delete resources matching a label selector. |
| --all | Delete all resources of the given type in the namespace. |
| --grace-period | Seconds before force kill; -1 uses object default, 0 with --force is immediate. |
| --force | Skip graceful shutdown (use with --grace-period=0 for stuck pods). |
| --cascade | background, foreground, or orphan to control garbage collection of dependents. |
| --wait | Wait for the resource to be fully deleted before returning. |
Examples
kubectl delete pod web-abc Graceful deletion of a single pod.
kubectl delete -f deploy.yaml Remove every resource defined in a manifest.
kubectl delete pod web-abc --grace-period=0 --force Force-evict a stuck pod (last resort).
kubectl delete deploy,svc -l app=old Bulk delete Deployments and Services by label.
Gotcha
--force does not remove the object from etcd if the API is unreachable; it just skips kubelet's graceful shutdown. --cascade=orphan leaves ReplicaSets/pods running after their owner is gone.
Related commands
kubectl apply
Declaratively creates or updates resources from a manifest file, directory, URL, or kustomization. Tracks the last-applied configuration so subsequent applies compute a three-way merge patch rather than replacing the object.
kubectl create
Imperatively creates a resource from a file or from built-in generators (deployment, configmap, secret, job, etc.). Unlike apply, it fails if the resource already exists and does not record a last-applied annotation.
kubectl rollout
Manages the deployment lifecycle of Deployments, StatefulSets, and DaemonSets. Subcommands cover watching progress, rolling back to a revision, restarting all pods, and pausing/resuming controller reconciliation.
kubectl scale
Sets a new desired replica count for a Deployment, StatefulSet, ReplicaSet, or ReplicationController. Optional preconditions guard against racing with another controller.
kubectl autoscale
Creates a HorizontalPodAutoscaler (v2) that scales a workload based on CPU utilization. For memory or custom/external metrics, author the HPA manifest directly since this command only exposes CPU targets.