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
Restructure resize policy naming and set default resize policy values #116119
Changes from all commits
8b23497
c5130fb
9411050
9a805db
06e1692
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -22,6 +22,8 @@ import ( | |
v1 "k8s.io/api/core/v1" | ||
"k8s.io/apimachinery/pkg/runtime" | ||
"k8s.io/apimachinery/pkg/util/intstr" | ||
utilfeature "k8s.io/apiserver/pkg/util/feature" | ||
"k8s.io/kubernetes/pkg/features" | ||
"k8s.io/kubernetes/pkg/util/parsers" | ||
"k8s.io/utils/pointer" | ||
) | ||
|
@@ -157,6 +159,29 @@ func SetDefaults_Pod(obj *v1.Pod) { | |
} | ||
} | ||
} | ||
if utilfeature.DefaultFeatureGate.Enabled(features.InPlacePodVerticalScaling) && | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Follow up with a test? :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yes, a more comprehensive test is warranted, sorry for the miss. I'll bring it with GetPodQoS -> PodQOSClass change. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. |
||
obj.Spec.Containers[i].Resources.Requests != nil { | ||
// For normal containers, set resize restart policy to default value (NotRequired), if not specified. | ||
resizePolicySpecified := make(map[v1.ResourceName]bool) | ||
for _, p := range obj.Spec.Containers[i].ResizePolicy { | ||
resizePolicySpecified[p.ResourceName] = true | ||
} | ||
setDefaultResizePolicy := func(resourceName v1.ResourceName) { | ||
if _, found := resizePolicySpecified[resourceName]; !found { | ||
obj.Spec.Containers[i].ResizePolicy = append(obj.Spec.Containers[i].ResizePolicy, | ||
v1.ContainerResizePolicy{ | ||
ResourceName: resourceName, | ||
RestartPolicy: v1.NotRequired, | ||
}) | ||
} | ||
} | ||
if _, exists := obj.Spec.Containers[i].Resources.Requests[v1.ResourceCPU]; exists { | ||
setDefaultResizePolicy(v1.ResourceCPU) | ||
} | ||
if _, exists := obj.Spec.Containers[i].Resources.Requests[v1.ResourceMemory]; exists { | ||
setDefaultResizePolicy(v1.ResourceMemory) | ||
} | ||
} | ||
} | ||
for i := range obj.Spec.InitContainers { | ||
if obj.Spec.InitContainers[i].Resources.Limits != nil { | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
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.
CC: @marquiz, was it you we discussed it with when talking about QoS-class resources KEP: kubernetes/enhancements#3008. Cannot recall now. Maybe you have some naming input here
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.
No I don't remember discussing this aspect of in-place updates in context of the QoS resources KEP. I don't think we've got this deep in the details there, yet.