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

fix: Configure containerd runc plugin options with systemd cgroup driver #493

Merged
merged 8 commits into from
Oct 6, 2022

Conversation

dlipovetsky
Copy link
Collaborator

What problem does this PR solve?:
konvoy-image-builder installs kubelet as a systemd service, and kubelet therefore uses the systemd cgroup driver.

The container runtime must use the same cgroup driver.

Note: In v1.22, if the user is not setting the cgroupDriver field
under KubeletConfiguration, kubeadm will default it to systemd.
-- https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/configure-cgroup-driver/

Which issue(s) does this PR fix?:

Special notes for your reviewer:

Does this PR introduce a user-facing change?:


konvoy-image-builder installs kubelet as a systemd service, and
kubelet therefore uses the systemd cgroup driver.

The container runtime must use the same cgroup driver.

> Note: In v1.22, if the user is not setting the cgroupDriver field
> under KubeletConfiguration, kubeadm will default it to systemd.
> -- https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/configure-cgroup-driver/
@github-actions github-actions bot added the fix label Sep 9, 2022
@github-actions
Copy link
Contributor

github-actions bot commented Sep 9, 2022

File Coverage
All files 14%
pkg/ansible/runner.go 0%
pkg/app/artifacts.go 0%
pkg/app/build.go 0%
pkg/app/build_azure.go 2%
pkg/app/build_gcp.go 0%
pkg/app/config.go 48%
pkg/app/errors.go 0%
pkg/app/provision.go 0%
pkg/app/root.go 0%
pkg/app/utils.go 7%
pkg/app/validate.go 0%
pkg/appansible/io.go 0%
pkg/appansible/playbook.go 0%
pkg/azure/azure.go 0%
pkg/logging/logger.go 0%
pkg/packer/manifest.go 0%
pkg/packer/packer.go 0%
pkg/stringutil/rand.go 0%
pkg/version/info.go 8%

Minimum allowed coverage is 75%

Generated by 🐒 cobertura-action against c890621

@@ -96,6 +95,8 @@ imports = ["/etc/containerd/conf.d/*.toml"]
runtime_engine = ""
runtime_root = ""
privileged_without_host_devices = false
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
systemd_cgroup = true
Copy link
Contributor

Choose a reason for hiding this comment

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

Is this value dependent on the Kubernetes version?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yes, but as of v1.21, kubeadm init configures kubelet to use the systemd cgroup driver, and as of v1.22, all kubeadm commands configure kubelet to use it.

Please see kubernetes/kubeadm#2376 (comment)

@dlipovetsky
Copy link
Collaborator Author

@faiq raised a good question about where in the containerd configuration this PR sets the cgroup driver.

The "global" setting has been deprecated for a while: https://github.com/containerd/containerd/blob/f4095a6876c62dd4cd5e3749d2435b2daa9eaff8/pkg/cri/config/config.go#L259-L262

So the right place to set it appears to be in the CRI runtime plugin

@dlipovetsky
Copy link
Collaborator Author

Looks like setting the configuration here only works for runtime type io.containerd.runc.v2. We use io.containerd.runc.v1, which means we need to change the configuration at the original, global location.

The 'io.containerd.runc.v1' runtime type was deprecated in containerd
1.4, and does not support the systemd cgroup driver.
The option should work, because the nvidia runtime is just a repackaged
runc runtime.
dlipovetsky and others added 4 commits September 13, 2022 10:26
Using snake case has no effect. Confirmed independently by both @faiq
and @dlipovetsky.
Only "io.containerd.runc.v2" supports the SystemdCgroup option we need.

I have seen multiple examples of this configuration in the wild, and
since nvidia-container-runtime is a wrapper around runc, there should
be no issues with using v2 of the containerd wrapper to runc.
@faiq faiq changed the title fix: Configure containerd runc plugin to use systemd cgroup driver fix: Configure containerd runc plugin options to use systemd cgroup driver Sep 14, 2022
@github-actions github-actions bot added fix and removed fix labels Sep 14, 2022
@faiq
Copy link
Collaborator

faiq commented Sep 15, 2022

There's some flatcar specific changes I'd like to take a look at before merging as well

@faiq faiq changed the title fix: Configure containerd runc plugin options to use systemd cgroup driver fix: Configure containerd runc plugin options with systemd cgroup driver Sep 15, 2022
@github-actions github-actions bot added fix and removed fix labels Sep 15, 2022
Copy link
Collaborator

@faiq faiq left a comment

Choose a reason for hiding this comment

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

No customer is using flatcar with dkp 2.2, which introduced disabling cgroups v2. So we can safely ignore the case where a flatcar configured with cgroupsv1 needs to be upgraded to dkp 2.4

@faiq faiq merged commit 1704c72 into main Oct 6, 2022
@faiq faiq deleted the dlipovetsky/systemd-cgroup-default branch October 6, 2022 15:32
@faiq faiq self-assigned this Oct 6, 2022
faiq added a commit that referenced this pull request Nov 17, 2022
…ver (#493)

* fix: Configure containerd runc plugin to use systemd cgroup driver

konvoy-image-builder installs kubelet as a systemd service, and
kubelet therefore uses the systemd cgroup driver.

The container runtime must use the same cgroup driver.

> Note: In v1.22, if the user is not setting the cgroupDriver field
> under KubeletConfiguration, kubeadm will default it to systemd.
> -- https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/configure-cgroup-driver/

* Use runtime type 'io.containerd.runc.v2'

The 'io.containerd.runc.v1' runtime type was deprecated in containerd
1.4, and does not support the systemd cgroup driver.

* Use systemd cgroup driver with the nvidia runtime

The option should work, because the nvidia runtime is just a repackaged
runc runtime.

* Use SystemdCgroup instead of systemd_cgroup

Using snake case has no effect. Confirmed independently by both @faiq
and @dlipovetsky.

* Use "io.containerd.runc.v2" for nvidia container runtime

Only "io.containerd.runc.v2" supports the SystemdCgroup option we need.

I have seen multiple examples of this configuration in the wild, and
since nvidia-container-runtime is a wrapper around runc, there should
be no issues with using v2 of the containerd wrapper to runc.

* fix: from poor merge

* fix: allows cgroups v2 by default for flatcar

Co-authored-by: Faiq <faiq@users.noreply.github.com>
Co-authored-by: faiq <faiqrazarizvi@gmail.com>
faiq added a commit that referenced this pull request Nov 17, 2022
…ver (#493)

Co-authored-by: Faiq <faiq@users.noreply.github.com>
Co-authored-by: faiq <faiqrazarizvi@gmail.com>
faiq added a commit that referenced this pull request Nov 17, 2022
…ver (#493) (#584)

* fix: Configure containerd runc plugin to use systemd cgroup driver

konvoy-image-builder installs kubelet as a systemd service, and
kubelet therefore uses the systemd cgroup driver.

The container runtime must use the same cgroup driver.

> Note: In v1.22, if the user is not setting the cgroupDriver field
> under KubeletConfiguration, kubeadm will default it to systemd.
> -- https://kubernetes.io/docs/tasks/administer-cluster/kubeadm/configure-cgroup-driver/

* Use runtime type 'io.containerd.runc.v2'

The 'io.containerd.runc.v1' runtime type was deprecated in containerd
1.4, and does not support the systemd cgroup driver.

* Use systemd cgroup driver with the nvidia runtime

The option should work, because the nvidia runtime is just a repackaged
runc runtime.

* Use SystemdCgroup instead of systemd_cgroup

Using snake case has no effect. Confirmed independently by both @faiq
and @dlipovetsky.

* Use "io.containerd.runc.v2" for nvidia container runtime

Only "io.containerd.runc.v2" supports the SystemdCgroup option we need.

I have seen multiple examples of this configuration in the wild, and
since nvidia-container-runtime is a wrapper around runc, there should
be no issues with using v2 of the containerd wrapper to runc.

* fix: from poor merge

* fix: allows cgroups v2 by default for flatcar

Co-authored-by: Faiq <faiq@users.noreply.github.com>
Co-authored-by: faiq <faiqrazarizvi@gmail.com>

Co-authored-by: Daniel Lipovetsky <3445370+dlipovetsky@users.noreply.github.com>
faiq added a commit that referenced this pull request Nov 17, 2022
…ver (#493) (#585)

Co-authored-by: Faiq <faiq@users.noreply.github.com>
Co-authored-by: faiq <faiqrazarizvi@gmail.com>

Co-authored-by: Daniel Lipovetsky <3445370+dlipovetsky@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants