Why helm upgrade --install failed when previous install is failure?

It happens when a deployment fails as unexpected.

First, check the status of the helm release deployment;

❯ helm ls  -n $namespace

NAME    NAMESPACE   REVISION    UPDATED STATUS  CHART   APP VERSION

Most probably you will see nothing about the problematic helm deployment. So, check the status of the deployment with the -a option;

❯ helm list -n $namespace -a
NAME            NAMESPACE       REVISION    UPDATED          STATUS             CHART         APP VERSION
$release_name   $namespace      7           $update_date     pending-upgrade    $chart_name   $app_version

As you can see the deployment stuck with the pending-upgrade status.

Check the helm deployment secrets;

❯ kubectl get secret -n $namespace                                                                                                                                             42s ⎈ eks_non-prod/monitoring
NAME                                 TYPE                  DATA   AGE
sh.helm.release.v1.$namespace.v1     helm.sh/release.v1    1      2d21h
sh.helm.release.v1.$namespace.v2     helm.sh/release.v1    1      21h
sh.helm.release.v1.$namespace.v3     helm.sh/release.v1    1      20h
sh.helm.release.v1.$namespace.v4     helm.sh/release.v1    1      19h
sh.helm.release.v1.$namespace.v5     helm.sh/release.v1    1      18h
sh.helm.release.v1.$namespace.v6     helm.sh/release.v1    1      17h
sh.helm.release.v1.$namespace.v7     helm.sh/release.v1    1      16h

and describe the last one;

❯ kubectl describe secret sh.helm.release.v1.$namespace.v7
Name:         sh.helm.release.v1.$namespace.v7
Namespace:    $namespace
Labels:       modifiedAt=1611503377
              name=$namespace
              owner=helm
              status=pending-upgrade
              version=7
Annotations:  <none>

Type:  helm.sh/release.v1

Data
====
release:  792744 bytes

You will see the secret has the same status with the failed deployment. So delete the secret;

❯ kubectl delete secret sh.helm.release.v1.$namespace.v7

Now, you should be able to upgrade the helm release. You can check the status of the helm release after the upgrade;

❯ helm list -n $namespace -a
NAME            NAMESPACE       REVISION    UPDATED          STATUS       CHART         APP VERSION
$release_name   $namespace      7           $update_date     deployed     $chart_name   $app_version

This is or has been a helm issue for a while. It only affects the situation where the first install of a chart fails and has up to helm 2.7 required a manual delete of the failed release before correcting the issue and installing again. However there is now a --force flag available to address this case - https://github.com/helm/helm/issues/4004


Just to add...

I have often seen the Error: UPGRADE FAILED: "my-app" has no deployed releases error in Helm 3. Almost every time, the error was in either kubectl, aws-cli or aws-iam-authenticator not Helm. Seems that a lot of problems seem to bubble-up to this exception, which is not ideal.

To diagnose the true issue you can run simple commands in one or more of these tools if you are using them and you should be able to quickly diagnose your problem.

For example:

aws-cli - aws --version to ensure you have the cli installed.

aws-iam-authenticator - aws-iam-authenticator version to check that this is correctly installed.

kubectl - kubectl version will show if the tool is installed.

kubectl - kubectl config current-context will show if you have provided a valid config that can connect to Kubernetes.


Try:

helm delete --purge <deployment> 

This will do the trick

and for helm3 onwards you need to uninstall eg.

helm uninstall <deployment>  -n <namespace>