optimize cgroups settings for node reserved
This commit is contained in:
parent
de762400ad
commit
dec11c7338
4 changed files with 34 additions and 3 deletions
|
@ -35,6 +35,9 @@ LimitNOFILE=infinity
|
|||
# Only systemd 226 and above support this version.
|
||||
TasksMax=infinity
|
||||
OOMScoreAdjust=-999
|
||||
{% if kube_reserved|bool %}
|
||||
Slice={{ kube_reserved_cgroups_for_service_slice }}
|
||||
{% endif %}
|
||||
|
||||
[Install]
|
||||
WantedBy=multi-user.target
|
||||
|
|
|
@ -12,8 +12,8 @@ kube_resolv_conf: "/etc/resolv.conf"
|
|||
kubelet_enforce_node_allocatable: "\"\""
|
||||
|
||||
# Set runtime and kubelet cgroups when using systemd as cgroup driver (default)
|
||||
kubelet_runtime_cgroups: "/systemd/system.slice"
|
||||
kubelet_kubelet_cgroups: "/systemd/system.slice"
|
||||
kubelet_runtime_cgroups: "{{ kube_reserved_cgroups }}/containerd.service"
|
||||
kubelet_kubelet_cgroups: "{{ kube_reserved_cgroups }}/kubelet.service"
|
||||
|
||||
# Set runtime and kubelet cgroups when using cgroupfs as cgroup driver
|
||||
kubelet_runtime_cgroups_cgroupfs: "/system.slice/containerd.service"
|
||||
|
@ -23,6 +23,10 @@ kubelet_kubelet_cgroups_cgroupfs: "/system.slice/kubelet.service"
|
|||
kubelet_fail_swap_on: true
|
||||
|
||||
# Reserve this space for kube resources
|
||||
# Set to true to reserve resources for kube daemons
|
||||
kube_reserved: false
|
||||
kube_reserved_cgroups_for_service_slice: kube.slice
|
||||
kube_reserved_cgroups: "/{{ kube_reserved_cgroups_for_service_slice }}"
|
||||
kube_memory_reserved: 256Mi
|
||||
kube_cpu_reserved: 100m
|
||||
# kube_ephemeral_storage_reserved: 2Gi
|
||||
|
@ -35,6 +39,8 @@ kube_master_cpu_reserved: 200m
|
|||
|
||||
# Set to true to reserve resources for system daemons
|
||||
system_reserved: false
|
||||
system_reserved_cgroups_for_service_slice: system.slice
|
||||
system_reserved_cgroups: "/{{ system_reserved_cgroups_for_service_slice }}"
|
||||
system_memory_reserved: 512Mi
|
||||
system_cpu_reserved: 500m
|
||||
# system_ephemeral_storage_reserved: 2Gi
|
||||
|
|
|
@ -60,6 +60,8 @@ clusterDNS:
|
|||
- {{ dns_address }}
|
||||
{% endfor %}
|
||||
{# Node reserved CPU/memory #}
|
||||
{% if kube_reserved|bool %}
|
||||
kubeReservedCgroup: {{ kube_reserved_cgroups }}
|
||||
kubeReserved:
|
||||
{% if is_kube_master|bool %}
|
||||
cpu: {{ kube_master_cpu_reserved }}
|
||||
|
@ -80,7 +82,9 @@ kubeReserved:
|
|||
pid: "{{ kube_pid_reserved }}"
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
{% if system_reserved is defined and system_reserved %}
|
||||
{% endif %}
|
||||
{% if system_reserved|bool %}
|
||||
systemReservedCgroup: {{ system_reserved_cgroups }}
|
||||
systemReserved:
|
||||
{% if is_kube_master|bool %}
|
||||
cpu: {{ system_master_cpu_reserved }}
|
||||
|
|
|
@ -10,6 +10,24 @@ Wants={{ container_manager }}.service
|
|||
|
||||
[Service]
|
||||
EnvironmentFile=-{{ kube_config_dir }}/kubelet.env
|
||||
{% if system_reserved|bool %}
|
||||
ExecStartPre=/bin/mkdir -p /sys/fs/cgroup/cpu/{{ system_reserved_cgroups_for_service_slice }}
|
||||
ExecStartPre=/bin/mkdir -p /sys/fs/cgroup/cpuacct/{{ system_reserved_cgroups_for_service_slice }}
|
||||
ExecStartPre=/bin/mkdir -p /sys/fs/cgroup/cpuset/{{ system_reserved_cgroups_for_service_slice }}
|
||||
ExecStartPre=/bin/mkdir -p /sys/fs/cgroup/hugetlb/{{ system_reserved_cgroups_for_service_slice }}
|
||||
ExecStartPre=/bin/mkdir -p /sys/fs/cgroup/memory/{{ system_reserved_cgroups_for_service_slice }}
|
||||
ExecStartPre=/bin/mkdir -p /sys/fs/cgroup/pids/{{ system_reserved_cgroups_for_service_slice }}
|
||||
ExecStartPre=/bin/mkdir -p /sys/fs/cgroup/systemd/{{ system_reserved_cgroups_for_service_slice }}
|
||||
{% endif %}
|
||||
{% if kube_reserved|bool %}
|
||||
ExecStartPre=/bin/mkdir -p /sys/fs/cgroup/cpu/{{ kube_reserved_cgroups_for_service_slice }}
|
||||
ExecStartPre=/bin/mkdir -p /sys/fs/cgroup/cpuacct/{{ kube_reserved_cgroups_for_service_slice }}
|
||||
ExecStartPre=/bin/mkdir -p /sys/fs/cgroup/cpuset/{{ kube_reserved_cgroups_for_service_slice }}
|
||||
ExecStartPre=/bin/mkdir -p /sys/fs/cgroup/hugetlb/{{ kube_reserved_cgroups_for_service_slice }}
|
||||
ExecStartPre=/bin/mkdir -p /sys/fs/cgroup/memory/{{ kube_reserved_cgroups_for_service_slice }}
|
||||
ExecStartPre=/bin/mkdir -p /sys/fs/cgroup/pids/{{ kube_reserved_cgroups_for_service_slice }}
|
||||
ExecStartPre=/bin/mkdir -p /sys/fs/cgroup/systemd/{{ kube_reserved_cgroups_for_service_slice }}
|
||||
{% endif %}
|
||||
ExecStart={{ bin_dir }}/kubelet \
|
||||
$KUBE_LOGTOSTDERR \
|
||||
$KUBE_LOG_LEVEL \
|
||||
|
|
Loading…
Reference in a new issue