Skip to content
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

Merged
merged 26 commits into from Aug 3, 2021

Conversation

Oats87
Copy link
Contributor

@Oats87 Oats87 commented Jul 27, 2021

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

…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>
@Oats87 Oats87 requested a review from a team as a code owner July 27, 2021 03:22
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
Signed-off-by: Chris Kim <oats87g@gmail.com>
pkg/cli/cmds/root.go Outdated Show resolved Hide resolved
@@ -41,17 +41,65 @@ var (
defaultAuditPolicyFile = "/etc/rancher/rke2/audit-policy.yaml"
)

type ControlPlaneResources struct {
Copy link
Member

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.

Copy link
Contributor

@brandond brandond Jul 27, 2021

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:

type ImageOverrideConfig struct {
SystemDefaultRegistry string
KubeAPIServer string
KubeControllerManager string
KubeProxy string
KubeScheduler string

@briandowns
Copy link
Member

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{
Copy link
Contributor

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.

Copy link
Contributor Author

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>
pkg/rke2/rke2_linux.go Show resolved Hide resolved
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-commenter
Copy link

Codecov Report

Merging #1463 (ad5af17) into master (6c1df6c) will decrease coverage by 0.75%.
The diff coverage is 0.00%.

Impacted file tree graph

@@            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              
Flag Coverage Δ
unittests 7.77% <0.00%> (-0.76%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
pkg/cli/cmds/root.go 0.00% <0.00%> (ø)
pkg/podexecutor/staticpod.go 0.00% <0.00%> (ø)
pkg/rke2/rke2.go 0.00% <ø> (ø)
pkg/rke2/rke2_linux.go 0.00% <0.00%> (ø)
pkg/staticpod/staticpod.go 0.00% <0.00%> (ø)
pkg/cli/cmds/agent.go 0.00% <0.00%> (ø)
pkg/windows/service_linux.go 0.00% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 6c1df6c...ad5af17. Read the comment docs.

pkg/staticpod/staticpod.go Outdated Show resolved Hide resolved
Signed-off-by: Chris Kim <oats87g@gmail.com>
…quests/limits

Signed-off-by: Chris Kim <oats87g@gmail.com>
Comment on lines 280 to 294
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)
}
}
Copy link
Contributor

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.

Copy link
Contributor Author

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.

Copy link
Contributor

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>
@Oats87 Oats87 changed the title WIP: Custom resource requests/limits, extra binds, and extra env for control plane static pod components Custom resource requests/limits, extra binds, and extra env for control plane static pod components Aug 3, 2021
Requests: v1.ResourceList{
v1.ResourceCPU: *resource.NewMilliQuantity(args.CPUMillis, resource.DecimalSI),
},
p.Spec.Containers[0].Resources = v1.ResourceRequirements{}
Copy link
Member

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>
@Oats87 Oats87 requested a review from brandond August 3, 2021 18:57
@Oats87 Oats87 merged commit 959247b into rancher:master Aug 3, 2021
@Oats87
Copy link
Contributor Author

Oats87 commented Aug 3, 2021

#1233

Oats87 added a commit to Oats87/rke2 that referenced this pull request Aug 3, 2021
…ol plane static pod components (rancher#1463)

* Add customization of cpu/memory limits/requests and extra binds and env
Oats87 added a commit to Oats87/rke2 that referenced this pull request Aug 3, 2021
Oats87 added a commit that referenced this pull request Aug 3, 2021
@dweomer dweomer mentioned this pull request Aug 24, 2021
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

Successfully merging this pull request may close these issues.

None yet

4 participants