From cf3bb9b16b14a42174d795b9052490acaa95708e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Berkay=20Tekin=20=C3=96z?= Date: Thu, 9 Jan 2025 11:35:10 +0300 Subject: [PATCH] Add a systemd override to add containerd defaults (#932) --- k8s/lib.sh | 13 +++++++++++++ k8s/systemd/containerd-defaults.conf | 11 +++++++++++ snap/hooks/configure | 2 ++ 3 files changed, 26 insertions(+) create mode 100644 k8s/systemd/containerd-defaults.conf diff --git a/k8s/lib.sh b/k8s/lib.sh index 29aa0d905..8421c1c11 100755 --- a/k8s/lib.sh +++ b/k8s/lib.sh @@ -219,3 +219,16 @@ k8s::util::load_kernel_modules() { modprobe $@ } + +k8s::containerd::ensure_systemd_defaults() { + k8s::common::setup_env + + local override_dir="/etc/systemd/system/snap.k8s.containerd.service.d" + local override_file="$SNAP/k8s/systemd/containerd-defaults.conf" + + if ! [ -f "$override_dir/containerd-defaults.conf" ]; then + mkdir -p "$override_dir" + cp "$override_file" "$override_dir/" + fi + +} diff --git a/k8s/systemd/containerd-defaults.conf b/k8s/systemd/containerd-defaults.conf new file mode 100644 index 000000000..457ec4bb6 --- /dev/null +++ b/k8s/systemd/containerd-defaults.conf @@ -0,0 +1,11 @@ +[Service] +Delegate=yes +# Having non-zero Limit*s causes performance problems due to accounting overhead +# in the kernel. We recommend using cgroups to do container-local accounting. +LimitNPROC=infinity +LimitCORE=infinity +LimitNOFILE=infinity +# Comment TasksMax if your systemd version does not supports it. +# Only systemd 226 and above support this version. +TasksMax=infinity +OOMScoreAdjust=-999 diff --git a/snap/hooks/configure b/snap/hooks/configure index e428bddc6..36ff6e1cc 100755 --- a/snap/hooks/configure +++ b/snap/hooks/configure @@ -5,3 +5,5 @@ k8s::common::setup_env k8s::cmd::k8s x-snapd-config reconcile + +k8s::containerd::ensure_systemd_defaults