Skip to content

Add Release TTL to set the time-to-live of a helm release #18

@rtpro

Description

@rtpro

Add the ability to set the expiration time to a release, after the TTL(time-to-live) expires the release is deleted.

Command to set a TTL after which the release will be deleted.

  • Set TTL time:
    helm release tll <RELEASE-NAME> --set=<>21 days # Runs kubectl apply with Cronjob object

  • Get TTL time:
    helm release ttl <RELEASE-NAME> # Retruns the TTL timeout, time left

  • Remove TTL time:
    helm release ttl <RELEASE-NAME> -unset # Remove the TTL timeout


Design:

  • Setting a TTL for a release creates a corn job in the namespace of the release to delete the release on timeout.
  • Use date --date="1 day" to set TTL timeout, the date command should output the cronjob time formatting.
  • Use Kubernetes cronjobs to delete timeout helm releases, the job use a Docker image with the helm command to delete the release.

Cronjob Object

apiVersion: batch/v1
kind: CronJob
metadata:
  name: <release-name>-ttl
  namespace: <release-namespace>
spec:
  schedule: "* * * * *"  # < date --date="4 days"
  jobTemplate:
    spec:
      template:
        spec:
          containers:
          - name: hello
            image: ibmcom/helm
            imagePullPolicy: IfNotPresent
            command:
            - helm uninstall <RELEASE NAME> && \
              kubectl delete chronjob <release-name>-ttl
          restartPolicy: OnFailure

Metadata

Metadata

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions