diff --git a/README.md b/README.md index 520146e..0df9ff9 100644 --- a/README.md +++ b/README.md @@ -325,6 +325,15 @@ rke2_wait_for_all_pods_to_be_ready: false # Enable debug mode (rke2-service) rke2_debug: false +# (Optional) Customize kubelet config using KubeletConfiguration - https://kubernetes.io/docs/reference/config-api/kubelet-config.v1beta1/ +# rke2_kubelet_config: +# imageGCHighThresholdPercent: 80 +# imageGCLowThresholdPercent: 70 +# Note that you also need to add the following to kubelet args: +# rke2_kubelet_arg: +# - "--config=/etc/rancher/rke2/kubelet-config.yaml" +rke2_kubelet_config: {} + # (Optional) Customize default kubelet arguments # rke2_kubelet_arg: # - "--system-reserved=cpu=100m,memory=100Mi" @@ -346,6 +355,7 @@ rke2_service_cidr: # Enable SELinux for rke2 rke2_selinux: false + ``` ## Inventory file example diff --git a/defaults/main.yml b/defaults/main.yml index 9b5272e..637c24d 100644 --- a/defaults/main.yml +++ b/defaults/main.yml @@ -287,6 +287,15 @@ rke2_wait_for_all_pods_to_be_ready: false # Enable debug mode (rke2-service) rke2_debug: false +# (Optional) Customize kubelet config using KubeletConfiguration - https://kubernetes.io/docs/reference/config-api/kubelet-config.v1beta1/ +# rke2_kubelet_config: +# imageGCHighThresholdPercent: 80 +# imageGCLowThresholdPercent: 70 +# Note that you also need to add the following to kubelet args: +# rke2_kubelet_arg: +# - "--config=/etc/rancher/rke2/kubelet-config.yaml" +rke2_kubelet_config: {} + # (Optional) Customize default kubelet arguments # rke2_kubelet_arg: # - "--system-reserved=cpu=100m,memory=100Mi" diff --git a/tasks/first_server.yml b/tasks/first_server.yml index 913e505..d65efad 100644 --- a/tasks/first_server.yml +++ b/tasks/first_server.yml @@ -21,6 +21,16 @@ mode: 0600 notify: "Config file changed" +- name: Copy kubelet config + ansible.builtin.template: + src: templates/kubelet-config.yaml.j2 + dest: /etc/rancher/rke2/kubelet-config.yaml + owner: root + group: root + mode: 0600 + when: rke2_kubelet_config | length > 0 + notify: "Config file changed" + - name: Copy Containerd Registry Configuration file ansible.builtin.template: src: "{{ rke2_custom_registry_path }}" diff --git a/tasks/main.yml b/tasks/main.yml index b0a2b22..5c42807 100644 --- a/tasks/main.yml +++ b/tasks/main.yml @@ -1,5 +1,4 @@ --- - - name: Install Keepalived when HA mode is enabled ansible.builtin.include_tasks: keepalived.yml when: @@ -31,7 +30,6 @@ - rke2_ha_mode_kubevip | bool - not rke2_ha_mode_keepalived | bool - - name: Copy kube-vip manifests to the masternode ansible.builtin.include_tasks: kubevip.yml when: diff --git a/tasks/remaining_nodes.yml b/tasks/remaining_nodes.yml index 310a259..e6cc0a7 100644 --- a/tasks/remaining_nodes.yml +++ b/tasks/remaining_nodes.yml @@ -1,5 +1,4 @@ --- - - name: Create the RKE2 config dir ansible.builtin.file: state: directory @@ -27,6 +26,16 @@ mode: 0600 notify: "Config file changed" +- name: Copy kubelet config + ansible.builtin.template: + src: templates/kubelet-config.yaml.j2 + dest: /etc/rancher/rke2/kubelet-config.yaml + owner: root + group: root + mode: 0600 + when: rke2_kubelet_config | length > 0 + notify: "Config file changed" + - name: Copy Containerd Registry Configuration file ansible.builtin.template: src: "{{ rke2_custom_registry_path }}" @@ -85,8 +94,7 @@ executable: /bin/bash changed_when: false register: all_ready_nodes - until: - "groups[rke2_cluster_group_name] | length == all_ready_nodes.stdout | int" + until: "groups[rke2_cluster_group_name] | length == all_ready_nodes.stdout | int" retries: 100 delay: 15 when: diff --git a/tasks/standalone.yml b/tasks/standalone.yml index 7b60d1a..1f66a5f 100644 --- a/tasks/standalone.yml +++ b/tasks/standalone.yml @@ -17,6 +17,16 @@ mode: 0600 notify: "Config file changed" +- name: Copy kubelet config + ansible.builtin.template: + src: templates/kubelet-config.yaml.j2 + dest: /etc/rancher/rke2/kubelet-config.yaml + owner: root + group: root + mode: 0600 + when: rke2_kubelet_config | length > 0 + notify: "Config file changed" + - name: Copy Containerd Registry Configuration file ansible.builtin.template: src: "{{ rke2_custom_registry_path }}" diff --git a/templates/kubelet-config.yaml.j2 b/templates/kubelet-config.yaml.j2 new file mode 100644 index 0000000..088acbe --- /dev/null +++ b/templates/kubelet-config.yaml.j2 @@ -0,0 +1,4 @@ +--- +apiVersion: kubelet.config.k8s.io/v1beta1 +kind: KubeletConfiguration +{{ rke2_kubelet_config | to_nice_yaml(indent=2) }}