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
Add ExtendedResourceToleration admission controller. #55839
Add ExtendedResourceToleration admission controller. #55839
Conversation
/assign @derekwaynecarr @liggitt |
/lgtm |
138e76c
to
6471801
Compare
Hey, release team reminder. If this PR is approved, please remember to add the 1.9 milestone and approve it for that milestone by Monday, Nov. 20th to make the Code Slush cutoff. Thanks! |
} | ||
|
||
for _, toleration := range pod.Spec.Tolerations { | ||
if len(toleration.Key) == 0 && len(toleration.Value) == 0 && |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: Can this be a function that is something like func podHasWildcardToleration(*api.pod) bool
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I suspect people don't use wildcard toleration much, and also it might be easier from an understandability perspective (both of the code and someone looking at the pod) if you always add the toleration. So I would suggest to just remove this special case where the wildcard toleration already exists.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
/lgtm |
[MILESTONENOTIFIER] Milestone Pull Request Current @bsalamat @davidopp @derekwaynecarr @jiayingz @liggitt @mindprince @vishh Pull Request Labels
|
6471801
to
0b9f41f
Compare
0b9f41f
to
3c4c85f
Compare
/retest |
/lgtm |
/assign @liggitt |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A nit. Fix in follow-up PR is fine.
|
||
// Admit updates the toleration of a pod based on the resources requested by it. | ||
// If an extended resource of name "example.com/device" is requested, it adds | ||
// a toleration with key "example.com/device", operator "Exists" and effect "NoSchedule". |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The result is that such pods can be scheduled to nodes with the "example.com/device" taint, right? Consider adding that in the comment and please also add this plugin to the doc.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes. I will send another PR with the comment fix. And another one to update the public documentation.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
are arbitrary resources allowed? does this give pod authors a way to cause arbitrary taints to be added? I expected a specific prefix/namespace to ensure resource-specific taints were tolerated, not arbitrary taints
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It only adds tolerations for the resource you requested and that resource cannot be in kubernetes.io
namespace.
Now you can request an arbitrary string as the resource (and then this will add that arbitrary string as the toleration) but then your pod will not get scheduled because that arbitrary string doesn't exist as a resource. And if the arbitrary string exists as a resource, we do want this admission controller to add that as a toleration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Now you can request an arbitrary string as the resource (and then this will add that arbitrary string as the toleration) but then your pod will not get scheduled because that arbitrary string doesn't exist as a resource.
Thinking through this some more:
- by default, users can already add arbitrary tolerations to their pod specs
- any cluster using taints/tolerations as a security measure to keep user pods off specific nodes already has to use something like PodTolerationRestriction to whitelist the tolerations a pod is allowed to have
- that whitelist would give control over allowing custom-resource tolerations while disallowing arbitrary security-related tolerations
So I think this still works as is
/approve no-issue |
Release note is user facing. Please add a brief description of what the plugin does and who needs it. |
Updated the release note with more details. When the final release notes doc will get generated, I would link this release note to the documentation in kubernetes.io |
resources := sets.String{} | ||
for _, container := range pod.Spec.Containers { | ||
for resourceName := range container.Resources.Requests { | ||
if helper.IsExtendedResourceName(resourceName) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@mindprince, regarding @liggitt's question, this line ensures that the resourceName
(and the toleration key) has a "kubernetes.io/"
or a "pod.alpha.kubernetes.io/opaque-int-resource-"
prefix. The "pod.alpha.kubernetes.io/opaque-int-resource-"
prefix seems strong enough. But the "kubernetes.io/"
seems very generic, will it collide with other taint key name?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It ensures the opposite. It ensures that the resource name doesn't have kubernetes.io
as the prefix.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Right. I missed the !
.
/hold for @liggitt's question |
/hold |
/hold cancel |
/lgtm |
[APPROVALNOTIFIER] This PR is APPROVED This pull-request has been approved by: bsalamat, caesarxuchao, davidopp, jiayingz, mindprince, vishh Associated issue: 55080 The full list of commands accepted by this bot can be found here.
Needs approval from an approver in each of these OWNERS Files:
You can indicate your approval by writing |
/test all [submit-queue is verifying that this PR is safe to merge] |
Automatic merge from submit-queue. If you want to cherry-pick this change to another branch, please follow the instructions here. |
Update this admission controller in doc kubernetes/website#6618. |
/kind feature
/sig scheduling
/area hw-accelerators
There's elaborate discussion on this in #55080. In short, we would like to enable cluster operators and/or cloud providers to create dedicated nodes with extended resources (like GPUs, FPGAs etc.) that are reserved for pods requesting such resources. Taints is the kubernetes concept to create dedicated nodes. If the cluster operator or cloud provider wants to create dedicated node pools, they are expected to taint the nodes containing extended resources with the key equal to the name of the resource and effect equal to NoSchedule. If they do that, only pods that have a toleration for such a taint can be scheduled there. To make it easy for the user, this admission controller when enabled, automatically adds a toleration with key
example.com/device
, operatorExists
and effectNoSchedule
if an extended resource of nameexample.com/device
is requested.Release note: