Search code examples
imageazurekubernetesdeploymentkubectl

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


Solution

  • 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.