How to delete a deployment / image in kubernetes
Solution 1
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.
Solution 2
Use the below command.
kubectl delete deployment deployment-name-here
More about the command here.
Related videos on Youtube
Carlo Luther
Know languages: c, c#, c++, java, VB, asp.net, sql server, Matlab Know Microcontroller platform: PIC, BasicStamp, Arduino ASP.NET MVC Developer, Angular 2, learning EOS (Dawn) spoken languages: English, Italian, French, Russian
Updated on July 10, 2022Comments
-
Carlo Luther almost 2 years
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.
I've run
kubectl get all -A
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>'
-
switchboard.op about 4 yearsMake sure you're specifying the right namespace as Agrhya suggests.
-
-
Praveen Sripati about 4 yearsMaybe the default namespace is not set properly. Use the -n option to explicitly specify the namespace.
-
Sumer about 3 yearsBut still lot of stuff like ingress etc are not deleted automatically, you need to delete that manually
-
Gaurav over 2 yearsworks flawlessly!