not able to delete the helm release using cornjob in kubernets

10/25/2021

Here is the yaml file what should find and delete the helm release, but is not able to delete the same.

apiVersion: batch/v1beta1
kind: CronJob
metadata:
  name: cronbox
  namespace: avinash-new
spec:
  serviceAccount: default
  successfulJobsHistoryLimit: 2
  failedJobsHistoryLimit: 2
  schedule: "*/1 * * * *"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: cronbox
            image: busybox
            args:
            #command: 'sh'
            - '-uexc'
            - 'releases=$(helm ls -a -q nodejs-chart.*); helm delete --purge $releases;'
            env:
            - name: TILLER_NAMESPACE
              value: mynamespace-build
            - name: KUBECONFIG
              value: /kube/config
            #volumeMounts:
            #- mountPath: /kube
              #name: kubeconfig
          restartPolicy: OnFailure
          volumes:
          - name: kubeconfig
            configMap:
              name: cronjob-kubeconfig

Please help me with the same. the expectation is "Need to delete the helm releases periadically like every 5 mins".

-- Avinash Rathod
google-kubernetes-engine
kubernetes
kubernetes-helm
kubernetes-ingress
openshift

1 Answer

10/25/2021

image: busybox does not come with helm command. You can try this image instead.

-- gohm'c
Source: StackOverflow