Add the cilium network plugin to the kubernetes role, disabling servicelb, and collect the disabled k3s components in one disable list
This commit is contained in:
@@ -23,7 +23,7 @@ kubernetes:
|
|||||||
# can be used to remove filter
|
# can be used to remove filter
|
||||||
clean_resolv_conf: false
|
clean_resolv_conf: false
|
||||||
|
|
||||||
# One of [flannel, calico]
|
# One of [none, flannel, calico, cilium]
|
||||||
plugin: calico
|
plugin: calico
|
||||||
|
|
||||||
# Helper for networking
|
# Helper for networking
|
||||||
@@ -33,7 +33,7 @@ kubernetes:
|
|||||||
# Helpful, when nodeIp_interface is a wireguard-interface
|
# Helpful, when nodeIp_interface is a wireguard-interface
|
||||||
routingtabletowg: false
|
routingtabletowg: false
|
||||||
|
|
||||||
# One of [traefik-ingress]
|
# One of [none, traefik-ingress, nginx-ingress]
|
||||||
ingress_controller: traefik-ingress
|
ingress_controller: traefik-ingress
|
||||||
|
|
||||||
# k3s version to install, e.g. v1.37.1+k3s1. An installed k3s is replaced only
|
# k3s version to install, e.g. v1.37.1+k3s1. An installed k3s is replaced only
|
||||||
|
|||||||
@@ -41,5 +41,10 @@
|
|||||||
when:
|
when:
|
||||||
- "kubernetes.network.plugin == 'calico'"
|
- "kubernetes.network.plugin == 'calico'"
|
||||||
|
|
||||||
|
- name: Deploy cilium
|
||||||
|
import_tasks: ./roles/kubernetes/tasks/install/server/network-plugin/deploy_cilium.yml
|
||||||
|
when:
|
||||||
|
- "kubernetes.network.plugin == 'cilium'"
|
||||||
|
|
||||||
- name: Deploy network-helpers
|
- name: Deploy network-helpers
|
||||||
import_tasks: ./roles/kubernetes/tasks/install/server/network-plugin/deploy_network_helper.yml
|
import_tasks: ./roles/kubernetes/tasks/install/server/network-plugin/deploy_network_helper.yml
|
||||||
|
|||||||
@@ -0,0 +1,63 @@
|
|||||||
|
- name: Check if already installed in cluster
|
||||||
|
command: "cilium status"
|
||||||
|
register: cilium_status
|
||||||
|
ignore_errors: true
|
||||||
|
run_once: true
|
||||||
|
|
||||||
|
- name: Get Cilium CLI version
|
||||||
|
ansible.builtin.command:
|
||||||
|
argv:
|
||||||
|
- curl
|
||||||
|
- -s
|
||||||
|
- https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt
|
||||||
|
register: cilium_cli_version
|
||||||
|
check_mode: no
|
||||||
|
changed_when: false
|
||||||
|
run_once: true
|
||||||
|
|
||||||
|
- name: Determine CLI architecture
|
||||||
|
set_fact:
|
||||||
|
cli_arch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}"
|
||||||
|
run_once: true
|
||||||
|
|
||||||
|
- name: Download and verify Cilium CLI
|
||||||
|
block:
|
||||||
|
- name: Download Cilium CLI tar.gz file
|
||||||
|
get_url:
|
||||||
|
url: "https://github.com/cilium/cilium-cli/releases/download/{{ cilium_cli_version.stdout }}/cilium-linux-{{ cli_arch }}.tar.gz"
|
||||||
|
dest: "/tmp/cilium-linux-{{ cli_arch }}.tar.gz"
|
||||||
|
checksum: "sha256:{{ lookup('url', 'https://github.com/cilium/cilium-cli/releases/download/' + cilium_cli_version.stdout + '/cilium-linux-' + cli_arch + '.tar.gz.sha256sum', wantlist=True)[0].split(' ')[0] }}"
|
||||||
|
mode: '0755'
|
||||||
|
|
||||||
|
- name: Extract Cilium CLI tar.gz to /usr/local/bin
|
||||||
|
unarchive:
|
||||||
|
src: "/tmp/cilium-linux-{{ cli_arch }}.tar.gz"
|
||||||
|
dest: "/usr/local/bin"
|
||||||
|
remote_src: yes
|
||||||
|
#extra_opts: ["--strip-components=1"]
|
||||||
|
mode: 777
|
||||||
|
when: cilium_cli_version.stdout is defined
|
||||||
|
become: yes
|
||||||
|
|
||||||
|
- name: Clean up temporary files
|
||||||
|
file:
|
||||||
|
path: "/tmp/cilium-linux-{{ cli_arch }}.tar.gz"
|
||||||
|
state: absent
|
||||||
|
|
||||||
|
# Install cilium via cli
|
||||||
|
- block:
|
||||||
|
- name: Install cilium
|
||||||
|
command: >
|
||||||
|
cilium install
|
||||||
|
--set
|
||||||
|
imap.mode=kubernetes,
|
||||||
|
ipv6.enabled=true,
|
||||||
|
#ipam.operator.clusterPoolIPv4PodCIDRList={{ kubernetes.ipPool.ipv4.cluster_cidr }},
|
||||||
|
#ipam.operator.clusterPoolIPv6PodCIDRList={{ kubernetes.ipPool.ipv6.cluster_cidr }}
|
||||||
|
|
||||||
|
- name: Wait for cilium
|
||||||
|
command: cilium status --wait
|
||||||
|
changed_when: false
|
||||||
|
run_once: true
|
||||||
|
when:
|
||||||
|
- cilium_status.rc != 0
|
||||||
@@ -1,3 +1,5 @@
|
|||||||
|
{% set disabled_components = [] %}
|
||||||
|
|
||||||
## Base ##
|
## Base ##
|
||||||
node-name: {{ ansible_fqdn }}
|
node-name: {{ ansible_fqdn }}
|
||||||
# Join cluster
|
# Join cluster
|
||||||
@@ -21,6 +23,15 @@ node-ip: {{ nodeip_ipv4 }},{{ nodeip_ipv6 }}
|
|||||||
node-ip: {{ nodeip_ipv4 }}
|
node-ip: {{ nodeip_ipv4 }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
# Network-plugin
|
||||||
|
{% if kubernetes.network.plugin == "flannel" %}
|
||||||
|
{% else %}
|
||||||
|
{% if kubernetes.network.plugin == "cilium" %}
|
||||||
|
# Cilium requires servicelb to be disabled when replacing kube-proxy
|
||||||
|
{% set _ = disabled_components.append('servicelb') %}
|
||||||
|
{% endif %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
## Label
|
## Label
|
||||||
# Region & DC
|
# Region & DC
|
||||||
node-label:
|
node-label:
|
||||||
@@ -34,4 +45,9 @@ node-label:
|
|||||||
- {{ item }}
|
- {{ item }}
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
|
|
||||||
|
# Disabled components
|
||||||
|
{% if disabled_components %}
|
||||||
|
disable: {{ disabled_components | join(',') }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{{ kubernetes.config_extra | to_yaml }}
|
{{ kubernetes.config_extra | to_yaml }}
|
||||||
|
|||||||
@@ -1,3 +1,5 @@
|
|||||||
|
{% set disabled_components = [] %}
|
||||||
|
|
||||||
## Base ##
|
## Base ##
|
||||||
node-name: {{ ansible_fqdn }}
|
node-name: {{ ansible_fqdn }}
|
||||||
{% if inventory_hostname == groups['kubernetes'][0] %}
|
{% if inventory_hostname == groups['kubernetes'][0] %}
|
||||||
@@ -46,11 +48,15 @@ flannel-backend: vxlan
|
|||||||
{% else %}
|
{% else %}
|
||||||
disable-network-policy: true
|
disable-network-policy: true
|
||||||
flannel-backend: none
|
flannel-backend: none
|
||||||
|
{% if kubernetes.network.plugin == "cilium" %}
|
||||||
|
# Cilium requires servicelb to be disabled when replacing kube-proxy
|
||||||
|
{% set _ = disabled_components.append('servicelb') %}
|
||||||
|
{% endif %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
# Ingress-plugin
|
# Ingress-plugin
|
||||||
{% if kubernetes.ingress_controller != "traefik-ingress" %}
|
{% if kubernetes.ingress_controller != "traefik-ingress" %}
|
||||||
disable: traefik
|
{% set _ = disabled_components.append('traefik') %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
## Label
|
## Label
|
||||||
@@ -68,6 +74,11 @@ node-label:
|
|||||||
{% endfor %}
|
{% endfor %}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
|
# Disabled components
|
||||||
|
{% if disabled_components %}
|
||||||
|
disable: {{ disabled_components | join(',') }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{{ kubernetes.config_extra | to_yaml }}
|
{{ kubernetes.config_extra | to_yaml }}
|
||||||
|
|
||||||
# Image garbage collection tuning (drop-in KubeletConfiguration)
|
# Image garbage collection tuning (drop-in KubeletConfiguration)
|
||||||
|
|||||||
Reference in New Issue
Block a user