Replace swap vars with single `kubelet_fail_swap_on` (#10036)

pull/10061/head
Manuelraa 2023-05-11 19:53:04 +02:00 committed by GitHub
parent 951face343
commit 2b75552d1c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 9 additions and 13 deletions

View File

@ -20,9 +20,6 @@ kubelet_kubelet_cgroups: "/{{ kube_service_cgroups }}/kubelet.service"
kubelet_runtime_cgroups_cgroupfs: "/system.slice/{{ container_manager }}.service" kubelet_runtime_cgroups_cgroupfs: "/system.slice/{{ container_manager }}.service"
kubelet_kubelet_cgroups_cgroupfs: "/system.slice/kubelet.service" kubelet_kubelet_cgroups_cgroupfs: "/system.slice/kubelet.service"
### fail with swap on (default true)
kubelet_fail_swap_on: true
# Set systemd service hardening features # Set systemd service hardening features
kubelet_systemd_hardening: false kubelet_systemd_hardening: false

View File

@ -1,7 +1,7 @@
apiVersion: kubelet.config.k8s.io/v1beta1 apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration kind: KubeletConfiguration
nodeStatusUpdateFrequency: "{{ kubelet_status_update_frequency }}" nodeStatusUpdateFrequency: "{{ kubelet_status_update_frequency }}"
failSwapOn: {{ kubelet_fail_swap_on|default(true) }} failSwapOn: {{ kubelet_fail_swap_on }}
authentication: authentication:
anonymous: anonymous:
enabled: false enabled: false
@ -140,9 +140,9 @@ eventRecordQPS: {{ kubelet_event_record_qps }}
{% endif %} {% endif %}
shutdownGracePeriod: {{ kubelet_shutdown_grace_period }} shutdownGracePeriod: {{ kubelet_shutdown_grace_period }}
shutdownGracePeriodCriticalPods: {{ kubelet_shutdown_grace_period_critical_pods }} shutdownGracePeriodCriticalPods: {{ kubelet_shutdown_grace_period_critical_pods }}
{% if not kubelet_fail_swap_on|default(true) %} {% if not kubelet_fail_swap_on %}
memorySwap: memorySwap:
swapBehavior: {{ kubelet_swap_behavior|default("LimitedSwap") }} swapBehavior: {{ kubelet_swap_behavior }}
{% endif %} {% endif %}
{% if kubelet_streaming_connection_idle_timeout is defined %} {% if kubelet_streaming_connection_idle_timeout is defined %}
streamingConnectionIdleTimeout: {{ kubelet_streaming_connection_idle_timeout }} streamingConnectionIdleTimeout: {{ kubelet_streaming_connection_idle_timeout }}

View File

@ -4,7 +4,7 @@
name: "{{ item }}" name: "{{ item }}"
fstype: swap fstype: swap
state: absent state: absent
with_items: loop:
- swap - swap
- none - none
@ -18,7 +18,6 @@
command: /sbin/swapoff -a command: /sbin/swapoff -a
when: when:
- swapon.stdout - swapon.stdout
- kubelet_fail_swap_on | default(True)
ignore_errors: "{{ ansible_check_mode }}" # noqa ignore-errors ignore_errors: "{{ ansible_check_mode }}" # noqa ignore-errors
- name: Disable swapOnZram for Fedora - name: Disable swapOnZram for Fedora
@ -26,4 +25,3 @@
when: when:
- swapon.stdout - swapon.stdout
- ansible_distribution in ['Fedora'] - ansible_distribution in ['Fedora']
- kubelet_fail_swap_on | default(True)

View File

@ -3,7 +3,7 @@
- import_tasks: 0010-swapoff.yml - import_tasks: 0010-swapoff.yml
when: when:
- not dns_late - not dns_late
- disable_swap - kubelet_fail_swap_on
- import_tasks: 0020-set_facts.yml - import_tasks: 0020-set_facts.yml
tags: tags:

View File

@ -11,8 +11,9 @@ kube_api_anonymous_auth: true
# Default value, but will be set to true automatically if detected # Default value, but will be set to true automatically if detected
is_fedora_coreos: false is_fedora_coreos: false
# optional disable the swap # Swap settings
disable_swap: true kubelet_fail_swap_on: true
kubelet_swap_behavior: LimitedSwap
## Change this to use another Kubernetes version, e.g. a current beta release ## Change this to use another Kubernetes version, e.g. a current beta release
kube_version: v1.26.3 kube_version: v1.26.3

View File

@ -14,6 +14,6 @@ kube_proxy_mode: iptables
preinstall_selinux_state: enforcing preinstall_selinux_state: enforcing
# Test Alpha swap feature by leveraging zswap default config in Fedora 35 # Test Alpha swap feature by leveraging zswap default config in Fedora 35
kubelet_fail_swap_on: False kubelet_fail_swap_on: false
kube_feature_gates: kube_feature_gates:
- "NodeSwap=True" - "NodeSwap=True"