Skip to content

Commit

Permalink
Simplify kubelet-config template
Browse files Browse the repository at this point in the history
  • Loading branch information
VannTen committed Nov 24, 2023
1 parent d583d33 commit cd52d42
Showing 1 changed file with 9 additions and 49 deletions.
58 changes: 9 additions & 49 deletions roles/kubernetes/node/templates/kubelet-config.v1beta1.yaml.j2
Original file line number Diff line number Diff line change
Expand Up @@ -60,56 +60,16 @@ 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 }}
memory: {{ kube_master_memory_reserved }}
{% if kube_master_ephemeral_storage_reserved is defined %}
ephemeral-storage: {{ kube_master_ephemeral_storage_reserved }}
{% endif %}
{% if kube_master_pid_reserved is defined %}
pid: "{{ kube_master_pid_reserved }}"
{% endif %}
{% else %}
cpu: {{ kube_cpu_reserved }}
memory: {{ kube_memory_reserved }}
{% if kube_ephemeral_storage_reserved is defined %}
ephemeral-storage: {{ kube_ephemeral_storage_reserved }}
{% endif %}
{% if kube_pid_reserved is defined %}
pid: "{{ kube_pid_reserved }}"
{% endif %}
{% endif %}
{% endif %}
{% if system_reserved | bool %}
systemReservedCgroup: {{ system_reserved_cgroups }}
systemReserved:
{% if is_kube_master | bool %}
cpu: {{ system_master_cpu_reserved }}
memory: {{ system_master_memory_reserved }}
{% if system_master_ephemeral_storage_reserved is defined %}
ephemeral-storage: {{ system_master_ephemeral_storage_reserved }}
{% endif %}
{% if system_master_pid_reserved is defined %}
pid: "{{ system_master_pid_reserved }}"
{% endif %}
{% else %}
cpu: {{ system_cpu_reserved }}
memory: {{ system_memory_reserved }}
{% if system_ephemeral_storage_reserved is defined %}
ephemeral-storage: {{ system_ephemeral_storage_reserved }}
{% endif %}
{% if system_pid_reserved is defined %}
pid: "{{ system_pid_reserved }}"
{% endif %}
{% endif %}
{% for scope in "kube", "system" %}
{% if lookup('ansible.builtin.vars', scope + "_reserved") | bool %}
{{ scope }}ReservedCgroup: {{ lookup('ansible.builtin.vars', scope + '_reserved_cgroup') }}
{{ scope }}Reserved:
{% for resource in "cpu", "memory", "ephemeral-storage", "pid" %}
{{ resource }}: "{{ lookup('ansible.builtin.vars', scope + '_' ~ (resource | replace('-', '_')) + "_reserved", default='') }}"
{% endfor %}
{% endif %}
{% if is_kube_master | bool and eviction_hard_control_plane is defined and eviction_hard_control_plane %}
evictionHard:
{{ eviction_hard_control_plane | to_nice_yaml(indent=2) | indent(2) }}
{% elif not is_kube_master | bool and eviction_hard is defined and eviction_hard %}
{% endfor %}
{% if eviction_hard is defined and eviction_hard %}
evictionHard:
{{ eviction_hard | to_nice_yaml(indent=2) | indent(2) }}
{% endif %}
Expand Down

0 comments on commit cd52d42

Please sign in to comment.