Skip to content

Commit

Permalink
Merge pull request #297 from lukapetrovic-git/main
Browse files Browse the repository at this point in the history
Added option to configure KubeletConfiguration
  • Loading branch information
MonolithProjects authored Jan 29, 2025
2 parents e3cfef0 + e78e62f commit 7be6600
Show file tree
Hide file tree
Showing 7 changed files with 54 additions and 5 deletions.
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -346,6 +355,7 @@ rke2_service_cidr:

# Enable SELinux for rke2
rke2_selinux: false

```
## Inventory file example
Expand Down
9 changes: 9 additions & 0 deletions defaults/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
10 changes: 10 additions & 0 deletions tasks/first_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
2 changes: 0 additions & 2 deletions tasks/main.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

- name: Install Keepalived when HA mode is enabled
ansible.builtin.include_tasks: keepalived.yml
when:
Expand Down Expand Up @@ -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:
Expand Down
14 changes: 11 additions & 3 deletions tasks/remaining_nodes.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
---

- name: Create the RKE2 config dir
ansible.builtin.file:
state: directory
Expand Down Expand Up @@ -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 }}"
Expand Down Expand Up @@ -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:
Expand Down
10 changes: 10 additions & 0 deletions tasks/standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}"
Expand Down
4 changes: 4 additions & 0 deletions templates/kubelet-config.yaml.j2
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
---
apiVersion: kubelet.config.k8s.io/v1beta1
kind: KubeletConfiguration
{{ rke2_kubelet_config | to_nice_yaml(indent=2) }}

0 comments on commit 7be6600

Please sign in to comment.