Re:Unironically using Kubernetes for my personal blog
by thedevelopnik on Thursday March 18, 2021 @12:29PM
(#26504393)
Jobs can get useful in more complex workflows. The most common use I’ve had for them us running a smoke test suite or a database migration as part of the larger workflow for a big Rails app.
[ Parent
| on HN ]
Re:Unironically using Kubernetes for my personal blog
by Hamuko on Thursday March 18, 2021 @02:13PM
(#26505666)
But why wouldn't I just run a database migration as part of my CI flow? I don't understand why I would add a persistent element to my Kubernetes cluster for just a one-off task, since Jobs do not actually automatically remove themselves from the cluster. And as far as I know, you can't even reuse the already created Job, so if I want to migrate the database again, I need to make it from scratch.
Re:Unironically using Kubernetes for my personal blog
by kube-system on Thursday March 18, 2021 @02:54PM
(#26506174)
Well, CI doesn't necessarily mean CD. In more than a few cases, I've found it advantageous to use CI to do automatic container builds, but manually attend to the deployment upgrades, particularly when things like db migrations are happening.
> Jobs do not actually automatically remove themselves from the cluster.
set `ttlSecondsAfterFinished` and they will
> And as far as I know, you can't even reuse the already created Job, so if I want to migrate the database again, I need to make it from scratch.
If you need to run a job on demand, you can always 'kubectl apply -f' the metadata, or you can create a cronjob and `kubectl create job --from` your cronjob. Or, if it needs to run at a particular part of your installation/upgrade workflow, use helm hooks. Jobs are intended to be a one-time thing, so the lack of functionality to repeatedly run them is intentional.