-
Notifications
You must be signed in to change notification settings - Fork 40.1k
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
StatefulSet supports all kinds of RestartPolicy #42892
Conversation
Hi @ohmystack. Thanks for your PR. I'm waiting for a kubernetes member to verify that this patch is reasonable to test. If it is, they should reply with Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
Thanks for your pull request. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA). 📝 Please follow instructions at https://github.com/kubernetes/kubernetes/wiki/CLA-FAQ to sign the CLA. Once you've signed, please reply here (e.g. "I signed it!") and we'll verify. Thanks.
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. I understand the commands that are listed here. |
[APPROVALNOTIFIER] This PR is NOT APPROVED The following people have approved this PR: ohmystack Needs approval from an approver in each of these OWNERS Files: We suggest the following people: |
I signed it! |
@bprashanth @enisoc @foxish @janetkuo Would you mind reviewing? |
@kubernetes/sig-apps-api-reviews |
@ohmystack There are a few issues here.
|
@kow3ns
As far as I am concerned, the default RestartPolicy sets to "Always", that's reasonable and can prevent mistakes. To your 3rd issue, the problem is, when the containers
However, I think the "Pod" is too light for those long running jobs. (And, another choice, the "batch/Job" is not fit for scientific computing.) Using "Pod", if a node dies, the Pod can do nothing but waiting for my service to watch the event and recreate one. In this way, my service just becomes a controller, it's like "Deployment/StatefulSet + Allowing OnFailure RestartPolicy". The funny thing is that, people will have to write a whole new controller besides Kubernetes for just allowing OnFailure/Never RestartPolicy to "Deployment/StatefulSet". |
@ohmystack |
@kow3ns You got my point.
I'll close this PR now, and thanks for your discussion above! |
What this PR does / why we need it:
Make StatefulSet to support all kinds of PodSpec.RestartPolicy, instead of allowing "Always" only.
We can allow the Pods in StatefulSet to use "OnFailure" and "Never" to exit when their work is done, instead of restarting over and over again.
In the meantime, it still follows the definition of StatefulSet, which is ordered and stateful.
To implement this, we only need to change the way how we determine a Pod is alive for different RestartPolicy.
Special notes for your reviewer:
A simple use-case:
In machine learning, for training a model in distributed way, we define a bunch of ordered stateful container workers, e.g. "worker-0" "worker-1" ... "worker-n". (They use numbers as their suffix. StatefulSet can manage these continuous numbers for us.)
When training begins, these containers talk to each other by their DNS records. (StatefulSet can help us to make their DNS records.)
When the training is done, all the workers save the result into their persistent volumes and
exit 0
. (StatefulSet helps us to manage their PVs.)Then, all the stateful Pods stop there in success state, and we still can check their logs.
You see, this is a suitable scene to use StatefulSet, and it is really helpful to allow to use "OnFailure" and "Never" RestartPolicy in StatefulSet.
Release note: