delete

Deleting Kubernetes Resources

Delete resources by filenames, stdin, resources and names, or by resources and label selector.

JSON and YAML formats are accepted. Only one type of the arguments may be specified: filenames, resources and names, or resources and label selector.

Command

  1. $ kubectl delete ([-f FILENAME] | [-k DIRECTORY] | TYPE [(NAME | -l label | --all)])

Example

Current state

  1. $ kubectl get deployment
  2. NAME READY UP-TO-DATE AVAILABLE AGE
  3. nginx 1/1 1 1 44s
  4. $ kubectl get pods
  5. NAME READY STATUS RESTARTS AGE
  6. nginx-6db489d4b7-9wgn9 1/1 Running 0 28s

Command

  1. $ kubectl delete deployments nginx
  2. deployment.apps "nginx" deleted

Output

  1. $ kubectl get deployments
  2. No resources found in default namespace.