Skip to content

Commit

Permalink
Merge pull request #169 from lukapetrovic-git/main
Browse files Browse the repository at this point in the history
feat: Add support for rke2_cni: none. Fixes #117
  • Loading branch information
MonolithProjects authored Nov 10, 2023
2 parents 9b5d42c + be11f37 commit 41d613b
Show file tree
Hide file tree
Showing 3 changed files with 57 additions and 3 deletions.
19 changes: 18 additions & 1 deletion tasks/first_server.yml
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,23 @@
enabled: false
masked: true

- name: Wait for the first server be ready
- name: Wait for the first server be ready - no CNI
ansible.builtin.shell: |
{{ rke2_data_path }}/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml get node "{{ inventory_hostname }}" -o jsonpath='{range .status.conditions[*]}{.message}{"\n"}{end}'
args:
executable: /bin/bash
changed_when: false
register: node_status
until:
- '"kubelet has sufficient memory available" in node_status.stdout_lines'
- '"kubelet has no disk pressure" in node_status.stdout_lines'
- '"kubelet has sufficient PID available" in node_status.stdout_lines'
- ('"cni plugin not initialized" in node_status.stdout' or '"kubelet is posting ready status." in node_status.stdout')
retries: 100
delay: 15
when: rke2_cni == 'none'

- name: Wait for the first server be ready - with CNI
ansible.builtin.shell: |
set -o pipefail
{{ rke2_data_path }}/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml get nodes | grep "{{ inventory_hostname }}"
Expand All @@ -112,6 +128,7 @@
'" Ready " in first_server.stdout'
retries: 40
delay: 15
when: rke2_cni != 'none'

- name: Restore etcd - remove old <node>.node-password.rke2 secrets
ansible.builtin.shell: |
Expand Down
22 changes: 21 additions & 1 deletion tasks/remaining_nodes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,26 @@
with_items:
- "{{ (['agent', 'server'] | reject('match', rke2_type) | list) }}"

- name: Wait for remaining nodes to be ready
- name: Wait for remaining nodes to be ready - no CNI
ansible.builtin.shell: |
{{ rke2_data_path }}/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml get node "{{ item }}" -o jsonpath='{range .status.conditions[*]}{.message}{"\n"}{end}'
args:
executable: /bin/bash
changed_when: false
register: node_status
until:
- '"kubelet has sufficient memory available" in node_status.stdout_lines'
- '"kubelet has no disk pressure" in node_status.stdout_lines'
- '"kubelet has sufficient PID available" in node_status.stdout_lines'
- ('"cni plugin not initialized" in node_status.stdout' or '"kubelet is posting ready status." in node_status.stdout')
retries: 100
delay: 15
loop: "{{ groups[rke2_cluster_group_name] }}"
delegate_to: "{{ active_server | default(groups[rke2_servers_group_name].0) }}"
run_once: true
when: rke2_cni == 'none'

- name: Wait for remaining nodes to be ready - with CNI
ansible.builtin.shell: |
set -o pipefail
{{ rke2_data_path }}/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml get nodes | grep " Ready" | wc -l
Expand All @@ -71,3 +90,4 @@
delay: 15
delegate_to: "{{ active_server | default(groups[rke2_servers_group_name].0) }}"
run_once: true
when: rke2_cni != 'none'
19 changes: 18 additions & 1 deletion tasks/standalone.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,23 @@
environment:
RKE2_TOKEN: "{{ rke2_token }}"

- name: Wait for the RKE2 server to be ready
- name: Wait for the first server be ready - no CNI
ansible.builtin.shell: |
{{ rke2_data_path }}/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml get node "{{ inventory_hostname }}" -o jsonpath='{range .status.conditions[*]}{.message}{"\n"}{end}'
args:
executable: /bin/bash
changed_when: false
register: node_status
until:
- '"kubelet has sufficient memory available" in node_status.stdout_lines'
- '"kubelet has no disk pressure" in node_status.stdout_lines'
- '"kubelet has sufficient PID available" in node_status.stdout_lines'
- ('"cni plugin not initialized" in node_status.stdout' or '"kubelet is posting ready status." in node_status.stdout')
retries: 100
delay: 15
when: rke2_cni == 'none'

- name: Wait for the first server be ready - with CNI
ansible.builtin.shell: |
set -o pipefail
{{ rke2_data_path }}/bin/kubectl --kubeconfig /etc/rancher/rke2/rke2.yaml get nodes | grep "{{ inventory_hostname }}"
Expand All @@ -47,3 +63,4 @@
- '" Ready " in first_server.stdout'
retries: 40
delay: 15
when: rke2_cni != 'none'

0 comments on commit 41d613b

Please sign in to comment.