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

Oneshot jobs #49

Closed
mumoshu opened this issue Mar 9, 2018 · 11 comments
Closed

Oneshot jobs #49

mumoshu opened this issue Mar 9, 2018 · 11 comments

Comments

@mumoshu
Copy link
Collaborator

mumoshu commented Mar 9, 2018

I'm a bit hesitant to propose this but how about supporting oneshot jobs in helmfile?

An oneshot job can be either a K8S job or a pod created via helm upgrade --install to accomplish a job like db migration, enqueueing a large job to a kind of workflow system, etc.

As of today, we have to resort a variant of kubectl run --image $img to run an oneshot job, even in a situation that our regular app are managed by helm and shared the image, envvars with oneshot jobs.

AFAIK, there's no such tool to support this use-case. And supporting it in helmfile allows us to provide a more docker-compose-like U/X to helm users, but the docker-build feature.

Thoughts?

cc/ @roboll @sstarcher

@sstarcher
Copy link
Contributor

I see this as a job for helm hooks as either a pre-upgrade or a post-upgrade hook. The chart that needs the job to run should be the one running the job.

@mumoshu
Copy link
Collaborator Author

mumoshu commented Mar 9, 2018

@sstarcher Interesting!

Hooks didn't work for me as, for example, I do run a DB migration separately from a deployment of regular app to avoid down time.

I'd use a hook if the job being run via it is composed of just small, short-running, safe tasks. Not for scheduling a large, long-running batch job paired with the regular server app.

@sstarcher
Copy link
Contributor

ya, it won't work if your application does not understand both database versions to allow for live migrations, but the hook is certainly the preferable mechanism as long as development puts in the time to allow the application to be cleanly upgraded.

@mumoshu
Copy link
Collaborator Author

mumoshu commented Mar 9, 2018

@sstarcher A change is almost always backward-compatible but it is just that my migration takes a table lock too long due to the size of table :)

I fully agree that hooks are good for dev purpose. Transparent automatic db migration would indeed be valuable for dev envs!

My use-case seems to be more about prod envs.

@sstarcher
Copy link
Contributor

I don't know enough about your situation, but I'm still not sure why you would not wait until you wanted to do the db migration to upgrade the helm chart. That way the migration got kicked off at the appropriate time.

@mumoshu
Copy link
Collaborator Author

mumoshu commented Mar 9, 2018

@sstarcher Probably you're suggesting the same thing as I do?

I wasn't sure what would be a solution to my problem at the time of writing this issue

But maybe I'd be happy with something like helmfile sync --selector task=migrate-db if it runs helm upgrade --install to run a new db-migration pod. Then, what we'd actually need to implement to support my use-case will be only #28?

@mumoshu
Copy link
Collaborator Author

mumoshu commented Mar 9, 2018

Or maybe helmfile run --selector task=migrate-db to upgrade the chart labeled with task=migrate-db AND keep tailing logs until the task finishes would be even nicer.

@sstarcher
Copy link
Contributor

@mumoshu ya in that situation #28 should give the main portion. As for tailing the logs that could be a nice feature, but it would likely best be supported under a separate issue and maybe with a flag of --follow or such, but that's a good bit more of a complicated situation.

@mumoshu
Copy link
Collaborator Author

mumoshu commented Mar 9, 2018

@sstarcher Thanks. Opened #50

@mumoshu
Copy link
Collaborator Author

mumoshu commented Mar 12, 2018

Hi @gtaylor,
Would this use-case looks like to fit within the scope of helmfile, given it will be supported out-of-box via #28?
Just wanted to sync up with you 😃I appreciate any feedback from you.

@mumoshu
Copy link
Collaborator Author

mumoshu commented Mar 26, 2018

I'll be closing this once I add a small example about it to README.

mumoshu added a commit to mumoshu/helmfile that referenced this issue Mar 26, 2018
mumoshu added a commit to mumoshu/helmfile that referenced this issue Mar 27, 2018
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

No branches or pull requests

2 participants