mirror of
https://github.com/techno-tim/k3s-ansible.git
synced 2026-09-16 17:13:19 +02:00
Merge branch 'master' into master
This commit is contained in:
@@ -10,6 +10,7 @@
|
||||
state: directory
|
||||
mode: '0755'
|
||||
|
||||
|
||||
- name: Deploy the K3s http_proxy configuration file
|
||||
ansible.builtin.template:
|
||||
src: "http_proxy.conf.j2"
|
||||
@@ -17,3 +18,20 @@
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
|
||||
- name: Create k3s-node.service.d directory
|
||||
file:
|
||||
path: '{{ systemd_dir }}/k3s-node.service.d'
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
|
||||
|
||||
- name: Copy K3s http_proxy conf file
|
||||
template:
|
||||
src: "http_proxy.conf.j2"
|
||||
dest: "{{ systemd_dir }}/k3s-node.service.d/http_proxy.conf"
|
||||
owner: root
|
||||
group: root
|
||||
mode: '0755'
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
---
|
||||
- name: Create manifests directory on first master
|
||||
file:
|
||||
path: /var/lib/rancher/k3s/server/manifests
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
when: ansible_hostname == hostvars[groups[group_name_master | default('master')][0]]['ansible_hostname']
|
||||
|
||||
- name: Download vip cloud provider manifest to first master
|
||||
ansible.builtin.get_url:
|
||||
url: "https://raw.githubusercontent.com/kube-vip/kube-vip-cloud-provider/{{ kube_vip_cloud_provider_tag_version | default('main') }}/manifest/kube-vip-cloud-controller.yaml" # noqa yaml[line-length]
|
||||
dest: "/var/lib/rancher/k3s/server/manifests/kube-vip-cloud-controller.yaml"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
when: ansible_hostname == hostvars[groups[group_name_master | default('master')][0]]['ansible_hostname']
|
||||
|
||||
- name: Copy kubevip configMap manifest to first master
|
||||
template:
|
||||
src: "kubevip.yaml.j2"
|
||||
dest: "/var/lib/rancher/k3s/server/manifests/kubevip.yaml"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0644
|
||||
when: ansible_hostname == hostvars[groups[group_name_master | default('master')][0]]['ansible_hostname']
|
||||
@@ -6,6 +6,13 @@
|
||||
state: stopped
|
||||
failed_when: false
|
||||
|
||||
# k3s-init won't work if the port is already in use
|
||||
- name: Stop k3s
|
||||
systemd:
|
||||
name: k3s
|
||||
state: stopped
|
||||
failed_when: false
|
||||
|
||||
- name: Clean previous runs of k3s-init # noqa command-instead-of-module
|
||||
# The systemd module does not support "reset-failed", so we need to resort to command.
|
||||
command: systemctl reset-failed k3s-init
|
||||
@@ -22,6 +29,12 @@
|
||||
- name: Deploy metallb manifest
|
||||
include_tasks: metallb.yml
|
||||
tags: metallb
|
||||
when: kube_vip_lb_ip_range is not defined and (not cilium_bgp or cilium_iface is not defined)
|
||||
|
||||
- name: Deploy kube-vip manifest
|
||||
include_tasks: kube-vip.yml
|
||||
tags: kubevip
|
||||
when: kube_vip_lb_ip_range is defined
|
||||
|
||||
- name: Init cluster inside the transient k3s-init service
|
||||
command:
|
||||
@@ -29,7 +42,7 @@
|
||||
-p Restart=on-failure \
|
||||
--unit=k3s-init \
|
||||
k3s server {{ server_init_args }}"
|
||||
creates: "{{ systemd_dir }}/k3s.service"
|
||||
creates: "{{ systemd_dir }}/k3s-init.service"
|
||||
|
||||
- name: Verification
|
||||
when: not ansible_check_mode
|
||||
@@ -67,9 +80,9 @@
|
||||
- name: Enable and check K3s service
|
||||
systemd:
|
||||
name: k3s
|
||||
daemon_reload: yes
|
||||
daemon_reload: true
|
||||
state: restarted
|
||||
enabled: yes
|
||||
enabled: true
|
||||
|
||||
- name: Wait for node-token
|
||||
wait_for:
|
||||
@@ -110,7 +123,7 @@
|
||||
copy:
|
||||
src: /etc/rancher/k3s/k3s.yaml
|
||||
dest: "{{ ansible_user_dir }}/.kube/config"
|
||||
remote_src: yes
|
||||
remote_src: true
|
||||
owner: "{{ ansible_user_id }}"
|
||||
mode: "u=rw,g=,o="
|
||||
|
||||
|
||||
@@ -0,0 +1,13 @@
|
||||
---
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: kubevip
|
||||
namespace: kube-system
|
||||
data:
|
||||
{% if kube_vip_lb_ip_range is string %}
|
||||
{# kube_vip_lb_ip_range was used in the legacy way: single string instead of a list #}
|
||||
{# => transform to list with single element #}
|
||||
{% set kube_vip_lb_ip_range = [kube_vip_lb_ip_range] %}
|
||||
{% endif %}
|
||||
range-global: {{ kube_vip_lb_ip_range | join(',') }}
|
||||
@@ -43,7 +43,7 @@ spec:
|
||||
- name: vip_ddns
|
||||
value: "false"
|
||||
- name: svc_enable
|
||||
value: "false"
|
||||
value: "{{ 'true' if kube_vip_lb_ip_range is defined else 'false' }}"
|
||||
- name: vip_leaderelection
|
||||
value: "true"
|
||||
- name: vip_leaseduration
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
---
|
||||
# Timeout to wait for MetalLB services to come up
|
||||
metal_lb_available_timeout: 120s
|
||||
metal_lb_available_timeout: 240s
|
||||
|
||||
# Name of the master group
|
||||
group_name_master: master
|
||||
|
||||
@@ -0,0 +1,114 @@
|
||||
---
|
||||
- name: Deploy Calico to cluster
|
||||
when: ansible_hostname == hostvars[groups[group_name_master | default('master')][0]]['ansible_hostname']
|
||||
run_once: true
|
||||
block:
|
||||
- name: Create manifests directory on first master
|
||||
file:
|
||||
path: /tmp/k3s
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: "Download to first master: manifest for Tigera Operator and Calico CRDs"
|
||||
ansible.builtin.get_url:
|
||||
url: "https://raw.githubusercontent.com/projectcalico/calico/{{ calico_tag }}/manifests/tigera-operator.yaml"
|
||||
dest: "/tmp/k3s/tigera-operator.yaml"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: Copy Calico custom resources manifest to first master
|
||||
ansible.builtin.template:
|
||||
src: "calico.crs.j2"
|
||||
dest: /tmp/k3s/custom-resources.yaml
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: Deploy or replace Tigera Operator
|
||||
block:
|
||||
- name: Deploy Tigera Operator
|
||||
ansible.builtin.command:
|
||||
cmd: kubectl create -f /tmp/k3s/tigera-operator.yaml
|
||||
register: create_operator
|
||||
changed_when: "'created' in create_operator.stdout"
|
||||
failed_when: "'Error' in create_operator.stderr and 'already exists' not in create_operator.stderr"
|
||||
rescue:
|
||||
- name: Replace existing Tigera Operator
|
||||
ansible.builtin.command:
|
||||
cmd: kubectl replace -f /tmp/k3s/tigera-operator.yaml
|
||||
register: replace_operator
|
||||
changed_when: "'replaced' in replace_operator.stdout"
|
||||
failed_when: "'Error' in replace_operator.stderr"
|
||||
|
||||
- name: Wait for Tigera Operator resources
|
||||
command: >-
|
||||
k3s kubectl wait {{ item.type }}/{{ item.name }}
|
||||
--namespace='tigera-operator'
|
||||
--for=condition=Available=True
|
||||
--timeout=7s
|
||||
register: tigera_result
|
||||
changed_when: false
|
||||
until: tigera_result is succeeded
|
||||
retries: 7
|
||||
delay: 7
|
||||
with_items:
|
||||
- {name: tigera-operator, type: deployment}
|
||||
loop_control:
|
||||
label: "{{ item.type }}/{{ item.name }}"
|
||||
|
||||
- name: Deploy Calico custom resources
|
||||
block:
|
||||
- name: Deploy custom resources for Calico
|
||||
ansible.builtin.command:
|
||||
cmd: kubectl create -f /tmp/k3s/custom-resources.yaml
|
||||
register: create_cr
|
||||
changed_when: "'created' in create_cr.stdout"
|
||||
failed_when: "'Error' in create_cr.stderr and 'already exists' not in create_cr.stderr"
|
||||
rescue:
|
||||
- name: Apply new Calico custom resource manifest
|
||||
ansible.builtin.command:
|
||||
cmd: kubectl apply -f /tmp/k3s/custom-resources.yaml
|
||||
register: apply_cr
|
||||
changed_when: "'configured' in apply_cr.stdout or 'created' in apply_cr.stdout"
|
||||
failed_when: "'Error' in apply_cr.stderr"
|
||||
|
||||
- name: Wait for Calico system resources to be available
|
||||
command: >-
|
||||
{% if item.type == 'daemonset' %}
|
||||
k3s kubectl wait pods
|
||||
--namespace='{{ item.namespace }}'
|
||||
--selector={{ item.selector }}
|
||||
--for=condition=Ready
|
||||
{% else %}
|
||||
k3s kubectl wait {{ item.type }}/{{ item.name }}
|
||||
--namespace='{{ item.namespace }}'
|
||||
--for=condition=Available
|
||||
{% endif %}
|
||||
--timeout=7s
|
||||
register: cr_result
|
||||
changed_when: false
|
||||
until: cr_result is succeeded
|
||||
retries: 30
|
||||
delay: 7
|
||||
with_items:
|
||||
- {name: calico-typha, type: deployment, namespace: calico-system}
|
||||
- {name: calico-kube-controllers, type: deployment, namespace: calico-system}
|
||||
- {name: csi-node-driver, type: daemonset, selector: 'k8s-app=csi-node-driver', namespace: calico-system}
|
||||
- {name: calico-node, type: daemonset, selector: 'k8s-app=calico-node', namespace: calico-system}
|
||||
- {name: calico-apiserver, type: deployment, namespace: calico-apiserver}
|
||||
loop_control:
|
||||
label: "{{ item.type }}/{{ item.name }}"
|
||||
|
||||
- name: Patch Felix configuration for eBPF mode
|
||||
ansible.builtin.command:
|
||||
cmd: >
|
||||
kubectl patch felixconfiguration default
|
||||
--type='merge'
|
||||
--patch='{"spec": {"bpfKubeProxyIptablesCleanupEnabled": false}}'
|
||||
register: patch_result
|
||||
changed_when: "'felixconfiguration.projectcalico.org/default patched' in patch_result.stdout"
|
||||
failed_when: "'Error' in patch_result.stderr"
|
||||
when: calico_ebpf
|
||||
@@ -0,0 +1,253 @@
|
||||
---
|
||||
- name: Prepare Cilium CLI on first master and deploy CNI
|
||||
when: ansible_hostname == hostvars[groups[group_name_master | default('master')][0]]['ansible_hostname']
|
||||
run_once: true
|
||||
block:
|
||||
- name: Create tmp directory on first master
|
||||
file:
|
||||
path: /tmp/k3s
|
||||
state: directory
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: Check if Cilium CLI is installed
|
||||
ansible.builtin.command: cilium version
|
||||
register: cilium_cli_installed
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
ignore_errors: true
|
||||
|
||||
- name: Check for Cilium CLI version in command output
|
||||
set_fact:
|
||||
installed_cli_version: >-
|
||||
{{
|
||||
cilium_cli_installed.stdout_lines
|
||||
| join(' ')
|
||||
| regex_findall('cilium-cli: (v\d+\.\d+\.\d+)')
|
||||
| first
|
||||
| default('unknown')
|
||||
}}
|
||||
when: cilium_cli_installed.rc == 0
|
||||
|
||||
- name: Get latest stable Cilium CLI version file
|
||||
ansible.builtin.get_url:
|
||||
url: "https://raw.githubusercontent.com/cilium/cilium-cli/main/stable.txt"
|
||||
dest: "/tmp/k3s/cilium-cli-stable.txt"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: Read Cilium CLI stable version from file
|
||||
ansible.builtin.command: cat /tmp/k3s/cilium-cli-stable.txt
|
||||
register: cli_ver
|
||||
changed_when: false
|
||||
|
||||
- name: Log installed Cilium CLI version
|
||||
ansible.builtin.debug:
|
||||
msg: "Installed Cilium CLI version: {{ installed_cli_version | default('Not installed') }}"
|
||||
|
||||
- name: Log latest stable Cilium CLI version
|
||||
ansible.builtin.debug:
|
||||
msg: "Latest Cilium CLI version: {{ cli_ver.stdout }}"
|
||||
|
||||
- name: Determine if Cilium CLI needs installation or update
|
||||
set_fact:
|
||||
cilium_cli_needs_update: >-
|
||||
{{
|
||||
cilium_cli_installed.rc != 0 or
|
||||
(cilium_cli_installed.rc == 0 and
|
||||
installed_cli_version != cli_ver.stdout)
|
||||
}}
|
||||
|
||||
- name: Install or update Cilium CLI
|
||||
when: cilium_cli_needs_update
|
||||
block:
|
||||
- name: Set architecture variable
|
||||
ansible.builtin.set_fact:
|
||||
cli_arch: "{{ 'arm64' if ansible_architecture == 'aarch64' else 'amd64' }}"
|
||||
|
||||
- name: Download Cilium CLI and checksum
|
||||
ansible.builtin.get_url:
|
||||
url: "{{ cilium_base_url }}/cilium-linux-{{ cli_arch }}{{ item }}"
|
||||
dest: "/tmp/k3s/cilium-linux-{{ cli_arch }}{{ item }}"
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
loop:
|
||||
- ".tar.gz"
|
||||
- ".tar.gz.sha256sum"
|
||||
vars:
|
||||
cilium_base_url: "https://github.com/cilium/cilium-cli/releases/download/{{ cli_ver.stdout }}"
|
||||
|
||||
- name: Verify the downloaded tarball
|
||||
ansible.builtin.shell: |
|
||||
cd /tmp/k3s && sha256sum --check cilium-linux-{{ cli_arch }}.tar.gz.sha256sum
|
||||
args:
|
||||
executable: /bin/bash
|
||||
changed_when: false
|
||||
|
||||
- name: Extract Cilium CLI to /usr/local/bin
|
||||
ansible.builtin.unarchive:
|
||||
src: "/tmp/k3s/cilium-linux-{{ cli_arch }}.tar.gz"
|
||||
dest: /usr/local/bin
|
||||
remote_src: true
|
||||
|
||||
- name: Remove downloaded tarball and checksum file
|
||||
ansible.builtin.file:
|
||||
path: "{{ item }}"
|
||||
state: absent
|
||||
loop:
|
||||
- "/tmp/k3s/cilium-linux-{{ cli_arch }}.tar.gz"
|
||||
- "/tmp/k3s/cilium-linux-{{ cli_arch }}.tar.gz.sha256sum"
|
||||
|
||||
- name: Wait for connectivity to kube VIP
|
||||
ansible.builtin.command: ping -c 1 {{ apiserver_endpoint }}
|
||||
register: ping_result
|
||||
until: ping_result.rc == 0
|
||||
retries: 21
|
||||
delay: 1
|
||||
ignore_errors: true
|
||||
changed_when: false
|
||||
|
||||
- name: Fail if kube VIP not reachable
|
||||
ansible.builtin.fail:
|
||||
msg: "API endpoint {{ apiserver_endpoint }} is not reachable"
|
||||
when: ping_result.rc != 0
|
||||
|
||||
- name: Test for existing Cilium install
|
||||
ansible.builtin.command: k3s kubectl -n kube-system get daemonsets cilium
|
||||
register: cilium_installed
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
ignore_errors: true
|
||||
|
||||
- name: Check existing Cilium install
|
||||
when: cilium_installed.rc == 0
|
||||
block:
|
||||
|
||||
- name: Check Cilium version
|
||||
ansible.builtin.command: cilium version
|
||||
register: cilium_version
|
||||
failed_when: false
|
||||
changed_when: false
|
||||
ignore_errors: true
|
||||
|
||||
- name: Parse installed Cilium version
|
||||
set_fact:
|
||||
installed_cilium_version: >-
|
||||
{{
|
||||
cilium_version.stdout_lines
|
||||
| join(' ')
|
||||
| regex_findall('cilium image.+(\d+\.\d+\.\d+)')
|
||||
| first
|
||||
| default('unknown')
|
||||
}}
|
||||
|
||||
- name: Determine if Cilium needs update
|
||||
set_fact:
|
||||
cilium_needs_update: >-
|
||||
{{ 'v' + installed_cilium_version != cilium_tag }}
|
||||
|
||||
- name: Log result
|
||||
ansible.builtin.debug:
|
||||
msg: >
|
||||
Installed Cilium version: {{ installed_cilium_version }},
|
||||
Target Cilium version: {{ cilium_tag }},
|
||||
Update needed: {{ cilium_needs_update }}
|
||||
|
||||
- name: Install Cilium
|
||||
ansible.builtin.command: >-
|
||||
{% if cilium_installed.rc != 0 %}
|
||||
cilium install
|
||||
{% else %}
|
||||
cilium upgrade
|
||||
{% endif %}
|
||||
--version "{{ cilium_tag }}"
|
||||
--helm-set operator.replicas="1"
|
||||
{{ '--helm-set devices=' + cilium_iface if cilium_iface != 'auto' else '' }}
|
||||
--helm-set ipam.operator.clusterPoolIPv4PodCIDRList={{ cluster_cidr }}
|
||||
{% if cilium_mode == "native" or (cilium_bgp and cilium_exportPodCIDR != 'false') %}
|
||||
--helm-set ipv4NativeRoutingCIDR={{ cluster_cidr }}
|
||||
{% endif %}
|
||||
--helm-set k8sServiceHost="127.0.0.1"
|
||||
--helm-set k8sServicePort="6444"
|
||||
--helm-set routingMode={{ cilium_mode | default("native") }}
|
||||
--helm-set autoDirectNodeRoutes={{ "true" if cilium_mode == "native" else "false" }}
|
||||
--helm-set kubeProxyReplacement={{ kube_proxy_replacement | default("true") }}
|
||||
--helm-set bpf.masquerade={{ enable_bpf_masquerade | default("true") }}
|
||||
--helm-set bgpControlPlane.enabled={{ cilium_bgp | default("false") }}
|
||||
--helm-set hubble.enabled={{ "true" if cilium_hubble else "false" }}
|
||||
--helm-set hubble.relay.enabled={{ "true" if cilium_hubble else "false" }}
|
||||
--helm-set hubble.ui.enabled={{ "true" if cilium_hubble else "false" }}
|
||||
{% if kube_proxy_replacement is not false %}
|
||||
--helm-set bpf.loadBalancer.algorithm={{ bpf_lb_algorithm | default("maglev") }}
|
||||
--helm-set bpf.loadBalancer.mode={{ bpf_lb_mode | default("hybrid") }}
|
||||
{% endif %}
|
||||
environment:
|
||||
KUBECONFIG: /home/{{ ansible_user }}/.kube/config
|
||||
register: cilium_install_result
|
||||
changed_when: cilium_install_result.rc == 0
|
||||
when: cilium_installed.rc != 0 or cilium_needs_update
|
||||
|
||||
- name: Wait for Cilium resources
|
||||
command: >-
|
||||
{% if item.type == 'daemonset' %}
|
||||
k3s kubectl wait pods
|
||||
--namespace=kube-system
|
||||
--selector='k8s-app=cilium'
|
||||
--for=condition=Ready
|
||||
{% else %}
|
||||
k3s kubectl wait {{ item.type }}/{{ item.name }}
|
||||
--namespace=kube-system
|
||||
--for=condition=Available
|
||||
{% endif %}
|
||||
--timeout=7s
|
||||
register: cr_result
|
||||
changed_when: false
|
||||
until: cr_result is succeeded
|
||||
retries: 30
|
||||
delay: 7
|
||||
with_items:
|
||||
- {name: cilium-operator, type: deployment}
|
||||
- {name: cilium, type: daemonset, selector: 'k8s-app=cilium'}
|
||||
- {name: hubble-relay, type: deployment, check_hubble: true}
|
||||
- {name: hubble-ui, type: deployment, check_hubble: true}
|
||||
loop_control:
|
||||
label: "{{ item.type }}/{{ item.name }}"
|
||||
when: >-
|
||||
not item.check_hubble | default(false) or (item.check_hubble | default(false) and cilium_hubble)
|
||||
|
||||
- name: Configure Cilium BGP
|
||||
when: cilium_bgp
|
||||
block:
|
||||
|
||||
- name: Copy BGP manifests to first master
|
||||
ansible.builtin.template:
|
||||
src: "cilium.crs.j2"
|
||||
dest: /tmp/k3s/cilium-bgp.yaml
|
||||
owner: root
|
||||
group: root
|
||||
mode: 0755
|
||||
|
||||
- name: Apply BGP manifests
|
||||
ansible.builtin.command:
|
||||
cmd: kubectl apply -f /tmp/k3s/cilium-bgp.yaml
|
||||
register: apply_cr
|
||||
changed_when: "'configured' in apply_cr.stdout or 'created' in apply_cr.stdout"
|
||||
failed_when: "'is invalid' in apply_cr.stderr"
|
||||
ignore_errors: true
|
||||
|
||||
- name: Print error message if BGP manifests application fails
|
||||
ansible.builtin.debug:
|
||||
msg: "{{ apply_cr.stderr }}"
|
||||
when: "'is invalid' in apply_cr.stderr"
|
||||
|
||||
- name: Test for BGP config resources
|
||||
ansible.builtin.command: "{{ item }}"
|
||||
loop:
|
||||
- k3s kubectl get CiliumBGPPeeringPolicy.cilium.io
|
||||
- k3s kubectl get CiliumLoadBalancerIPPool.cilium.io
|
||||
changed_when: false
|
||||
loop_control:
|
||||
label: "{{ item }}"
|
||||
@@ -1,7 +1,18 @@
|
||||
---
|
||||
- name: Deploy calico
|
||||
include_tasks: calico.yml
|
||||
tags: calico
|
||||
when: calico_iface is defined and cilium_iface is not defined
|
||||
|
||||
- name: Deploy cilium
|
||||
include_tasks: cilium.yml
|
||||
tags: cilium
|
||||
when: cilium_iface is defined
|
||||
|
||||
- name: Deploy metallb pool
|
||||
include_tasks: metallb.yml
|
||||
tags: metallb
|
||||
when: kube_vip_lb_ip_range is not defined and (not cilium_bgp or cilium_iface is not defined)
|
||||
|
||||
- name: Remove tmp directory used for manifests
|
||||
file:
|
||||
|
||||
@@ -8,6 +8,27 @@
|
||||
with_items: "{{ groups[group_name_master | default('master')] }}"
|
||||
run_once: true
|
||||
|
||||
- name: Delete outdated metallb replicas
|
||||
shell: |-
|
||||
set -o pipefail
|
||||
|
||||
REPLICAS=$(k3s kubectl --namespace='metallb-system' get replicasets \
|
||||
-l 'component=controller,app=metallb' \
|
||||
-o jsonpath='{.items[0].spec.template.spec.containers[0].image}, {.items[0].metadata.name}' 2>/dev/null || true)
|
||||
REPLICAS_SETS=$(echo ${REPLICAS} | grep -v '{{ metal_lb_controller_tag_version }}' | sed -e "s/^.*\s//g")
|
||||
if [ -n "${REPLICAS_SETS}" ] ; then
|
||||
for REPLICAS in "${REPLICAS_SETS}"
|
||||
do
|
||||
k3s kubectl --namespace='metallb-system' \
|
||||
delete rs "${REPLICAS}"
|
||||
done
|
||||
fi
|
||||
args:
|
||||
executable: /bin/bash
|
||||
changed_when: false
|
||||
run_once: true
|
||||
with_items: "{{ groups[group_name_master | default('master')] }}"
|
||||
|
||||
- name: Copy metallb CRs manifest to first master
|
||||
template:
|
||||
src: "metallb.crs.j2"
|
||||
|
||||
@@ -0,0 +1,41 @@
|
||||
# This section includes base Calico installation configuration.
|
||||
# For more information, see: https://docs.tigera.io/calico/latest/reference/installation/api#operator.tigera.io/v1.Installation
|
||||
apiVersion: operator.tigera.io/v1
|
||||
kind: Installation
|
||||
metadata:
|
||||
name: default
|
||||
spec:
|
||||
# Configures Calico networking.
|
||||
calicoNetwork:
|
||||
# Note: The ipPools section cannot be modified post-install.
|
||||
ipPools:
|
||||
- blockSize: {{ calico_blockSize | default('26') }}
|
||||
cidr: {{ cluster_cidr | default('10.52.0.0/16') }}
|
||||
encapsulation: {{ calico_encapsulation | default('VXLANCrossSubnet') }}
|
||||
natOutgoing: {{ calico_natOutgoing | default('Enabled') }}
|
||||
nodeSelector: {{ calico_nodeSelector | default('all()') }}
|
||||
nodeAddressAutodetectionV4:
|
||||
interface: {{ calico_iface }}
|
||||
linuxDataplane: {{ 'BPF' if calico_ebpf else 'Iptables' }}
|
||||
|
||||
---
|
||||
|
||||
# This section configures the Calico API server.
|
||||
# For more information, see: https://docs.tigera.io/calico/latest/reference/installation/api#operator.tigera.io/v1.APIServer
|
||||
apiVersion: operator.tigera.io/v1
|
||||
kind: APIServer
|
||||
metadata:
|
||||
name: default
|
||||
spec: {}
|
||||
|
||||
{% if calico_ebpf %}
|
||||
---
|
||||
kind: ConfigMap
|
||||
apiVersion: v1
|
||||
metadata:
|
||||
name: kubernetes-services-endpoint
|
||||
namespace: tigera-operator
|
||||
data:
|
||||
KUBERNETES_SERVICE_HOST: '{{ apiserver_endpoint }}'
|
||||
KUBERNETES_SERVICE_PORT: '6443'
|
||||
{% endif %}
|
||||
@@ -0,0 +1,29 @@
|
||||
apiVersion: "cilium.io/v2alpha1"
|
||||
kind: CiliumBGPPeeringPolicy
|
||||
metadata:
|
||||
name: 01-bgp-peering-policy
|
||||
spec: # CiliumBGPPeeringPolicySpec
|
||||
virtualRouters: # []CiliumBGPVirtualRouter
|
||||
- localASN: {{ cilium_bgp_my_asn }}
|
||||
exportPodCIDR: {{ cilium_exportPodCIDR | default('true') }}
|
||||
neighbors: # []CiliumBGPNeighbor
|
||||
- peerAddress: '{{ cilium_bgp_peer_address + "/32"}}'
|
||||
peerASN: {{ cilium_bgp_peer_asn }}
|
||||
eBGPMultihopTTL: 10
|
||||
connectRetryTimeSeconds: 120
|
||||
holdTimeSeconds: 90
|
||||
keepAliveTimeSeconds: 30
|
||||
gracefulRestart:
|
||||
enabled: true
|
||||
restartTimeSeconds: 120
|
||||
serviceSelector:
|
||||
matchExpressions:
|
||||
- {key: somekey, operator: NotIn, values: ['never-used-value']}
|
||||
---
|
||||
apiVersion: "cilium.io/v2alpha1"
|
||||
kind: CiliumLoadBalancerIPPool
|
||||
metadata:
|
||||
name: "01-lb-pool"
|
||||
spec:
|
||||
cidrs:
|
||||
- cidr: "{{ cilium_bgp_lb_cidr }}"
|
||||
@@ -14,7 +14,7 @@
|
||||
name: net.ipv4.ip_forward
|
||||
value: "1"
|
||||
state: present
|
||||
reload: yes
|
||||
reload: true
|
||||
tags: sysctl
|
||||
|
||||
- name: Enable IPv6 forwarding
|
||||
@@ -22,7 +22,7 @@
|
||||
name: net.ipv6.conf.all.forwarding
|
||||
value: "1"
|
||||
state: present
|
||||
reload: yes
|
||||
reload: true
|
||||
tags: sysctl
|
||||
|
||||
- name: Enable IPv6 router advertisements
|
||||
@@ -30,7 +30,7 @@
|
||||
name: net.ipv6.conf.all.accept_ra
|
||||
value: "2"
|
||||
state: present
|
||||
reload: yes
|
||||
reload: true
|
||||
tags: sysctl
|
||||
|
||||
- name: Add br_netfilter to /etc/modules-load.d/
|
||||
@@ -51,7 +51,7 @@
|
||||
name: "{{ item }}"
|
||||
value: "1"
|
||||
state: present
|
||||
reload: yes
|
||||
reload: true
|
||||
when: ansible_os_family == "RedHat"
|
||||
loop:
|
||||
- net.bridge.bridge-nf-call-iptables
|
||||
|
||||
@@ -17,21 +17,27 @@
|
||||
when:
|
||||
grep_cpuinfo_raspberrypi.rc == 0 or grep_device_tree_model_raspberrypi.rc == 0
|
||||
|
||||
- name: Set detected_distribution to Raspbian
|
||||
- name: Set detected_distribution to Raspbian (ARM64 on Raspbian, Debian Buster/Bullseye/Bookworm)
|
||||
set_fact:
|
||||
detected_distribution: Raspbian
|
||||
when: >
|
||||
raspberry_pi|default(false) and
|
||||
( ansible_facts.lsb.id|default("") == "Raspbian" or
|
||||
ansible_facts.lsb.description|default("") is match("[Rr]aspbian.*") )
|
||||
vars:
|
||||
allowed_descriptions:
|
||||
- "[Rr]aspbian.*"
|
||||
- "Debian.*buster"
|
||||
- "Debian.*bullseye"
|
||||
- "Debian.*bookworm"
|
||||
when:
|
||||
- ansible_facts.architecture is search("aarch64")
|
||||
- raspberry_pi|default(false)
|
||||
- ansible_facts.lsb.description|default("") is match(allowed_descriptions | join('|'))
|
||||
|
||||
- name: Set detected_distribution to Raspbian (ARM64 on Debian Buster)
|
||||
- name: Set detected_distribution to Raspbian (ARM64 on Debian Bookworm)
|
||||
set_fact:
|
||||
detected_distribution: Raspbian
|
||||
when:
|
||||
- ansible_facts.architecture is search("aarch64")
|
||||
- raspberry_pi|default(false)
|
||||
- ansible_facts.lsb.description|default("") is match("Debian.*buster")
|
||||
- ansible_facts.lsb.description|default("") is match("Debian.*bookworm")
|
||||
|
||||
- name: Set detected_distribution_major_version
|
||||
set_fact:
|
||||
@@ -39,14 +45,6 @@
|
||||
when:
|
||||
- detected_distribution | default("") == "Raspbian"
|
||||
|
||||
- name: Set detected_distribution to Raspbian (ARM64 on Debian Bullseye)
|
||||
set_fact:
|
||||
detected_distribution: Raspbian
|
||||
when:
|
||||
- ansible_facts.architecture is search("aarch64")
|
||||
- raspberry_pi|default(false)
|
||||
- ansible_facts.lsb.description|default("") is match("Debian.*bullseye")
|
||||
|
||||
- name: Execute OS related tasks on the Raspberry Pi - {{ action_ }}
|
||||
include_tasks: "{{ item }}"
|
||||
with_first_found:
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
- name: Enable cgroup via boot commandline if not already enabled for Rocky
|
||||
lineinfile:
|
||||
path: /boot/cmdline.txt
|
||||
backrefs: yes
|
||||
backrefs: true
|
||||
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$'
|
||||
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
|
||||
notify: reboot
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
- name: Enable cgroup via boot commandline if not already enabled for Ubuntu on a Raspberry Pi
|
||||
lineinfile:
|
||||
path: /boot/firmware/cmdline.txt
|
||||
backrefs: yes
|
||||
backrefs: true
|
||||
regexp: '^((?!.*\bcgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory\b).*)$'
|
||||
line: '\1 cgroup_enable=cpuset cgroup_memory=1 cgroup_enable=memory'
|
||||
notify: reboot
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
systemd:
|
||||
name: "{{ item }}"
|
||||
state: stopped
|
||||
enabled: no
|
||||
enabled: false
|
||||
failed_when: false
|
||||
with_items:
|
||||
- k3s
|
||||
@@ -45,19 +45,22 @@
|
||||
- /var/lib/rancher/k3s
|
||||
- /var/lib/rancher/
|
||||
- /var/lib/cni/
|
||||
- /etc/cni/net.d
|
||||
|
||||
- name: Remove K3s http_proxy files
|
||||
file:
|
||||
name: "{{ item }}"
|
||||
state: absent
|
||||
with_items:
|
||||
- "{{ systemd_dir }}/k3s.service.d/http_proxy.conf"
|
||||
- "{{ systemd_dir }}/k3s.service.d"
|
||||
- "{{ systemd_dir }}/k3s-node.service.d/http_proxy.conf"
|
||||
- "{{ systemd_dir }}/k3s-node.service.d"
|
||||
when: proxy_env is defined
|
||||
|
||||
- name: Reload daemon_reload
|
||||
systemd:
|
||||
daemon_reload: yes
|
||||
daemon_reload: true
|
||||
|
||||
- name: Remove tmp directory used for manifests
|
||||
file:
|
||||
|
||||
Reference in New Issue
Block a user