Merge branch 'role_kubernetes-k3s'

role_nftables
Ruakij 2 years ago
commit 753f456ef3

@ -1,13 +1,12 @@
- name: Install K3s agent
command: /root/k3s_install.sh {{ type }}
register: command
changed_when: "'No change detected' in command.stdout"
changed_when: "'No change detected' not in command.stdout"
until: "command is not failed"
retries: 2
delay: 10
- name: Restart when config changed, but install already done
- name: Make sure service is started / restarted on config change
service:
name: k3s
status: restarted
when: "inventory_hostname != groups['kubernetes'][0] and not command.changed and config.changed"
name: k3s-agent
state: "{{ 'restarted' if not command.changed and config.changed else 'started' }}"

@ -2,13 +2,13 @@
command: /root/k3s_install.sh {{ type }}
when: "inventory_hostname == groups['kubernetes'][0]"
register: command
changed_when: "'No change detected' in command.stdout"
changed_when: "'No change detected' not in command.stdout"
- name: Restart when config changed, but install already done
- name: Make sure service is started / restarted on config change
service:
name: k3s
status: restarted
when: "inventory_hostname == groups['kubernetes'][0] and not command.changed and config.changed"
state: "{{ 'restarted' if not command.changed and config.changed else 'started' }}"
when: "inventory_hostname == groups['kubernetes'][0]"
- name: Waiting for K3s-server to accept connections
ansible.builtin.wait_for:
@ -21,16 +21,16 @@
command: /root/k3s_install.sh {{ type }}
when: "inventory_hostname != groups['kubernetes'][0]"
register: command
changed_when: "'No change detected' in command.stdout"
changed_when: "'No change detected' not in command.stdout"
until: "command is not failed"
retries: 2
delay: 10
- name: Restart when config changed, but install already done
- name: Make sure service is started / restarted on config change
service:
name: k3s
status: restarted
when: "inventory_hostname != groups['kubernetes'][0] and not command.changed and config.changed"
state: "{{ 'restarted' if not command.changed and config.changed else 'started' }}"
when: "inventory_hostname != groups['kubernetes'][0]"
- name: Waiting for K3s-server to accept connections on other nodes
ansible.builtin.wait_for:

@ -3,6 +3,8 @@
register: command
changed_when: "'created' in command.stdout"
run_once: true
failed_when:
- "command.rc == 1 and 'AlreadyExists' not in command.stderr"
- name: Deploy calico ressource template
ansible.builtin.template:

@ -1,11 +1,8 @@
server: https://{{ kubernetes.control_plane.dns_name }}:6443
server: https://{{ hostvars[groups['kubernetes'][0]]['nodeip_ipv4'] }}:6443
token: '{{ kubernetes.token }}'
{% if nodeip_ipv6 != "" and kubernetes.ipPool.ipv6 is defined %}
node-ip: {{ nodeip_ipv4 }},{{ nodeip_ipv6 }}
# FIXME: Workaround for bug in Kubernetes 1.24/1.25 ignoring node IPv6 addresses
kubelet-arg: "--node-ip=0.0.0.0"
{% else %}
node-ip: {{ nodeip_ipv4 }}
{% endif %}

@ -15,9 +15,6 @@ tls-san:
node-ip: {{ nodeip_ipv4 }},{{ nodeip_ipv6 }}
cluster-cidr: {{ kubernetes.ipPool.ipv4.cluster_cidr }},{{ kubernetes.ipPool.ipv6.cluster_cidr }}
service-cidr: {{ kubernetes.ipPool.ipv4.service_cidr }},{{ kubernetes.ipPool.ipv6.service_cidr }}
# FIXME: Workaround for bug in Kubernetes 1.24/1.25 ignoring node IPv6 addresses
kubelet-arg: "--node-ip=0.0.0.0"
{% else %}
node-ip: {{ nodeip_ipv4 }}
cluster-cidr: {{ kubernetes.ipPool.ipv4.cluster_cidr }}
@ -27,7 +24,7 @@ service-cidr: {{ kubernetes.ipPool.ipv4.service_cidr }}
egress-selector-mode: disabled
# Network-plugin
{% if kubernetes.network_plugin == "flannel" %}
{% if kubernetes.network.plugin == "flannel" %}
flannel-backend: vxlan
{% else %}
disable-network-policy: true

Loading…
Cancel
Save