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

[WIP] feat(nodeadm): Add default system reserved resources #1808

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion nodeadm/internal/kubelet/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ func (k *kubelet) writeKubeletConfig(cfg *api.NodeConfig) error {
// KubeletConfiguration types:
// https://pkg.go.dev/k8s.io/kubelet/config/v1beta1#KubeletConfiguration
type kubeletConfig struct {
metav1.TypeMeta `json:",inline"`

Address string `json:"address"`
Authentication k8skubelet.KubeletAuthentication `json:"authentication"`
Authorization k8skubelet.KubeletAuthorization `json:"authorization"`
Expand All @@ -63,6 +65,7 @@ type kubeletConfig struct {
ClusterDNS []string `json:"clusterDNS"`
ClusterDomain string `json:"clusterDomain"`
ContainerRuntimeEndpoint string `json:"containerRuntimeEndpoint"`
EnforceNodeAllocatable []string `json:"enforceNodeAllocatable"`
EvictionHard map[string]string `json:"evictionHard,omitempty"`
FeatureGates map[string]bool `json:"featureGates"`
HairpinMode string `json:"hairpinMode"`
Expand All @@ -78,9 +81,9 @@ type kubeletConfig struct {
RegisterWithTaints []v1.Taint `json:"registerWithTaints,omitempty"`
SerializeImagePulls bool `json:"serializeImagePulls"`
ServerTLSBootstrap bool `json:"serverTLSBootstrap"`
SystemReserved map[string]string `json:"systemReserved,omitempty"`
SystemReservedCgroup *string `json:"systemReservedCgroup,omitempty"`
TLSCipherSuites []string `json:"tlsCipherSuites"`
metav1.TypeMeta `json:",inline"`
}

type loggingConfiguration struct {
Expand Down Expand Up @@ -119,6 +122,7 @@ func defaultKubeletSubConfig() kubeletConfig {
CgroupRoot: "/",
ClusterDomain: "cluster.local",
ContainerRuntimeEndpoint: containerd.ContainerRuntimeEndpoint,
EnforceNodeAllocatable: []string{"pods"},
Copy link
Member Author

Choose a reason for hiding this comment

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

This is the default -- just making it explicit here that we aren't enforcing either kube or system reserved.

EvictionHard: map[string]string{
"memory.available": "100Mi",
"nodefs.available": "10%",
Expand Down Expand Up @@ -261,6 +265,12 @@ func (ksc *kubeletConfig) withCloudProvider(kubeletVersion string, cfg *api.Node
// config with reserved cgroup values on behalf of the user
func (ksc *kubeletConfig) withDefaultReservedResources(cfg *api.NodeConfig) {
ksc.SystemReservedCgroup = ptr.String("/system")
ksc.SystemReserved = map[string]string{
"cpu": "",
"memory": "",
"ephemeral-storage": "",
}

ksc.KubeReservedCgroup = ptr.String("/runtime")
maxPods, ok := MaxPodsPerInstanceType[cfg.Status.Instance.Type]
if !ok {
Expand Down
Loading