Search code examples
kuberneteskubernetes-helmkubectl

What's the difference between helm uninstall, helm delete and kubectl delete


I want to remove pod that I deployed to my cluster with helm install.

I used 3 ways to do so:

  1. helm uninstall <release name> -> remove the pod from the cluster and from the helm list
  2. helm delete <release name> -> remove the pod from the cluster and from the helm list
  3. kubectl delete -n <namespace> deploy <deployment name> -> remove the pod from the cluster but not from the helm list

What's the difference between them? Is one better practice then the other?


Solution

  • helm delete is an alias for helm uninstall and you can see this when you check the --help syntax:

    $ helm delete --help
    ...
    Usage:
      helm uninstall RELEASE_NAME [...] [flags]
    

    kubectl delete ... just removes the resource in the cluster.

    Doing helm uninstall ... won't just remove the pod, but it will remove all the resources created by helm when it installed the chart. For a single pod, this might not be any different to using kubectl delete... but when you have tens or hundreds of different resources and dependent charts, doing all this manually by doing kubectl delete... becomes cumbersome, time-consuming and error-prone.

    Generally, if you're deleting something off of the cluster, use the same method you used to install it in the first place. Namely, if you used helm install or helm upgrade --install to install it into the cluster, use helm uninstall to remove it (or helm delete --purge if you're still running Helm v2); and if you used kubectl create or kubectl apply, use kubectl delete to remove it.