mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-22 03:11:40 +00:00
Merge pull request #111231 from bobbypage/cgroup-driver
cluster: use systemd cgroup driver for cgroupv2
This commit is contained in:
commit
a8da99cf11
@ -1621,7 +1621,13 @@ function start-kubelet {
|
|||||||
echo "Using kubelet binary at ${kubelet_bin}"
|
echo "Using kubelet binary at ${kubelet_bin}"
|
||||||
|
|
||||||
local -r kubelet_env_file="/etc/default/kubelet"
|
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 "KUBELET_OPTS=\"${kubelet_opts}\"" > "${kubelet_env_file}"
|
||||||
echo "KUBE_COVERAGE_FILE=\"/var/log/kubelet.cov\"" >> "${kubelet_env_file}"
|
echo "KUBE_COVERAGE_FILE=\"/var/log/kubelet.cov\"" >> "${kubelet_env_file}"
|
||||||
|
|
||||||
@ -2967,6 +2973,11 @@ function override-kubectl {
|
|||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function detect-cgroup-config {
|
||||||
|
CGROUP_CONFIG=$(stat -fc %T /sys/fs/cgroup/)
|
||||||
|
echo "Detected cgroup config as ${CGROUP_CONFIG}"
|
||||||
|
}
|
||||||
|
|
||||||
function override-pv-recycler {
|
function override-pv-recycler {
|
||||||
if [[ -z "${PV_RECYCLER_OVERRIDE_TEMPLATE:-}" ]]; then
|
if [[ -z "${PV_RECYCLER_OVERRIDE_TEMPLATE:-}" ]]; then
|
||||||
echo "PV_RECYCLER_OVERRIDE_TEMPLATE is not set"
|
echo "PV_RECYCLER_OVERRIDE_TEMPLATE is not set"
|
||||||
@ -3060,6 +3071,13 @@ EOF
|
|||||||
cni_template_path=""
|
cni_template_path=""
|
||||||
fi
|
fi
|
||||||
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
|
cat > "${config_path}" <<EOF
|
||||||
version = 2
|
version = 2
|
||||||
# Kubernetes requires the cri plugin.
|
# Kubernetes requires the cri plugin.
|
||||||
@ -3089,6 +3107,8 @@ oom_score = -999
|
|||||||
# See: https://github.com/kubernetes/k8s.io/issues/3411
|
# See: https://github.com/kubernetes/k8s.io/issues/3411
|
||||||
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."k8s.gcr.io"]
|
[plugins."io.containerd.grpc.v1.cri".registry.mirrors."k8s.gcr.io"]
|
||||||
endpoint = ["https://registry.k8s.io", "https://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
|
EOF
|
||||||
|
|
||||||
if [[ "${CONTAINER_RUNTIME_TEST_HANDLER:-}" == "true" ]]; then
|
if [[ "${CONTAINER_RUNTIME_TEST_HANDLER:-}" == "true" ]]; then
|
||||||
@ -3398,6 +3418,7 @@ function main() {
|
|||||||
fi
|
fi
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
log-wrap 'DetectCgroupConfig' detect-cgroup-config
|
||||||
log-wrap 'OverrideKubectl' override-kubectl
|
log-wrap 'OverrideKubectl' override-kubectl
|
||||||
if docker-installed; then
|
if docker-installed; then
|
||||||
# We still need to configure docker so it wouldn't reserver the 172.17.0/16 subnet
|
# We still need to configure docker so it wouldn't reserver the 172.17.0/16 subnet
|
||||||
|
Loading…
Reference in New Issue
Block a user