I want to deploy redis pod which loads a list. Then I will have kubernetes job which will execute bash script with variable taken from that list in redis.
How can I make this redis pod to be auto deleted when all items from a list are used?
I want to deploy redis pod which loads a list. Then I will have kubernetes job which will execute bash script with variable taken from that list in redis.
How can I make this redis pod to be auto deleted when all items from a list are used?
2
Answers
I wrote a bash script which is checking a list, if it is empty it kills a redis-server. That means pod is finished and with ttlSecondsAfterFinished job will be deleted
By default, Kubernetes keeps the completed jobs and associated objects for debugging purposes, and you will lose all the generated logs by them when deleted.
That being said, a job can be automatically deleted by using the TTL mechanism for finished Jobs.
Here you can find an example of a job’s manifest with the TTL enabled and set to delete the job and associated objects (pods, services, etc.) 100 sec after its completion: