Compare commits
23
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
1ede3d3329 | ||
|
|
deb3521bfa | ||
|
|
c8cac22d12 | ||
|
|
6fe03c5f70 | ||
|
|
15b4e54bd5 | ||
|
|
c016459922 | ||
|
|
4d1725f17f | ||
|
|
80658c632f | ||
|
|
60b67f748e | ||
|
|
4a76aa3a2e | ||
|
|
e9f1153482 | ||
|
|
ca1fcc16b6 | ||
|
|
fb94fd5997 | ||
|
|
713d38d77d | ||
|
|
bc71066de1 | ||
|
|
5eae9ca348 | ||
|
|
844e017f9e | ||
|
|
381f3ab7c9 | ||
|
|
6390e6288b | ||
|
|
13d60c4f9b | ||
|
|
cb09f77b68 | ||
|
|
84fd52b678 | ||
|
|
c7eceae087 |
@@ -5,3 +5,8 @@
|
|||||||
systemd:
|
systemd:
|
||||||
name: systemd-journald
|
name: systemd-journald
|
||||||
state: restarted
|
state: restarted
|
||||||
|
|
||||||
|
- name: restart_fail2ban
|
||||||
|
systemd:
|
||||||
|
name: fail2ban
|
||||||
|
state: restarted
|
||||||
|
|||||||
@@ -1,3 +1,9 @@
|
|||||||
|
- name: Ensure .bashrc exists
|
||||||
|
file:
|
||||||
|
path: "{{ ansible_facts.env.HOME }}/.bashrc"
|
||||||
|
state: touch
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
- name: General aliases
|
- name: General aliases
|
||||||
blockinfile:
|
blockinfile:
|
||||||
path: "{{ ansible_facts.env.HOME }}/.bashrc"
|
path: "{{ ansible_facts.env.HOME }}/.bashrc"
|
||||||
@@ -8,11 +14,26 @@
|
|||||||
alias syslog="tail -f --lines=100 /var/log/syslog"
|
alias syslog="tail -f --lines=100 /var/log/syslog"
|
||||||
alias cp="rsync -hlAXEptgoDS --numeric-ids --info=progress2"
|
alias cp="rsync -hlAXEptgoDS --numeric-ids --info=progress2"
|
||||||
|
|
||||||
|
# We can tell bash to check the next word after the alias (i.e sudo) by adding a space to the end of the alias value. https://askubuntu.com/questions/22037/aliases-not-available-when-using-sudo
|
||||||
|
alias sudo='sudo '
|
||||||
|
|
||||||
- name: ls aliases and colors
|
- name: ls aliases and colors
|
||||||
blockinfile:
|
blockinfile:
|
||||||
path: "{{ ansible_facts.env.HOME }}/.bashrc"
|
path: "{{ ansible_facts.env.HOME }}/.bashrc"
|
||||||
marker: "# {mark} ANSIBLE MANAGED BLOCK | ls aliases and colors"
|
marker: "# {mark} ANSIBLE MANAGED BLOCK | ls aliases and colors"
|
||||||
block: |
|
block: |
|
||||||
|
# enable color support of ls and also add handy aliases
|
||||||
|
if [ -x /usr/bin/dircolors ]; then
|
||||||
|
test -r ~/.dircolors && eval "$(dircolors -b ~/.dircolors)" || eval "$(dircolors -b)"
|
||||||
|
alias ls='ls --color=auto'
|
||||||
|
#alias dir='dir --color=auto'
|
||||||
|
#alias vdir='vdir --color=auto'
|
||||||
|
|
||||||
|
alias grep='grep --color=auto'
|
||||||
|
alias fgrep='fgrep --color=auto'
|
||||||
|
alias egrep='egrep --color=auto'
|
||||||
|
fi
|
||||||
|
|
||||||
export LS_OPTIONS='--color=auto'
|
export LS_OPTIONS='--color=auto'
|
||||||
eval "`dircolors`"
|
eval "`dircolors`"
|
||||||
alias ls='ls $LS_OPTIONS'
|
alias ls='ls $LS_OPTIONS'
|
||||||
|
|||||||
@@ -0,0 +1,9 @@
|
|||||||
|
# Debian 12+ ships no syslog daemon, so there is no /var/log/auth.log and the
|
||||||
|
# file-based sshd jail refuses to start; read sshd from the journal instead.
|
||||||
|
- name: Read the sshd jail from the journal
|
||||||
|
copy:
|
||||||
|
dest: /etc/fail2ban/jail.d/sshd-systemd.conf
|
||||||
|
content: |
|
||||||
|
[sshd]
|
||||||
|
backend = systemd
|
||||||
|
notify: restart_fail2ban
|
||||||
@@ -1,5 +1,7 @@
|
|||||||
- import_tasks: ./packages.yml
|
- import_tasks: ./packages.yml
|
||||||
|
|
||||||
|
- import_tasks: ./fail2ban.yml
|
||||||
|
|
||||||
- import_tasks: ./ssh.yml
|
- import_tasks: ./ssh.yml
|
||||||
|
|
||||||
- import_tasks: ./packages.yml
|
- import_tasks: ./packages.yml
|
||||||
|
|||||||
@@ -6,13 +6,40 @@
|
|||||||
net.ipv6.conf.all.forwarding = 1
|
net.ipv6.conf.all.forwarding = 1
|
||||||
notify: reload_sysctl
|
notify: reload_sysctl
|
||||||
|
|
||||||
|
- name: Check if the sysctl configuration file exists
|
||||||
|
stat:
|
||||||
|
path: "/etc/sysctl.d/ipv6-slaac-address-generation.conf"
|
||||||
|
register: sysctl_conf
|
||||||
|
|
||||||
|
- block:
|
||||||
|
# - name: Generate IPv6 stable-secret segments
|
||||||
|
# set_fact:
|
||||||
|
# stable_secret_segments: "{{ stable_secret_segments | default() + '%0x' | format(range(0, 2**(16*2)) | random(seed=ipv6_stable_secret_seed+inventory_hostname+(stable_secret_segments | default()))) }}"
|
||||||
|
# loop: "{{ range(4) }}"
|
||||||
|
|
||||||
|
# - name: Format IPv6 stable-secret segments
|
||||||
|
# set_fact:
|
||||||
|
# ipv6_stable_secret: "{{ stable_secret_segments | regex_replace('(.{4})(?=.)', '\\1:') }}"
|
||||||
|
|
||||||
|
- name: Generate random IPv6 stable-secret
|
||||||
|
set_fact:
|
||||||
|
ipv6_stable_secret: "{{ 'fd' + (lookup('password', '/dev/null length=30 chars=hex')).split('.')[0][:7] + '::' + (lookup('password', '/dev/null length=4 chars=hex')) }}"
|
||||||
|
|
||||||
- name: Set sysctl settings for ipv6-address-generation
|
- name: Set sysctl settings for ipv6-address-generation
|
||||||
copy:
|
copy:
|
||||||
dest: "/etc/sysctl.d/ipv6-slaac-address-generation.conf"
|
dest: "/etc/sysctl.d/ipv6-slaac-address-generation.conf"
|
||||||
content: |
|
content: |
|
||||||
net.ipv6.conf.default.addr_gen_mode = 2
|
{% if ansible_facts.default_ipv6.interface is defined %}
|
||||||
net.ipv6.conf.default.stable_secret = {{ ipv6_stable_secret }}
|
net.ipv6.conf.{{ ansible_facts.default_ipv6.interface }}.addr_gen_mode = 2
|
||||||
|
net.ipv6.conf.{{ ansible_facts.default_ipv6.interface }}.stable_secret = {{ ipv6_stable_secret }}
|
||||||
|
{% else %}
|
||||||
|
net.ipv6.conf.{{ ansible_facts.default_ipv4.interface }}.addr_gen_mode = 2
|
||||||
|
net.ipv6.conf.{{ ansible_facts.default_ipv4.interface }}.stable_secret = {{ ipv6_stable_secret }}
|
||||||
|
{% endif %}
|
||||||
notify: reload_sysctl
|
notify: reload_sysctl
|
||||||
|
when:
|
||||||
|
- ansible_facts.default_ipv6 is defined
|
||||||
|
- not sysctl_conf.stat.exists
|
||||||
|
|
||||||
- name: Set sysctl settings to override ipv6-slaac with enabled forwarding
|
- name: Set sysctl settings to override ipv6-slaac with enabled forwarding
|
||||||
copy:
|
copy:
|
||||||
@@ -20,3 +47,13 @@
|
|||||||
content: |
|
content: |
|
||||||
net.ipv6.conf.all.accept_ra = 2
|
net.ipv6.conf.all.accept_ra = 2
|
||||||
notify: reload_sysctl
|
notify: reload_sysctl
|
||||||
|
|
||||||
|
- name: Set sysctl settings for TCP BBR
|
||||||
|
copy:
|
||||||
|
dest: "/etc/sysctl.d/tcp-bbr.conf"
|
||||||
|
content: |
|
||||||
|
net.core.default_qdisc = fq
|
||||||
|
net.ipv4.tcp_congestion_control = bbr
|
||||||
|
when:
|
||||||
|
- ansible_kernel is version('4.9', '>=')
|
||||||
|
notify: reload_sysctl
|
||||||
|
|||||||
@@ -2,7 +2,6 @@
|
|||||||
apt:
|
apt:
|
||||||
update_cache: yes
|
update_cache: yes
|
||||||
upgrade: yes
|
upgrade: yes
|
||||||
when: ansible_facts.distribution == "Debian"
|
|
||||||
|
|
||||||
- name: Install Packages
|
- name: Install Packages
|
||||||
package:
|
package:
|
||||||
@@ -11,10 +10,11 @@
|
|||||||
- htop
|
- htop
|
||||||
- iotop
|
- iotop
|
||||||
- slurm
|
- slurm
|
||||||
|
- nmon
|
||||||
- sudo
|
- sudo
|
||||||
- screen
|
- screen
|
||||||
- curl
|
- curl
|
||||||
- rsync
|
- rsync
|
||||||
- zstd
|
- zstd
|
||||||
|
- fail2ban
|
||||||
state: latest
|
state: latest
|
||||||
when: ansible_facts.distribution == "Debian"
|
|
||||||
|
|||||||
@@ -1,3 +1,10 @@
|
|||||||
|
- name: Check if SSH daemon is active
|
||||||
|
systemd:
|
||||||
|
name: sshd
|
||||||
|
state: started
|
||||||
|
register: sshd_status
|
||||||
|
|
||||||
|
- block:
|
||||||
- name: Disable SSH password auth
|
- name: Disable SSH password auth
|
||||||
lineinfile:
|
lineinfile:
|
||||||
dest: /etc/ssh/sshd_config
|
dest: /etc/ssh/sshd_config
|
||||||
@@ -10,3 +17,4 @@
|
|||||||
name: sshd
|
name: sshd
|
||||||
state: restarted
|
state: restarted
|
||||||
when: sshd_config.changed
|
when: sshd_config.changed
|
||||||
|
when: sshd_status.status.ActiveState == 'active'
|
||||||
|
|||||||
@@ -7,7 +7,7 @@ kubernetes:
|
|||||||
service_cidr: 10.43.0.0/16
|
service_cidr: 10.43.0.0/16
|
||||||
ipv6:
|
ipv6:
|
||||||
# Minimum: /120
|
# Minimum: /120
|
||||||
cluster_cidr: fd42::/56
|
cluster_cidr: fd42::/112
|
||||||
service_cidr: fd43::/112
|
service_cidr: fd43::/112
|
||||||
|
|
||||||
# Interface to grab node-IPv4/v6 from
|
# Interface to grab node-IPv4/v6 from
|
||||||
@@ -19,7 +19,11 @@ kubernetes:
|
|||||||
token: <shared token for nodes to join>
|
token: <shared token for nodes to join>
|
||||||
|
|
||||||
network:
|
network:
|
||||||
# One of [flannel, calico]
|
# Copies the current /etc/resolv.conf whilst only keeping "nameserver" lines
|
||||||
|
# can be used to remove filter
|
||||||
|
clean_resolv_conf: false
|
||||||
|
|
||||||
|
# One of [none, flannel, calico, cilium]
|
||||||
plugin: calico
|
plugin: calico
|
||||||
|
|
||||||
# Helper for networking
|
# Helper for networking
|
||||||
@@ -29,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
|
||||||
@@ -48,3 +52,14 @@ kubernetes:
|
|||||||
etcd-arg:
|
etcd-arg:
|
||||||
heartbeat-interval: 500
|
heartbeat-interval: 500
|
||||||
election-timeout: 5000
|
election-timeout: 5000
|
||||||
|
|
||||||
|
registries_config:
|
||||||
|
# Defines the names and endpoints of registries
|
||||||
|
# When embedded-registry is enabled, every registry needs to be defined here to allow this node to distribute those images.
|
||||||
|
#mirrors:
|
||||||
|
# Enable distribution for all registries
|
||||||
|
#"*": {}
|
||||||
|
|
||||||
|
# Defines authentication and extra settings for the registries
|
||||||
|
#config:
|
||||||
|
|
||||||
@@ -1,3 +1,3 @@
|
|||||||
---
|
---
|
||||||
dependencies:
|
#dependencies:
|
||||||
- role: docker
|
# - role: docker
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
ansible.builtin.file:
|
ansible.builtin.file:
|
||||||
path: /etc/rancher/k3s/
|
path: /etc/rancher/k3s/
|
||||||
state: directory
|
state: directory
|
||||||
mode: '0755'
|
mode: "0755"
|
||||||
|
|
||||||
- name: Read the live k3s config
|
- name: Read the live k3s config
|
||||||
slurp:
|
slurp:
|
||||||
@@ -33,14 +33,33 @@
|
|||||||
get_url:
|
get_url:
|
||||||
url: https://get.k3s.io
|
url: https://get.k3s.io
|
||||||
dest: /root/k3s_install.sh
|
dest: /root/k3s_install.sh
|
||||||
mode: '744'
|
mode: "744"
|
||||||
# todo: update when file changed?
|
# todo: update when file changed?
|
||||||
|
|
||||||
|
- name: Read the live registries.yaml
|
||||||
|
slurp:
|
||||||
|
src: /etc/rancher/k3s/registries.yaml
|
||||||
|
register: live_registries
|
||||||
|
failed_when: false
|
||||||
|
when: "type == 'server'"
|
||||||
|
|
||||||
|
# Written only on a change k3s would see, like config.yaml
|
||||||
|
- name: Deploy registries.yaml
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: k3s/server/registries.yaml.j2
|
||||||
|
dest: /etc/rancher/k3s/registries.yaml
|
||||||
|
register: registries_config
|
||||||
|
when:
|
||||||
|
- "type == 'server'"
|
||||||
|
- >-
|
||||||
|
live_registries.content is not defined or
|
||||||
|
(live_registries.content | b64decode | from_yaml) != (lookup('template', 'k3s/server/registries.yaml.j2') | from_yaml)
|
||||||
|
|
||||||
- import_tasks: ./install/server/setup_network.yml
|
- import_tasks: ./install/server/setup_network.yml
|
||||||
when: "type == 'server'"
|
when: "type == 'server'"
|
||||||
|
|
||||||
- import_tasks: ./install/server/install_helm.yml
|
#- import_tasks: ./install/server/install_helm.yml
|
||||||
when: "type == 'server'"
|
# when: "type == 'server'"
|
||||||
|
|
||||||
- import_tasks: ./install/server/install_k3s.yml
|
- import_tasks: ./install/server/install_k3s.yml
|
||||||
when: "type == 'server'"
|
when: "type == 'server'"
|
||||||
|
|||||||
@@ -1,33 +1,10 @@
|
|||||||
- name: Install K3s-server for 1st-node
|
- block:
|
||||||
|
- name: Install K3s-server
|
||||||
command: /root/k3s_install.sh {{ type }}
|
command: /root/k3s_install.sh {{ type }}
|
||||||
environment:
|
environment:
|
||||||
|
INSTALL_K3S_CHANNEL: latest
|
||||||
INSTALL_K3S_VERSION: "{{ kubernetes.version }}"
|
INSTALL_K3S_VERSION: "{{ kubernetes.version }}"
|
||||||
when:
|
when: k3s_installed.rc != 0 or (kubernetes.version != '' and ('k3s version ' ~ kubernetes.version ~ ' ') not in k3s_installed.stdout)
|
||||||
- "inventory_hostname == groups['kubernetes'][0]"
|
|
||||||
- k3s_installed.rc != 0 or (kubernetes.version != '' and ('k3s version ' ~ kubernetes.version ~ ' ') not in k3s_installed.stdout)
|
|
||||||
register: command
|
|
||||||
changed_when: "'No change detected' not in command.stdout"
|
|
||||||
|
|
||||||
- name: Make sure service is started / restarted on config change
|
|
||||||
service:
|
|
||||||
name: k3s
|
|
||||||
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:
|
|
||||||
host: "{{ inventory_hostname }}"
|
|
||||||
port: 6443
|
|
||||||
state: started
|
|
||||||
when: "inventory_hostname == groups['kubernetes'][0]"
|
|
||||||
|
|
||||||
- name: Install K3s-server for other nodes
|
|
||||||
command: /root/k3s_install.sh {{ type }}
|
|
||||||
environment:
|
|
||||||
INSTALL_K3S_VERSION: "{{ kubernetes.version }}"
|
|
||||||
when:
|
|
||||||
- "inventory_hostname != groups['kubernetes'][0]"
|
|
||||||
- k3s_installed.rc != 0 or (kubernetes.version != '' and ('k3s version ' ~ kubernetes.version ~ ' ') not in k3s_installed.stdout)
|
|
||||||
register: command
|
register: command
|
||||||
changed_when: "'No change detected' not in command.stdout"
|
changed_when: "'No change detected' not in command.stdout"
|
||||||
until: "command is not failed"
|
until: "command is not failed"
|
||||||
@@ -37,27 +14,37 @@
|
|||||||
- name: Make sure service is started / restarted on config change
|
- name: Make sure service is started / restarted on config change
|
||||||
service:
|
service:
|
||||||
name: k3s
|
name: k3s
|
||||||
state: "{{ 'restarted' if not command.changed and config.changed else 'started' }}"
|
enabled: true
|
||||||
when: "inventory_hostname != groups['kubernetes'][0]"
|
state: "{{ 'restarted' if not command.changed and (config.changed or registries_config.changed) else 'started' }}"
|
||||||
|
|
||||||
- name: Waiting for K3s-server to accept connections on other nodes
|
- name: Waiting for K3s-server to accept connections
|
||||||
ansible.builtin.wait_for:
|
ansible.builtin.wait_for:
|
||||||
host: "{{ inventory_hostname }}"
|
host: "{{ inventory_hostname }}"
|
||||||
port: 6443
|
port: 6443
|
||||||
state: started
|
state: started
|
||||||
when: "inventory_hostname != groups['kubernetes'][0]"
|
throttle: 1
|
||||||
|
|
||||||
#- name: Add Kubernetes environment-vars to /etc/profile.d/
|
- name: Ensure the .kube directory exists
|
||||||
# blockinfile:
|
file:
|
||||||
# path: /etc/profile.d/k3s-bin.sh
|
path: "~/.kube"
|
||||||
# marker: "# {mark} ANSIBLE MANAGED BLOCK | k3s"
|
state: directory
|
||||||
# block: |
|
mode: "0755"
|
||||||
# export KUBECONFIG="/etc/rancher/k3s/k3s.yaml"
|
|
||||||
# create: true
|
- name: Create symbolic link for k3s.yaml
|
||||||
|
file:
|
||||||
|
src: "/etc/rancher/k3s/k3s.yaml"
|
||||||
|
dest: "~/.kube/config"
|
||||||
|
state: link
|
||||||
|
|
||||||
- name: Deploy calico
|
- name: Deploy calico
|
||||||
import_tasks: ./roles/kubernetes/tasks/install/server/network-plugin/deploy_calico.yml
|
import_tasks: ./roles/kubernetes/tasks/install/server/network-plugin/deploy_calico.yml
|
||||||
when: "kubernetes.network.plugin == 'calico'"
|
when:
|
||||||
|
- "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
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
- name: Deploy calico operator
|
- name: Deploy calico operator
|
||||||
command: kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.25.0/manifests/tigera-operator.yaml
|
command: kubectl create -f https://raw.githubusercontent.com/projectcalico/calico/v3.28.0/manifests/tigera-operator.yaml
|
||||||
register: command
|
register: command
|
||||||
changed_when: "'created' in command.stdout"
|
changed_when: "'created' in command.stdout"
|
||||||
run_once: true
|
run_once: true
|
||||||
|
|||||||
@@ -0,0 +1,71 @@
|
|||||||
|
- name: Check if already installed in cluster
|
||||||
|
command: "cilium status"
|
||||||
|
register: cilium_status
|
||||||
|
ignore_errors: true
|
||||||
|
changed_when: false
|
||||||
|
check_mode: false
|
||||||
|
run_once: true
|
||||||
|
|
||||||
|
- name: Check if the Cilium CLI is installed
|
||||||
|
stat:
|
||||||
|
path: /usr/local/bin/cilium
|
||||||
|
register: cilium_cli
|
||||||
|
|
||||||
|
- 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
|
||||||
|
# An installed CLI is left alone, not upgraded to the latest release
|
||||||
|
when: cilium_cli_version.stdout is defined and not cilium_cli.stat.exists
|
||||||
|
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
|
||||||
@@ -3,4 +3,4 @@
|
|||||||
- import_tasks: ./node.yml
|
- import_tasks: ./node.yml
|
||||||
|
|
||||||
- import_tasks: ./install.yml
|
- import_tasks: ./install.yml
|
||||||
|
when: target_host is not defined or inventory_hostname == target_host
|
||||||
|
|||||||
@@ -35,8 +35,27 @@
|
|||||||
|
|
||||||
- name: Getting nodeIp-data from interface
|
- name: Getting nodeIp-data from interface
|
||||||
set_fact:
|
set_fact:
|
||||||
nodeip_ipv4: "{{ ansible_facts[ interface ].ipv4.address }}"
|
nodeip_ipv4: >-
|
||||||
nodeip_ipv6: "{{ ansible_facts[ interface ].ipv6[0].address if ansible_facts[ interface ].ipv6 is defined }}"
|
{{ (ansible_facts[interface].ipv4.address)
|
||||||
|
if (ansible_facts is defined and ansible_facts.get(interface) is defined and ansible_facts[interface].ipv4 is defined)
|
||||||
|
else (ansible_default_ipv4.address | default('')) }}
|
||||||
|
nodeip_ipv6: >-
|
||||||
|
{{ (ansible_facts[interface].ipv6[0].address)
|
||||||
|
if (ansible_facts is defined and ansible_facts.get(interface) is defined and ansible_facts[interface].ipv6 is defined and (ansible_facts[interface].ipv6 | length) > 0)
|
||||||
|
else (ansible_default_ipv6.address | default('')) }}
|
||||||
|
|
||||||
|
- block:
|
||||||
|
- name: Read resolv.conf
|
||||||
|
shell: "grep '^nameserver' /etc/resolv.conf"
|
||||||
|
register: nameserver_line
|
||||||
|
changed_when: false
|
||||||
|
check_mode: false
|
||||||
|
|
||||||
|
- name: Write /etc/resolv-k3s.conf with only nameservers
|
||||||
|
copy:
|
||||||
|
content: "{{ nameserver_line.stdout }}"
|
||||||
|
dest: /etc/resolv-k3s.conf
|
||||||
|
when: kubernetes.network.clean_resolv_conf is true
|
||||||
|
|
||||||
- name: Run handlers to reload configurations
|
- name: Run handlers to reload configurations
|
||||||
meta: flush_handlers
|
meta: flush_handlers
|
||||||
|
|||||||
@@ -1,12 +1,37 @@
|
|||||||
|
{% set disabled_components = [] %}
|
||||||
|
|
||||||
|
## Base ##
|
||||||
|
node-name: {{ ansible_fqdn }}
|
||||||
|
# Join cluster
|
||||||
server: https://{{ hostvars[groups['kubernetes'][0]]['nodeip_ipv4'] }}:6443
|
server: https://{{ hostvars[groups['kubernetes'][0]]['nodeip_ipv4'] }}:6443
|
||||||
token: '{{ kubernetes.token }}'
|
token: '{{ kubernetes.token }}'
|
||||||
|
|
||||||
|
# Networking
|
||||||
|
{% if ansible_default_ipv6 is defined %}
|
||||||
|
node-external-ip: {{ ansible_default_ipv4.address }},{{ ansible_default_ipv6.address }}
|
||||||
|
{% else %}
|
||||||
|
node-external-ip: {{ ansible_default_ipv4.address }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if kubernetes.network.clean_resolv_conf %}
|
||||||
|
resolv-conf: /etc/resolv-k3s.conf
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% 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 }}
|
||||||
{% else %}
|
{% else %}
|
||||||
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:
|
||||||
@@ -16,3 +41,13 @@ node-label:
|
|||||||
{% if zone is defined %}
|
{% if zone is defined %}
|
||||||
- topology.kubernetes.io/zone={{ zone }}
|
- topology.kubernetes.io/zone={{ zone }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% for item in kubernetes.labels_extra %}
|
||||||
|
- {{ item }}
|
||||||
|
{% endfor %}
|
||||||
|
|
||||||
|
# Disabled components
|
||||||
|
{% if disabled_components %}
|
||||||
|
disable: {{ disabled_components | join(',') }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{{ kubernetes.config_extra | to_yaml }}
|
||||||
|
|||||||
@@ -1,8 +1,12 @@
|
|||||||
|
{% set disabled_components = [] %}
|
||||||
|
|
||||||
## Base ##
|
## Base ##
|
||||||
|
node-name: {{ ansible_fqdn }}
|
||||||
{% if inventory_hostname == groups['kubernetes'][0] %}
|
{% if inventory_hostname == groups['kubernetes'][0] %}
|
||||||
# Initialize with internal etcd
|
# Initialize with internal etcd
|
||||||
cluster-init: true
|
cluster-init: true
|
||||||
{% else %}
|
{% else %}
|
||||||
|
# Join cluster
|
||||||
server: https://{{ hostvars[groups['kubernetes'][0]]['nodeip_ipv4'] }}:6443
|
server: https://{{ hostvars[groups['kubernetes'][0]]['nodeip_ipv4'] }}:6443
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@@ -11,6 +15,16 @@ tls-san:
|
|||||||
- {{ kubernetes.control_plane.dns_name }}
|
- {{ kubernetes.control_plane.dns_name }}
|
||||||
|
|
||||||
# Networking
|
# Networking
|
||||||
|
{% if ansible_default_ipv6 is defined and ansible_default_ipv6.address is defined %}
|
||||||
|
node-external-ip: {{ ansible_default_ipv4.address }},{{ ansible_default_ipv6.address }}
|
||||||
|
{% else %}
|
||||||
|
node-external-ip: {{ ansible_default_ipv4.address }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
{% if kubernetes.network.clean_resolv_conf %}
|
||||||
|
resolv-conf: /etc/resolv-k3s.conf
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{% 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 }}
|
||||||
cluster-cidr: {{ kubernetes.ipPool.ipv4.cluster_cidr }},{{ kubernetes.ipPool.ipv6.cluster_cidr }}
|
cluster-cidr: {{ kubernetes.ipPool.ipv4.cluster_cidr }},{{ kubernetes.ipPool.ipv6.cluster_cidr }}
|
||||||
@@ -34,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
|
||||||
@@ -50,6 +68,16 @@ node-label:
|
|||||||
{% if zone is defined %}
|
{% if zone is defined %}
|
||||||
- topology.kubernetes.io/zone={{ zone }}
|
- topology.kubernetes.io/zone={{ zone }}
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
{% if kubernetes.labels_extra is defined %}
|
||||||
|
{% for item in kubernetes.labels_extra %}
|
||||||
|
- {{ item }}
|
||||||
|
{% endfor %}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
# Disabled components
|
||||||
|
{% if disabled_components %}
|
||||||
|
disable: {{ disabled_components | join(',') }}
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
{{ kubernetes.config_extra | to_yaml }}
|
{{ kubernetes.config_extra | to_yaml }}
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1 @@
|
|||||||
|
{{ kubernetes.registries_config | to_nice_yaml(indent=2) }}
|
||||||
@@ -0,0 +1 @@
|
|||||||
|
DPkg::Post-Invoke { "/usr/local/sbin/pve-no-nag"; };
|
||||||
@@ -0,0 +1,7 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
# Disables the "No valid subscription" dialog of the Proxmox web UI. Called by the apt hook
|
||||||
|
# 86pve-no-nag, because every proxmox-widget-toolkit update restores the file. Without a match
|
||||||
|
# (changed upstream code) the dialog returns and nothing breaks.
|
||||||
|
f=/usr/share/javascript/proxmox-widget-toolkit/proxmoxlib.js
|
||||||
|
[ -f "$f" ] && sed -i 's/checked_command: function (orig_cmd) {$/& orig_cmd(); return;/' "$f"
|
||||||
|
exit 0
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
- name: Install the subscription nag remover
|
||||||
|
copy:
|
||||||
|
src: pve-no-nag
|
||||||
|
dest: /usr/local/sbin/pve-no-nag
|
||||||
|
mode: "0755"
|
||||||
|
|
||||||
|
- name: Run it after every dpkg run
|
||||||
|
copy:
|
||||||
|
src: 86pve-no-nag
|
||||||
|
dest: /etc/apt/apt.conf.d/86pve-no-nag
|
||||||
|
mode: "0644"
|
||||||
|
|
||||||
|
- name: Remove the subscription nag
|
||||||
|
command: /usr/local/sbin/pve-no-nag
|
||||||
|
changed_when: false
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
tuned:
|
||||||
|
profile:
|
||||||
@@ -0,0 +1,6 @@
|
|||||||
|
- name: Install Packages
|
||||||
|
package:
|
||||||
|
name:
|
||||||
|
- tuned
|
||||||
|
- tuned-utils
|
||||||
|
- tuned-utils-systemtap
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
- import_tasks: ./install-packages.yml
|
||||||
|
|
||||||
|
- import_tasks: ./setup-service.yml
|
||||||
|
|
||||||
|
- import_tasks: ./set-profile.yml
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
- name: Set profile
|
||||||
|
command: tuned-adm profile throughput-performance
|
||||||
|
register: command
|
||||||
|
failed_when:
|
||||||
|
- "command.rc != 0"
|
||||||
@@ -0,0 +1,5 @@
|
|||||||
|
- name: Make sure service is started
|
||||||
|
service:
|
||||||
|
name: tuned
|
||||||
|
enabled: true
|
||||||
|
state: "started"
|
||||||
@@ -10,10 +10,30 @@
|
|||||||
daemon-reload: true
|
daemon-reload: true
|
||||||
enabled: true
|
enabled: true
|
||||||
|
|
||||||
|
- name: Ensure drop-in directory for the bound service exists
|
||||||
|
ansible.builtin.file:
|
||||||
|
path: /etc/systemd/system/{{ wireguard_ipv6_converter.service.bindTo }}.d
|
||||||
|
state: directory
|
||||||
|
mode: "0755"
|
||||||
|
when: "wireguard_ipv6_converter.service.bindTo is defined"
|
||||||
|
|
||||||
|
- name: Deploy start-propagation drop-in for the bound service
|
||||||
|
ansible.builtin.template:
|
||||||
|
src: wg-ipv6-conv-restart.conf.jinja2
|
||||||
|
dest: /etc/systemd/system/{{ wireguard_ipv6_converter.service.bindTo }}.d/10-wg-ipv6-converter_{{ wireguard_ipv6_converter.setup.interface }}.conf
|
||||||
|
mode: "0644"
|
||||||
|
when: "wireguard_ipv6_converter.service.bindTo is defined"
|
||||||
|
register: upholdsFile
|
||||||
|
|
||||||
|
- name: Reload systemd for drop-in
|
||||||
|
ansible.builtin.systemd:
|
||||||
|
daemon_reload: true
|
||||||
|
when: "upholdsFile.changed"
|
||||||
|
|
||||||
- name: Start service if interface exists already
|
- name: Start service if interface exists already
|
||||||
ansible.builtin.service:
|
ansible.builtin.service:
|
||||||
name: wg-ipv6-converter_{{ wireguard_ipv6_converter.setup.interface }}
|
name: wg-ipv6-converter_{{ wireguard_ipv6_converter.setup.interface }}
|
||||||
state: "{{ 'restarted' if deployDownload.changed or serviceFile.changed else 'started' }}"
|
state: "restarted"
|
||||||
register: service
|
register: service
|
||||||
when: "wireguard_ipv6_converter.setup.interface in ansible_interfaces"
|
when: "wireguard_ipv6_converter.setup.interface in ansible_interfaces"
|
||||||
|
|
||||||
|
|||||||
@@ -0,0 +1,7 @@
|
|||||||
|
# BindsTo= in the converter unit only propagates stop, so a restart of
|
||||||
|
# {{ wireguard_ipv6_converter.service.bindTo }} leaves the converter dead and the re-created
|
||||||
|
# interface without its IPv6 addresses. Start it again whenever
|
||||||
|
# {{ wireguard_ipv6_converter.service.bindTo }} starts. --no-block because the converter orders
|
||||||
|
# itself After={{ wireguard_ipv6_converter.service.bindTo }}.
|
||||||
|
[Service]
|
||||||
|
ExecStartPost=/bin/systemctl --no-block start wg-ipv6-converter_{{ wireguard_ipv6_converter.setup.interface }}.service
|
||||||
Reference in New Issue
Block a user