Skip to content

Commit

Permalink
WIP Remove hard-coded cgroup settings
Browse files Browse the repository at this point in the history
Leave cgroupsPerQOS defaulted to true.

Signed-off-by: Tom Wieczorek <[email protected]>
  • Loading branch information
twz123 committed Nov 19, 2024
1 parent 410e884 commit c6b628e
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
1 change: 0 additions & 1 deletion pkg/component/controller/workerconfig/reconciler.go
Original file line number Diff line number Diff line change
Expand Up @@ -508,7 +508,6 @@ func (r *Reconciler) buildConfigMaps(snapshot *snapshot) ([]*corev1.ConfigMap, e
workerProfiles["default"] = workerProfile

workerProfile = r.buildProfile(snapshot)
workerProfile.KubeletConfiguration.CgroupsPerQOS = ptr.To(false)
workerProfiles["default-windows"] = workerProfile

for _, profile := range snapshot.profiles {
Expand Down
1 change: 0 additions & 1 deletion pkg/component/controller/workerconfig/reconciler_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,6 @@ func TestReconciler_ResourceGeneration(t *testing.T) {
},

"worker-config-default-windows-1.31": func(expected *kubeletConfig) {
expected.CgroupsPerQOS = ptr.To(false)
expected.FeatureGates = map[string]bool{"kubelet-feature": true}
},

Expand Down
22 changes: 8 additions & 14 deletions pkg/component/worker/kubelet.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import (
corev1 "k8s.io/api/core/v1"
"k8s.io/apimachinery/pkg/util/validation"
kubeletv1beta1 "k8s.io/kubelet/config/v1beta1"
"k8s.io/utils/ptr"

"github.com/sirupsen/logrus"
"sigs.k8s.io/yaml"
Expand Down Expand Up @@ -121,13 +120,15 @@ func (k *Kubelet) Start(ctx context.Context) error {
logrus.Info("Starting kubelet")
kubeletConfigPath := filepath.Join(k.K0sVars.DataDir, "kubelet-config.yaml")

// Maybe auto-detect? Should be k0s's cgroup if launching the embedded containerd.
// "--runtime-cgroups": "/system.slice/containerd.service",

args := stringmap.StringMap{
"--root-dir": k.dataDir,
"--config": kubeletConfigPath,
"--kubeconfig": k.Kubeconfig,
"--v": k.LogLevel,
"--runtime-cgroups": "/system.slice/containerd.service",
"--cert-dir": filepath.Join(k.dataDir, "pki"),
"--root-dir": k.dataDir,
"--config": kubeletConfigPath,
"--kubeconfig": k.Kubeconfig,
"--v": k.LogLevel,
"--cert-dir": filepath.Join(k.dataDir, "pki"),
}

if len(k.Labels) > 0 {
Expand Down Expand Up @@ -232,13 +233,6 @@ func (k *Kubelet) writeKubeletConfig(path string) error {
config.RegisterWithTaints = taints
}

// cgroup related things (Linux only)
if runtime.GOOS == "linux" {
config.KubeReservedCgroup = "system.slice"
config.KubeletCgroups = "/system.slice/containerd.service"
config.CgroupsPerQOS = ptr.To(true)
}

configBytes, err := yaml.Marshal(config)
if err != nil {
return fmt.Errorf("can't marshal kubelet config: %w", err)
Expand Down

0 comments on commit c6b628e

Please sign in to comment.