From d8e09052543e0d26a312485f05e10c42618d0659 Mon Sep 17 00:00:00 2001 From: shelmingsong Date: Wed, 24 Aug 2022 20:13:00 +0800 Subject: [PATCH] set cgroup slice for multi container engine --- .../containerd/templates/containerd.service.j2 | 1 + .../cri-dockerd/templates/cri-dockerd.service.j2 | 4 ++++ roles/container-engine/docker/templates/docker.service.j2 | 4 ++++ 3 files changed, 9 insertions(+) diff --git a/roles/container-engine/containerd/templates/containerd.service.j2 b/roles/container-engine/containerd/templates/containerd.service.j2 index bc0121bfa..7527d5ac3 100644 --- a/roles/container-engine/containerd/templates/containerd.service.j2 +++ b/roles/container-engine/containerd/templates/containerd.service.j2 @@ -35,6 +35,7 @@ LimitNOFILE=infinity # Only systemd 226 and above support this version. TasksMax=infinity OOMScoreAdjust=-999 +# Set the cgroup slice of the service so that kube reserved takes effect {% if kube_reserved is defined and kube_reserved|bool %} Slice={{ kube_reserved_cgroups_for_service_slice }} {% endif %} diff --git a/roles/container-engine/cri-dockerd/templates/cri-dockerd.service.j2 b/roles/container-engine/cri-dockerd/templates/cri-dockerd.service.j2 index 078f66651..ec128150f 100644 --- a/roles/container-engine/cri-dockerd/templates/cri-dockerd.service.j2 +++ b/roles/container-engine/cri-dockerd/templates/cri-dockerd.service.j2 @@ -35,6 +35,10 @@ LimitCORE=infinity TasksMax=infinity Delegate=yes KillMode=process +# Set the cgroup slice of the service so that kube reserved takes effect +{% if kube_reserved is defined and kube_reserved|bool %} +Slice={{ kube_reserved_cgroups_for_service_slice }} +{% endif %} [Install] WantedBy=multi-user.target diff --git a/roles/container-engine/docker/templates/docker.service.j2 b/roles/container-engine/docker/templates/docker.service.j2 index fd1d06121..539c3a5c4 100644 --- a/roles/container-engine/docker/templates/docker.service.j2 +++ b/roles/container-engine/docker/templates/docker.service.j2 @@ -42,6 +42,10 @@ TimeoutStartSec=1min Restart=on-failure StartLimitBurst=3 StartLimitInterval=60s +# Set the cgroup slice of the service so that kube reserved takes effect +{% if kube_reserved is defined and kube_reserved|bool %} +Slice={{ kube_reserved_cgroups_for_service_slice }} +{% endif %} [Install] WantedBy=multi-user.target