Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to delete a deployment / image in kubernetes

I'm running kubernetes in azure. I want to delete a specific deployment, with AZ AKS or kubectl.

The only info I've found is how to delete pods, but this is not what I'm looking for, since pods will regenerate once deleted.

I know I just can go to the ui and delete the deployment but i want to do it with az aks or kubectl.

enter image description here

I've run

kubectl get all -A

enter image description here

Then I copy the name of the deployment that I want to delete and run:

kubectl delete deployment zr-binanceloggercandlestick-btcusdt-2hour

kubectl delete deployment deployment.apps/zr-binanceloggercandlestick-btcusdt-12hour

but noting no success, i get these errors:

Error from server (NotFound): deployments.extensions "zr-binanceloggercandlestick-btcusdt-2hour" not found


error: there is no need to specify a resource type as a separate argument when passing arguments in resource/name form (e.g. 'C:\Users\amnesia\.azure-kubectl\kubectl.exe get resource/<resource_name>' instead of 'C:\Users\amnesia\.azure-kubectl\kubectl.exe get resource resource/<resource_name>'

enter image description here

like image 862
Carlo Luther Avatar asked Apr 06 '20 11:04

Carlo Luther


People also ask

How do I delete a deployment permanently in Kubernetes?

For example, if you had a Deployment called “web” with 3 replicas, and 1 of them is running on the node that will be deleted, and it is not acceptable to only run 2 replicas at any time, you would scale the Deployment up to 4 replicas, wait for the new pod to become Ready, and then delete the old pod using kubectl ...

How do I delete old deployments?

If you want to delete a deployment, but keep all the underlying resources, you must use the Google Cloud CLI or the API. In the Google Cloud console, open the Deployments page. In the list of deployments, select the check boxes for the deployments that you want to delete. On the top of the page, click Delete.

How do I remove objects from Kubernetes?

You can use the delete command to delete an object from a cluster: delete <type>/<name>


1 Answers

Find out all deployments across all namespaces

kubectl get deploy -A

Then delete a deployment with deploymentname from namespace. deploymentname can be found from above command.

kubectl delete deploy deploymentname -n namespacename

Docs on how to configure kubectl to connect to AKS.

like image 194
Arghya Sadhu Avatar answered Oct 05 '22 13:10

Arghya Sadhu