liveBook · Manning

Kubectl delete

As explained in Kubernetes in Action, Second Edition

kubectl delete is a kubectl command that removes Kubernetes objects identified by names, manifest files, or other selectors.

kubectl delete removes Kubernetes objects by name, manifest file, or selector. Deleting a Pod means removing the Pod and its containers, not stopping it for later restart. section 5.6.1

Use the command in progressively broader ways:

  • Delete named objects: kubectl delete po kiada, or provide several names separated by spaces. section 5.6.1
  • Delete objects described by files: kubectl delete -f pod.kiada-ssl.yaml, multiple comma-separated files, or a directory; use --recursive for subdirectories. section 5.6.2
  • Delete all included object kinds and instances with kubectl delete all --all; review the scope with --interactive. section 5.6.4

Removing an application

If an application was created with kubectl apply -f app.yaml, remove its defined objects with kubectl delete -f app.yaml. Kubernetes may report a Pod as Terminating while containers shut down; use --wait=false to return without waiting. section 5.6.2 section 5.6.1

$ kubectl delete po kiada
pod "kiada" deleted

Shows the command and confirmation output for deleting a named Pod. section 5.6.1

How Kubernetes in Action, Second Edition covers it

How deep it goes
Explains names, manifests, directories, all-object deletion, waiting, and termination, but defers detailed container shutdown behavior.
Examples
Demonstrates deleting kiada Pods, manifest-defined Pods, directories, and all included application objects.
What it assumes
Assumes familiarity with kubectl, Kubernetes objects, Pods, and manifest files.
What you can do after
Operate kubectl to remove named objects, manifest-defined applications, or broad object sets with controlled waiting.
How it connects
Connects Pods, Deployments, ReplicaSets, Services, manifest files, and container shutdown.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Kubernetes in Action, Second Edition. The section links point to the parts of the book it draws on.