1

I had a helm release whose deployment was not successful. I tried uninstalling it so that I can create a fresh one. The weird thing which I found is that there were some resources created partially (a couple of Jobs) because of the failed deployment, Uninstalling the failed deployment using helm does not removes those partially created resources which could cause issues when I try to install the release again with some changes.

My question is: Is there a way where I can ask helm to delete all the related resources of a release completely.

Vijender Kumar
  • 1,285
  • 2
  • 17
  • 26
  • give more info, like what are those partially created things? – Sahadat Hossain Mar 02 '21 at 08:26
  • In my case those partially created things were the jobs created by the chart installation. – Vijender Kumar Mar 02 '21 at 17:48
  • I have a similar issue here, where, after a `helm uninstall`, the pods still persist in microk8s. https://stackoverflow.com/questions/75101715/helm-uninstall-does-not-delete-all-resources-in-microkubernetes – hey Jan 12 '23 at 20:38

2 Answers2

1

Since there are no details on partially created resources. One scenario could be where helm uninstall/delete would not delete the PVC's in the namespace. We resolved this by creating a separate namespace to deploy the application and helm release is uninstalled/deleted, we delete the namespace as well. For a fresh deployment, create a namespace again and do a helm installation on the namespace for a clean install or you can also change the reclaimPolicy to "Delete" while creating the storageClass (by default Reclaimpolicy is retain) as mentioned in the below post

PVC issue on helm: https://github.com/goharbor/harbor-helm/issues/268#issuecomment-505822451

apiVersion: storage.k8s.io/v1
kind: StorageClass
metadata:
   name: rook-ceph-block
provisioner: ceph.rook.io/block
parameters:
  blockPool: replicapool
  # The value of "clusterNamespace" MUST be the same as the one in which your rook cluster exist
  clusterNamespace: rook-ceph-system
  # Specify the filesystem type of the volume. If not specified, it will use `ext4`.
# Optional, default reclaimPolicy is "Delete". Other options are: "Retain", "Recycle" as documented in https://kubernetes.io/docs/concepts/storage/storage-classes/
reclaimPolicy: Delete
DBSand
  • 670
  • 3
  • 10
1

As you said in the comment that the partially created object is a job. In helm there is a concept name hook, which also runs a job for different situations like: pre-install, post-install etc. I thing you used one of this.

The yaml of an example is given below, where you can set the "helm.sh/hook-delete-policy": hook-failed instead of hook-succeeded then if the hook failed the job will be deleted. For more please see the official doc of helm hook

apiVersion: batch/v1
kind: Job
metadata:
  name: {{ .Release.Name | quote }}
  labels:
    app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
    app.kubernetes.io/instance: {{ .Release.Name | quote }}
  annotations:
    # This is what defines this resource as a hook. Without this line, the
    # job is considered part of the release.
    "helm.sh/hook": pre-install
    "helm.sh/hook-weight": "-5"
    "helm.sh/hook-delete-policy": hook-succeeded
spec:
  template:
    metadata:
      name: {{ .Release.Name | quote }}
      labels:
        app.kubernetes.io/managed-by: {{ .Release.Service | quote }}
        app.kubernetes.io/instance: {{ .Release.Name | quote }}
    spec:
      restartPolicy: Never
      containers:
        - name: pre-install-job
          image: "ubuntu"
          #command: ["/bin/sleep","{{ default "10" .Values.hook.job.sleepyTime }}"]
          args:
            - /bin/bash
            - -c
            - echo
            - "pre-install hook"
Sahadat Hossain
  • 3,583
  • 2
  • 12
  • 19