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
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# Runskubectl applywith Cronjob objectGet TTL time:
helm release ttl <RELEASE-NAME># Retruns the TTL timeout, time leftRemove TTL time:
helm release ttl <RELEASE-NAME> -unset# Remove the TTL timeoutDesign:
date --date="1 day"to set TTL timeout, thedatecommand should output the cronjob time formatting.helmcommand to delete the release.Cronjob Object