Merge pull request #111231 from bobbypage/cgroup-driver

cluster: use systemd cgroup driver for cgroupv2
This commit is contained in:
Kubernetes Prow Robot 2022-07-21 07:19:54 -07:00 committed by GitHub
commit a8da99cf11
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1621,7 +1621,13 @@ function start-kubelet {
echo "Using kubelet binary at ${kubelet_bin}"
local -r kubelet_env_file="/etc/default/kubelet"
local kubelet_opts="${KUBELET_ARGS} ${KUBELET_CONFIG_FILE_ARG:-}"
local kubelet_cgroup_driver=""
if [[ "${CGROUP_CONFIG-}" == "cgroup2fs" ]]; then
kubelet_cgroup_driver="--cgroup-driver=systemd"
fi
local kubelet_opts="${KUBELET_ARGS} ${KUBELET_CONFIG_FILE_ARG:-} ${kubelet_cgroup_driver:-}"
echo "KUBELET_OPTS=\"${kubelet_opts}\"" > "${kubelet_env_file}"
echo "KUBE_COVERAGE_FILE=\"/var/log/kubelet.cov\"" >> "${kubelet_env_file}"
@ -2967,6 +2973,11 @@ function override-kubectl {
fi
}
function detect-cgroup-config {
CGROUP_CONFIG=$(stat -fc %T /sys/fs/cgroup/)
echo "Detected cgroup config as ${CGROUP_CONFIG}"
}
function override-pv-recycler {
if [[ -z "${PV_RECYCLER_OVERRIDE_TEMPLATE:-}" ]]; then
echo "PV_RECYCLER_OVERRIDE_TEMPLATE is not set"
@ -3060,6 +3071,13 @@ EOF
cni_template_path=""
fi
fi
# Use systemd cgroup driver when running on cgroupv2
local systemdCgroup="false"
if [[ "${CGROUP_CONFIG-}" == "cgroup2fs" ]]; then
systemdCgroup="true"
fi
cat > "${config_path}" <<EOF
version = 2
# Kubernetes requires the cri plugin.
@ -3089,6 +3107,8 @@ oom_score = -999
# See: https://github.com/kubernetes/k8s.io/issues/3411
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."k8s.gcr.io"]
endpoint = ["https://registry.k8s.io", "https://k8s.gcr.io",]
[plugins."io.containerd.grpc.v1.cri".containerd.runtimes.runc.options]
SystemdCgroup = ${systemdCgroup}
EOF
if [[ "${CONTAINER_RUNTIME_TEST_HANDLER:-}" == "true" ]]; then
@ -3398,6 +3418,7 @@ function main() {
fi
fi
log-wrap 'DetectCgroupConfig' detect-cgroup-config
log-wrap 'OverrideKubectl' override-kubectl
if docker-installed; then
# We still need to configure docker so it wouldn't reserver the 172.17.0/16 subnet