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
Custom resource requests/limits, extra binds, and extra env for control plane static pod components #1463
Conversation
…d extra binds and env Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
@@ -41,17 +41,65 @@ var ( | |||
defaultAuditPolicyFile = "/etc/rancher/rke2/audit-policy.yaml" | |||
) | |||
|
|||
type ControlPlaneResources struct { |
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.
We can probably drop all of the prefixed "kube" since that's implied and will make visually scanning this struct a lot easier.
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 am +1 on keeping them as-is for parity with the Image stuff:
Lines 47 to 52 in 6c1df6c
type ImageOverrideConfig struct { | |
SystemDefaultRegistry string | |
KubeAPIServer string | |
KubeControllerManager string | |
KubeProxy string | |
KubeScheduler string |
Can you provide a few examples of what the data passed in would look like to the newly added arguments? |
CloudControllerManager: cfg.ExtraEnv.CloudControllerManager.Value(), | ||
} | ||
|
||
extraMounts := podexecutor.ControlPlaneMounts{ |
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.
Should we do input validation on these? Later on we do mount := strings.Split(rawMount, ":")
and reference mount[1]
but we don't actually validate that they contain at least one semicolon, so that could cause a runtime panic.
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.
Yeah, I've added some basic input validation to check that the length of the resultant slice is 2, but this doesn't actually validate that the paths are valid or anything. I'm not sure how far we want to go with the validations, as the kubelet will block the static pods from running itself as well if the volume mounts/source don't make sense
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Codecov Report
@@ Coverage Diff @@
## master #1463 +/- ##
=========================================
- Coverage 8.52% 7.77% -0.76%
=========================================
Files 20 21 +1
Lines 1689 1852 +163
=========================================
Hits 144 144
- Misses 1523 1686 +163
Partials 22 22
Flags with carried forward coverage won't be shown. Click here to find out more.
Continue to review full report at Codecov.
|
Signed-off-by: Chris Kim <oats87g@gmail.com>
7d91757
to
4be20c1
Compare
…quests/limits Signed-off-by: Chris Kim <oats87g@gmail.com>
pkg/staticpod/staticpod.go
Outdated
if len(mount) != 2 || len(mount) != 3 { | ||
logrus.Errorf("mount for pod %s %s was not valid", p.Name, rawMount) | ||
continue | ||
} | ||
var ro bool | ||
if len(mount) == 3 { | ||
switch strings.ToLower(mount[2]) { | ||
case "ro": | ||
ro = true | ||
case "rw": | ||
ro = false | ||
default: | ||
logrus.Errorf("unknown mount option: %s encountered in extra mount %s for pod %s", mount[2], rawMount, p.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.
I think this would be a lot tidier as a switch len(mount)
. case 2 is a noop, case 3 checks for ro/rw, default is an error.
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 changed to using a switch, but am now doing a switch within a switch. I think this is acceptable.
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 put a switch in your switch, so you can switch while you switch /xzibit
… for env var parsing Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Requests: v1.ResourceList{ | ||
v1.ResourceCPU: *resource.NewMilliQuantity(args.CPUMillis, resource.DecimalSI), | ||
}, | ||
p.Spec.Containers[0].Resources = v1.ResourceRequirements{} |
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 these not already initialized to their 0 value for that type?
Signed-off-by: Chris Kim <oats87g@gmail.com>
…ol plane static pod components (rancher#1463) * Add customization of cpu/memory limits/requests and extra binds and env
…ol plane static pod components (rancher#1463)
Proposed Changes
Allow for custom resource requests/limits, extra binds, and extra environment variables for control plane static pod components
Types of Changes
CLI, static pod executor
Verification
Linked Issues
Further Comments