Skip to content
Related Articles
Get the best out of our app
GeeksforGeeks App
Open App
geeksforgeeks
Browser
Continue

Related Articles

Kubernetes – Kubectl Delete

Improve Article
Save Article
Like Article
Improve Article
Save Article
Like Article

Pre-requisite: Kubernetes

Kubernetes is an open-source Container Management tool that automates container deployment, container scaling, descaling, and container load balancing (also called a container orchestration tool). It is written in Golang and has a huge community because it was first developed by Google and later donated to CNCF (Cloud Native Computing Foundation). kubectl delete is used to delete resources by using a configuration file or by using the type of resource and the resource name.

kubectl delete ([-f FILENAME] | TYPE [(NAME | --all)])

Example: Suppose we are having Nginx web server deployment and Service running.

nginx file

 

nginx service file

 

kubectl get all

 

Deleting  Deployment:

$ kubectl delete deployment deployment_name

Alternatively, you can also point your terminal to the file containing the deployment config file and use the command

$ kubectl delete -f your_config_file.yaml
kubectl delete command

 

Deleting  Service:

$ kubectl delete service service_name

Alternatively, you can also point your terminal to the file containing the deployment config file and use the command

$ kubectl delete -f your_config_file.yaml
kubectl delete command

 

Deleting All Resources:

$ kubectl delete resource_type -all

Examples:

  • Deleting all deployments
$ kubectl delete deployment -all
  • Deleting all services
$ kubectl delete service --all
My Personal Notes arrow_drop_up
Last Updated : 30 Mar, 2023
Like Article
Save Article
Similar Reads
Related Tutorials