Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Open
rtpro opened this issue Aug 22, 2022 · 0 comments
Open

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

rtpro opened this issue Aug 22, 2022 · 0 comments
Assignees
Labels
enhancement New feature or request

Comments

@rtpro
Copy link
Contributor

rtpro commented Aug 22, 2022

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
@rtpro rtpro added the enhancement New feature or request label Aug 22, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants