Merge branch 'role_kubernetes-k3s'

role_nftables
Ruakij 2 years ago
commit 753f456ef3

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

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

@ -3,6 +3,8 @@
register: command register: command
changed_when: "'created' in command.stdout" changed_when: "'created' in command.stdout"
run_once: true run_once: true
failed_when:
- "command.rc == 1 and 'AlreadyExists' not in command.stderr"
- name: Deploy calico ressource template - name: Deploy calico ressource template
ansible.builtin.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 }}' token: '{{ kubernetes.token }}'
{% if nodeip_ipv6 != "" and kubernetes.ipPool.ipv6 is defined %} {% if nodeip_ipv6 != "" and kubernetes.ipPool.ipv6 is defined %}
node-ip: {{ nodeip_ipv4 }},{{ nodeip_ipv6 }} 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 %} {% else %}
node-ip: {{ nodeip_ipv4 }} node-ip: {{ nodeip_ipv4 }}
{% endif %} {% endif %}

@ -15,9 +15,6 @@ tls-san:
node-ip: {{ nodeip_ipv4 }},{{ nodeip_ipv6 }} node-ip: {{ nodeip_ipv4 }},{{ nodeip_ipv6 }}
cluster-cidr: {{ kubernetes.ipPool.ipv4.cluster_cidr }},{{ kubernetes.ipPool.ipv6.cluster_cidr }} cluster-cidr: {{ kubernetes.ipPool.ipv4.cluster_cidr }},{{ kubernetes.ipPool.ipv6.cluster_cidr }}
service-cidr: {{ kubernetes.ipPool.ipv4.service_cidr }},{{ kubernetes.ipPool.ipv6.service_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 %} {% else %}
node-ip: {{ nodeip_ipv4 }} node-ip: {{ nodeip_ipv4 }}
cluster-cidr: {{ kubernetes.ipPool.ipv4.cluster_cidr }} cluster-cidr: {{ kubernetes.ipPool.ipv4.cluster_cidr }}
@ -27,7 +24,7 @@ service-cidr: {{ kubernetes.ipPool.ipv4.service_cidr }}
egress-selector-mode: disabled egress-selector-mode: disabled
# Network-plugin # Network-plugin
{% if kubernetes.network_plugin == "flannel" %} {% if kubernetes.network.plugin == "flannel" %}
flannel-backend: vxlan flannel-backend: vxlan
{% else %} {% else %}
disable-network-policy: true disable-network-policy: true

Loading…
Cancel
Save