@@ -133,23 +133,20 @@ func fixNodeRegistration(nodeRegistration *bootstrapv1.NodeRegistrationOptions,
133
133
nodeRegistration .KubeletExtraArgs = map [string ]string {}
134
134
}
135
135
136
- if _ , ok := nodeRegistration .KubeletExtraArgs ["eviction-hard" ]; ! ok {
137
- nodeRegistration .KubeletExtraArgs ["eviction-hard" ] = "nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%"
138
- }
139
- if _ , ok := nodeRegistration .KubeletExtraArgs ["fail-swap-on" ]; ! ok {
140
- nodeRegistration .KubeletExtraArgs ["fail-swap-on" ] = "false"
141
- }
136
+ // Disable disk resource management by default.
137
+ // The kubelet will see the host disk that the inner container runtime
138
+ // is ultimately backed by and attempt to recover disk space. We don't want that.
139
+ // See https://github.com/kubernetes-sigs/cluster-api/issues/11856 for more details.
140
+ defaultExtraArg (nodeRegistration , "image-gc-high-threshold" , "100" )
141
+ defaultExtraArg (nodeRegistration , "eviction-hard" , "nodefs.available<0%,nodefs.inodesFree<0%,imagefs.available<0%" )
142
+
143
+ defaultExtraArg (nodeRegistration , "fail-swap-on" , "false" )
142
144
143
145
if kindMapping .Mode != kind .Mode0_19 {
144
146
// kindest/node images generated by modo 0.20 and greater require to use CgroupnsMode = "private" when running images;
145
147
// following settings are complementary to this change.
146
-
147
- if _ , ok := nodeRegistration .KubeletExtraArgs ["cgroup-root" ]; ! ok {
148
- nodeRegistration .KubeletExtraArgs ["cgroup-root" ] = "/kubelet"
149
- }
150
- if _ , ok := nodeRegistration .KubeletExtraArgs ["runtime-cgroups" ]; ! ok {
151
- nodeRegistration .KubeletExtraArgs ["runtime-cgroups" ] = "/system.slice/containerd.service"
152
- }
148
+ defaultExtraArg (nodeRegistration , "cgroup-root" , "/kubelet" )
149
+ defaultExtraArg (nodeRegistration , "runtime-cgroups" , "/system.slice/containerd.service" )
153
150
}
154
151
155
152
if version .Compare (kindMapping .KubernetesVersion , cgroupDriverPatchVersionCeiling ) == - 1 {
@@ -159,6 +156,13 @@ func fixNodeRegistration(nodeRegistration *bootstrapv1.NodeRegistrationOptions,
159
156
}
160
157
}
161
158
159
+ // defautExtraArg sets a default value for an extra arg if it is not already set.
160
+ func defaultExtraArg (nodeRegistration * bootstrapv1.NodeRegistrationOptions , arg , value string ) {
161
+ if _ , ok := nodeRegistration .KubeletExtraArgs [arg ]; ! ok {
162
+ nodeRegistration .KubeletExtraArgs [arg ] = value
163
+ }
164
+ }
165
+
162
166
// Commands return a list of commands to run on the node.
163
167
// Each command defines the parameters of a shell command necessary to generate a file replicating the cloud-init write_files module.
164
168
func (a * writeFilesAction ) Commands () ([]provisioning.Cmd , error ) {
0 commit comments