Refactor based on comments

This commit is contained in:
Ethan Shold
2024-01-26 01:09:36 -06:00
parent e1b34d2395
commit 68f1674b50
9 changed files with 29 additions and 25 deletions
+6 -1
View File
@@ -35,7 +35,12 @@ k3s_version: ""
ansible_user: NA ansible_user: NA
systemd_dir: "" systemd_dir: ""
container_iface: "" flannel_iface: ""
#calico_iface: ""
calico_ebpf: ""
calico_cidr: ""
calico_tag: ""
apiserver_endpoint: "" apiserver_endpoint: ""
+9 -10
View File
@@ -7,14 +7,13 @@ systemd_dir: /etc/systemd/system
# Set your timezone # Set your timezone
system_timezone: "Your/Timezone" system_timezone: "Your/Timezone"
# node interface which will be used for the container network interface (flannel or calico) # interface which will be used for flannel
container_iface: "eth0" flannel_iface: "eth0"
# set use_calico to true to use tigera operator/calico instead of the default CNI flannel # uncomment calico_iface to use tigera operator/calico cni instead of flannel https://docs.tigera.io/calico/latest/about
# install reference: https://docs.tigera.io/calico/latest/getting-started/kubernetes/k3s/multi-node-install#install-calico #calico_iface: "eth0"
use_calico: false
calico_ebpf: false # use eBPF dataplane instead of iptables https://docs.tigera.io/calico/latest/operations/ebpf calico_ebpf: false # use eBPF dataplane instead of iptables https://docs.tigera.io/calico/latest/operations/ebpf
calico_cidr: "10.52.0.0/16" # pod cidr pool calico_cidr: "10.52.0.0/16" # calico cluster pod cidr pool
calico_tag: "v3.27.0" # calico version tag calico_tag: "v3.27.0" # calico version tag
# apiserver_endpoint is virtual ip-address which will be configured on each master # apiserver_endpoint is virtual ip-address which will be configured on each master
@@ -27,14 +26,14 @@ k3s_token: "some-SUPER-DEDEUPER-secret-password"
# The IP on which the node is reachable in the cluster. # The IP on which the node is reachable in the cluster.
# Here, a sensible default is provided, you can still override # Here, a sensible default is provided, you can still override
# it for each of your hosts, though. # it for each of your hosts, though.
k3s_node_ip: '{{ ansible_facts[container_iface]["ipv4"]["address"] }}' k3s_node_ip: "{{ ansible_facts[(calico_iface | default(flannel_iface))]['ipv4']['address'] }}"
# Disable the taint manually by setting: k3s_master_taint = false # Disable the taint manually by setting: k3s_master_taint = false
k3s_master_taint: "{{ true if groups['node'] | default([]) | length >= 1 else false }}" k3s_master_taint: "{{ true if groups['node'] | default([]) | length >= 1 else false }}"
# these arguments are recommended for servers as well as agents: # these arguments are recommended for servers as well as agents:
extra_args: >- extra_args: >-
{{ '--flannel-iface=' + container_iface if not use_calico else '' }} {{ '--flannel-iface=' + flannel_iface if calico_iface is not defined else '' }}
--node-ip={{ k3s_node_ip }} --node-ip={{ k3s_node_ip }}
# change these to your liking, the only required are: --disable servicelb, --tls-san {{ apiserver_endpoint }} # change these to your liking, the only required are: --disable servicelb, --tls-san {{ apiserver_endpoint }}
@@ -42,10 +41,10 @@ extra_args: >-
extra_server_args: >- extra_server_args: >-
{{ extra_args }} {{ extra_args }}
{{ '--node-taint node-role.kubernetes.io/master=true:NoSchedule' if k3s_master_taint else '' }} {{ '--node-taint node-role.kubernetes.io/master=true:NoSchedule' if k3s_master_taint else '' }}
{% if use_calico %} {% if calico_iface is defined %}
--flannel-backend=none --flannel-backend=none
--disable-network-policy --disable-network-policy
--cluster-cidr={{ calico_cidr }} --cluster-cidr={{ calico_cidr | default('10.52.0.0/16') }}
{% endif %} {% endif %}
--tls-san {{ apiserver_endpoint }} --tls-san {{ apiserver_endpoint }}
--disable servicelb --disable servicelb
+1 -1
View File
@@ -6,7 +6,7 @@
ansible.builtin.set_fact: ansible.builtin.set_fact:
# See: # See:
# https://github.com/flannel-io/flannel/blob/67d603aaf45ef80f5dd39f43714fc5e6f8a637eb/Documentation/troubleshooting.md#Vagrant # https://github.com/flannel-io/flannel/blob/67d603aaf45ef80f5dd39f43714fc5e6f8a637eb/Documentation/troubleshooting.md#Vagrant
container_iface: eth1 flannel_iface: eth1
# The test VMs might be a bit slow, so we give them more time to join the cluster: # The test VMs might be a bit slow, so we give them more time to join the cluster:
retry_count: 45 retry_count: 45
+3 -3
View File
@@ -6,7 +6,7 @@
ansible.builtin.set_fact: ansible.builtin.set_fact:
# See: # See:
# https://github.com/flannel-io/flannel/blob/67d603aaf45ef80f5dd39f43714fc5e6f8a637eb/Documentation/troubleshooting.md#Vagrant # https://github.com/flannel-io/flannel/blob/67d603aaf45ef80f5dd39f43714fc5e6f8a637eb/Documentation/troubleshooting.md#Vagrant
container_iface: eth1 flannel_iface: eth1
# In this scenario, we have multiple interfaces that the VIP could be # In this scenario, we have multiple interfaces that the VIP could be
# broadcasted on. Since we have assigned a dedicated private network # broadcasted on. Since we have assigned a dedicated private network
@@ -27,13 +27,13 @@
- fdad:bad:ba55::1b:0/112 - fdad:bad:ba55::1b:0/112
- 192.168.123.80-192.168.123.90 - 192.168.123.80-192.168.123.90
# k3s_node_ip is by default set to the IPv4 address of container_iface. # k3s_node_ip is by default set to the IPv4 address of flannel_iface.
# We want IPv6 addresses here of course, so we just specify them # We want IPv6 addresses here of course, so we just specify them
# manually below. # manually below.
k3s_node_ip: "{{ node_ipv4 }},{{ node_ipv6 }}" k3s_node_ip: "{{ node_ipv4 }},{{ node_ipv6 }}"
- name: Override host variables (2/2) - name: Override host variables (2/2)
# Since "extra_args" depends on "k3s_node_ip" and "container_iface" we have # Since "extra_args" depends on "k3s_node_ip" and "flannel_iface" we have
# to set this AFTER overriding the both of them. # to set this AFTER overriding the both of them.
ansible.builtin.set_fact: ansible.builtin.set_fact:
# A few extra server args are necessary: # A few extra server args are necessary:
+1 -1
View File
@@ -30,7 +30,7 @@
name: net.ipv6.conf.{{ item }}.accept_dad name: net.ipv6.conf.{{ item }}.accept_dad
value: "0" value: "0"
with_items: with_items:
- "{{ container_iface }}" - "{{ flannel_iface }}"
- name: Write IPv4 configuration - name: Write IPv4 configuration
ansible.builtin.template: ansible.builtin.template:
@@ -3,6 +3,6 @@ network:
version: 2 version: 2
renderer: networkd renderer: networkd
ethernets: ethernets:
{{ container_iface }}: {{ flannel_iface }}:
addresses: addresses:
- {{ node_ipv4 }}/24 - {{ node_ipv4 }}/24
+1 -1
View File
@@ -6,7 +6,7 @@
ansible.builtin.set_fact: ansible.builtin.set_fact:
# See: # See:
# https://github.com/flannel-io/flannel/blob/67d603aaf45ef80f5dd39f43714fc5e6f8a637eb/Documentation/troubleshooting.md#Vagrant # https://github.com/flannel-io/flannel/blob/67d603aaf45ef80f5dd39f43714fc5e6f8a637eb/Documentation/troubleshooting.md#Vagrant
container_iface: eth1 flannel_iface: eth1
# The test VMs might be a bit slow, so we give them more time to join the cluster: # The test VMs might be a bit slow, so we give them more time to join the cluster:
retry_count: 45 retry_count: 45
+1 -1
View File
@@ -2,7 +2,7 @@
- name: Deploy calico - name: Deploy calico
include_tasks: calico.yml include_tasks: calico.yml
tags: calico tags: calico
when: use_calico == true when: calico_iface is defined
- name: Deploy metallb pool - name: Deploy metallb pool
include_tasks: metallb.yml include_tasks: metallb.yml
@@ -9,13 +9,13 @@ spec:
calicoNetwork: calicoNetwork:
# Note: The ipPools section cannot be modified post-install. # Note: The ipPools section cannot be modified post-install.
ipPools: ipPools:
- blockSize: {{ calico_blockSize if calico_blockSize is defined else '26' }} - blockSize: {{ calico_blockSize | default('26') }}
cidr: {{ calico_cidr if calico_cidr is defined else '10.52.0.0/16' }} cidr: {{ calico_cidr | default('10.52.0.0/16') }}
encapsulation: {{ calico_encapsulation if calico_encapsulation is defined else 'VXLANCrossSubnet' }} encapsulation: {{ calico_encapsulation | default('VXLANCrossSubnet') }}
natOutgoing: {{ calico_natOutgoing if calico_natOutgoing is defined else 'Enabled' }} natOutgoing: {{ calico_natOutgoing | default('Enabled') }}
nodeSelector: {{ calico_nodeSelector if calico_nodeSelector is defined else 'all()' }} nodeSelector: {{ calico_nodeSelector | default('all()') }}
nodeAddressAutodetectionV4: nodeAddressAutodetectionV4:
interface: {{ container_iface if container_iface is defined else 'eth0' }} interface: {{ calico_iface }}
linuxDataplane: {{ 'BPF' if calico_ebpf else 'Iptables' }} linuxDataplane: {{ 'BPF' if calico_ebpf else 'Iptables' }}
--- ---