Skip to content

ScaleTask for scaling deployments to a particular replica count #459

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

Closed
benlangfeld opened this issue Apr 1, 2019 · 5 comments
Closed

Comments

@benlangfeld
Copy link
Contributor

Feature request

If the maintainers agree with the feature as described here, I intend to submit a Pull Request myself.

Proposal: A scale task, similar to RestartTask which patches Deployment/spec/replicas.

Our use case is replacing the schema of a SQL database used by an application deployed by kubernetes-deploy. While this schema reload is happening, we want to effectively shut down application processes to prevent them from encountering and loudly reporting errors. Our plan is to scale all Deployment resources to a replica count of 0, reload the database schema, and then trigger a deployment.

An alternative approach would be to perform a new deployment with the replica-count set to 0, but this requires adding logic to templates to prevent running bare pods for the likes of database migrations in the initial deployment.

@KnVerey
Copy link
Contributor

KnVerey commented Apr 2, 2019

Do I understand correctly that the value added over using kubectl scale is that it would affect multiple Deployment resources identified via an annotation?

Might something like kubectl scale --replicas=0 deployment --all --selector=scale-me=true work for your use case?

@benlangfeld
Copy link
Contributor Author

@KnVerey Such a command prints "error: no objects passed to scale". I ended up using this:

kubectl get deployments --no-headers=true --output=name --selector=foo | xargs -I % kubectl scale --replicas=0 %

@KnVerey
Copy link
Contributor

KnVerey commented Apr 3, 2019

That error sounds like maybe the selector was wrong of one of the args was missing? It works fine for me:

image

@benlangfeld
Copy link
Contributor Author

Indeed you're right. I'm not sure what I had been doing last time I tried, but your example does work. Apologies for the noise. I don't think this does carry enough value to move forward.

@Ticiano-mw
Copy link

Ticiano-mw commented May 5, 2020

I was having the same problem. It was the hallowed namespace selection! You probably were missing the
-n <namespace> flag to your scale command like me.
Cheers!

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

3 participants