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

chore(jobs): add ttl of 30 days to job templates #1070

Merged
merged 2 commits into from
Aug 9, 2023
Merged

Conversation

deer-wmde
Copy link
Contributor

There are currently >300 job objects floating around in our prod cluster. Are there any downsides of setting a ttl to them? I went for 30 days here

https://kubernetes.io/docs/concepts/workloads/controllers/ttlafterfinished/

As an alternative we could add a script or something that edits this into the spec of existing jobs, so we could also opt for "cleaning" whenever we feel like its too much, instead of specifying it in beforehand (this would also come in handy to get rid of the current pile of old completed jobs)

@m90
Copy link
Contributor

m90 commented Aug 8, 2023

I could also live with a TTL of 7 days I guess.

this would also come in handy to get rid of the current pile of old completed jobs

I doubt we miss out on anything if we delete all of them as of now. Can't think of anything we'd need to retroactively debug right now.

@deer-wmde
Copy link
Contributor Author

I could also live with a TTL of 7 days I guess.

Me too.

I doubt we miss out on anything if we delete all of them as of now. Can't think of anything we'd need to retroactively debug right now.

Yup, I think so too. I would run something like

for JOB in $(kubectl get --no-headers jobs.batch | awk '{ print $1 }'); do
  kubectl patch jobs.batch "$JOB" -p "$(kubectl get jobs.batch "$JOB" -o yaml | yq '.spec.ttlSecondsAfterFinished = 604800')";
done

@m90
Copy link
Contributor

m90 commented Aug 9, 2023

Couldn't we just really delete them ourselves, e.g.

kubectl delete jobs --field-selector status.successful=1 

@deer-wmde
Copy link
Contributor Author

Couldn't we just really delete them ourselves, e.g.

kubectl delete jobs --field-selector status.successful=1 

lol yeah that is A LOT easier 👍

@deer-wmde deer-wmde merged commit c8d9e31 into main Aug 9, 2023
2 checks passed
@deer-wmde deer-wmde deleted the de/jobs-add-ttl branch August 9, 2023 18:03
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants