From 54b1fe83f3dea2cd8ed72a98913456945210a03c Mon Sep 17 00:00:00 2001 From: koriukiv <30844277+koriukiv@users.noreply.github.com> Date: Wed, 31 Jul 2019 21:24:15 +0300 Subject: [PATCH] Add an option to reserve resources for OS system daemons (#5007) --- .../sample/group_vars/k8s-cluster/k8s-cluster.yml | 9 +++++++++ .../node/templates/kubelet-config.v1beta1.yaml.j2 | 12 +++++++++++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/inventory/sample/group_vars/k8s-cluster/k8s-cluster.yml b/inventory/sample/group_vars/k8s-cluster/k8s-cluster.yml index 7a49bee19..f0dc90108 100644 --- a/inventory/sample/group_vars/k8s-cluster/k8s-cluster.yml +++ b/inventory/sample/group_vars/k8s-cluster/k8s-cluster.yml @@ -191,6 +191,15 @@ podsecuritypolicy_enabled: false # Acceptable options are 'pods', 'system-reserved', 'kube-reserved' and ''. Default is "". # kubelet_enforce_node_allocatable: pods +## Optionally reserve resources for OS system daemons. +# system_reserved: true +## Uncomment to override default values +# system_memory_reserved: 512M +# system_cpu_reserved: 500m +## Reservation for master hosts +# system_master_memory_reserved: 256M +# system_master_cpu_reserved: 250m + # An alternative flexvolume plugin directory # kubelet_flexvolumes_plugins_dir: /usr/libexec/kubernetes/kubelet-plugins/volume/exec diff --git a/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2 b/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2 index 2beef8bf1..78ca34796 100644 --- a/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2 +++ b/roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2 @@ -54,4 +54,14 @@ kubeReserved: cpu: {{ kube_cpu_reserved }} memory: {{ kube_memory_reserved|regex_replace('Mi', 'M') }} {% endif %} -resolvConf: "{{ kube_resolv_conf }}" \ No newline at end of file +{% if system_reserved is defined and system_reserved %} +systemReserved: +{% if is_kube_master|bool %} + cpu: {{ system_master_cpu_reserved|default('250m') }} + memory: {{ system_master_memory_reserved|default('256M')|regex_replace('Mi', 'M') }} +{% else %} + cpu: {{ system_cpu_reserved|default('500m') }} + memory: {{ system_memory_reserved|default('512M')|regex_replace('Mi', 'M') }} +{% endif %} +{% endif %} +resolvConf: "{{ kube_resolv_conf }}"