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

Additional kubelet configuration settings #2930

Merged
merged 6 commits into from
May 4, 2023

Conversation

stmcginnis
Copy link
Contributor

@stmcginnis stmcginnis commented Mar 22, 2023

Issue number:

Closes: #2877
Closes: #1792
Closes: #1445
Closes: #2977

Description of changes:

This adds new settings that can be used for soft eviction, graceful shutdown, CPU quota enforcement, and memory manager policy.

The new settings are:

Soft eviction

  • settings.kubernetes.eviction-soft
  • settings.kubernetes.eviction-soft-grace-period
  • settings.kubernetes.eviction-max-pod-grace-period

eviction-soft is the same as the existing eviction-hard but allows a grace period before pods are evicted. The eviction-soft-grace-period allows setting this grace period for each of the support eviction keys. eviction-max-grace-period is used to set an overall maximum for the eviction grace period.

Graceful shutdown

  • settings.kubernetes.shutdown-grace-period
  • settings.kubernetes.shutdown-grace-period-for-critical-pods

These allow setting a grace period to wait on node shut down to allow pods to exit. Of that grace period, a portion can be dedicated to making sure critical pods are shut down.

CPU quota enforcement

  • settings.kubernetes.cpu-cfs-quota-enforced

This sets a flag telling kubelet whether or not to enforce quota for containers that specify CPU limits. The default behavior is to enforce these quotas.

For additional reference on the kubelet setting values, see the node eviction documentation and the KubeletConfiguration docs.

Memory manager

  • settings.kubernetes.memory-manager-policy
  • settings.kubernetes.memory-manager-reserved-memory

Allows configuring kubelet settings for the memory manager.

Testing done:

Built and deployed a cluster. Configured these settings with:

apiclient apply << EOF
[settings.kubernetes.eviction-hard]
"memory.available" = "15%"

[settings.kubernetes.eviction-soft]
"memory.available" = "12%"

[settings.kubernetes.eviction-soft-grace-period]
"memory.available" = "30s"

[settings.kubernetes]
cpu-cfs-quota-enforced = false
shutdown-grace-period = "30s"
shutdown-grace-period-for-critical-pods = "10s"
eviction-max-pod-grace-period = 40
memory-manager-policy = "Static"

[settings.kubernetes.memory-manager-reserved-memory.0]
enabled = true
memory = "674Mi"
EOF

Verified values were accepted. The performed:

cat /etc/kubernetes/kubelet/config

Verified the config file had the expected configuration keys and values. Then ran:

systemctl status kubelet
journalctl -u kubelet

And made sure there were no errors or issues with service operation.

Terms of contribution:

By submitting this pull request, I agree that this contribution is dual-licensed under the terms of both the Apache License, version 2.0, and the MIT license.

@stmcginnis stmcginnis force-pushed the kubelet-config branch 2 times, most recently from 6803ac4 to 209c2bc Compare March 22, 2023 21:34
Release.toml Outdated Show resolved Hide resolved
@jpculp
Copy link
Member

jpculp commented Mar 23, 2023

Should #2742 be part of this as well?

@stmcginnis
Copy link
Contributor Author

Should #2742 be part of this as well?

My initial reaction was yes, but after reading through that some more, I think it might be safer to keep that one separate. It has some special casing since it's only applicable to 1.25 and later.

I think if this one merges first, that one could just get added to the same migration if it ends up being in the same release cycle. But I think it would be better to keep that separate in its own PR.

@kahirokunn
Copy link

I am very happy with this PR as I just needed a shutdown-grace-period !

@stmcginnis
Copy link
Contributor Author

Rebased to resolve merge conflicts.

@stmcginnis
Copy link
Contributor Author

Added memory manager policy and settings.

README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
README.md Outdated Show resolved Hide resolved
sources/models/src/modeled_types/kubernetes.rs Outdated Show resolved Hide resolved
sources/models/src/modeled_types/shared.rs Outdated Show resolved Hide resolved
@stmcginnis stmcginnis force-pushed the kubelet-config branch 2 times, most recently from 1b8e061 to 9507287 Compare April 12, 2023 16:20
@stmcginnis
Copy link
Contributor Author

stmcginnis commented Apr 12, 2023

Rebased to address conflict in Release.toml due to 1.13.3 and 1.13.4.

Copy link
Contributor

@zmrow zmrow left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM!

This adds a setting to be able to set the KubeletConfig value
`cpuCFSQuota` to `false`.

Signed-off-by: Sean McGinnis <stmcg@amazon.com>
This adds the settings:

- `settings.kubernetes.shutdown-grace-period`
- `settings.kubernetes.shutdown-grace-period-for-critical-pods`

These control how long kubelet will wait on shutdown for pods to exit,
and what portion of that period to dedicate to waiting for critical pods
to exit.

Signed-off-by: Sean McGinnis <stmcg@amazon.com>
This adds the settings:

- `settings.kubernetes.eviction-soft`
- `settings.kubernetes.eviction-soft-grace-period`
- `settings.kubernetes.eviction-max-pod-grace-period`

To configure the Kubelet soft eviction settings. This is similar to the
existing ``settings.kubernetes.eviction-hard` with additional
configuration needed to control the behavior of the soft eviction
thresholds.

Signed-off-by: Sean McGinnis <stmcg@amazon.com>
This adds a `NonNegativeInteger` type to our model to be able to model
setting values that need to be between 0 and i32::MAX.

Signed-off-by: Sean McGinnis <stmcg@amazon.com>
This enables the kubelet memory manager and allows setting its values
and the memory manager policy.

Signed-off-by: Sean McGinnis <stmcg@amazon.com>
Signed-off-by: Sean McGinnis <stmcg@amazon.com>
@stmcginnis stmcginnis merged commit 7a63929 into bottlerocket-os:develop May 4, 2023
37 checks passed
@stmcginnis stmcginnis deleted the kubelet-config branch May 4, 2023 22:58
@sanjeevpandey19
Copy link

sanjeevpandey19 commented May 8, 2023

Hi @stmcginnis, First of all, thanks for this PR. Just out of curiosity, wanted to know if this is going to be part of the 1.14.0 release.

@stmcginnis
Copy link
Contributor Author

Hi @stmcginnis, First of all, thanks for this PR. Just out of curiosity, wanted to know if this is going to be part of the 1.14.0 release.

Hi @sanjeevpandey19! Yes, hoping to have this part of the 1.14.0 release. Everything is subject to change based on what is found and testing and other issues of course, but hoping to have this in a 1.14.0 release in the very near future. ;)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet