Page MenuHomePhorge

No OneTemporary

Authored By
Unknown
Size
7 KB
Referenced Files
None
Subscribers
None
diff --git a/deployments/ansible/roles/kolab-node/tasks/install-k3s.yaml b/deployments/ansible/roles/kolab-node/tasks/install-k3s.yaml
index cba1412..bd43bd6 100644
--- a/deployments/ansible/roles/kolab-node/tasks/install-k3s.yaml
+++ b/deployments/ansible/roles/kolab-node/tasks/install-k3s.yaml
@@ -1,126 +1,126 @@
---
- name: Check if file exists
ansible.builtin.stat:
path: /usr/local/bin/k3s
register: file_check
- name: Define Variable
set_fact:
k3s_mariadb_install_command: 'curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server" sh -s - --disable traefik,servicelb --write-kubeconfig-mode=644 --token="{{ k3s_token }}" --datastore-endpoint="mysql://k3s:{{ k3s_db_password }}@tcp({{ virtual_ip }}:3306)/k3s" --tls-san={{ virtual_ip }} --node-ip={{ ip }} --server=https://{{ virtual_ip }}:6443 --node-taint node-role.kubernetes.io/control-plane=true:NoSchedule'
k3s_sqlite_install_command: 'curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="server" sh -s - --disable traefik,servicelb --write-kubeconfig-mode=644 --token="{{ k3s_token }}" --tls-san={{ virtual_ip }} --node-ip={{ ip }} --node-taint node-role.kubernetes.io/control-plane=true:NoSchedule'
k3s_agent_install_command: 'curl -sfL https://get.k3s.io | INSTALL_K3S_EXEC="agent" sh -s - --token="{{ k3s_token }}" --node-ip={{ ip }} --server=https://{{ virtual_ip }}:6443'
when: not file_check.stat.exists
- name: Define Variable
set_fact:
- k3s_mariadb_install_command: 'cat install.sh | INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_EXEC="server" sh -s - --disable traefik,servicelb --write-kubeconfig-mode=644 --token="{{ k3s_token }}" --datastore-endpoint="mysql://k3s:{{ k3s_db_password }}@tcp({{ virtual_ip }}:3306)/k3s" --tls-san={{ virtual_ip }} --node-ip={{ ip }} --server=https://{{ virtual_ip }}:6443 --node-taint node-role.kubernetes.io/control-plane=true:NoSchedule'
- k3s_sqlite_install_command: 'cat install.sh | INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_EXEC="server" sh -s - --disable traefik,servicelb --write-kubeconfig-mode=644 --token="{{ k3s_token }}" --tls-san={{ virtual_ip }} --node-ip={{ ip }} --node-taint node-role.kubernetes.io/control-plane=true:NoSchedule'
- k3s_agent_install_command: 'cat install.sh | INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_EXEC="agent" sh -s - --token="{{ k3s_token }}" --node-ip={{ ip }} --server=https://{{ virtual_ip }}:6443'
+ k3s_mariadb_install_command: "INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_EXEC='server --disable traefik,servicelb --write-kubeconfig-mode=644 --token=\"{{ k3s_token }}\" --datastore-endpoint=\"mysql://k3s:{{ k3s_db_password }}@tcp({{ virtual_ip }}:3306)/k3s\" --tls-san={{ virtual_ip }} --node-ip={{ ip }} --server=https://{{ virtual_ip }}:6443 --node-taint node-role.kubernetes.io/control-plane=true:NoSchedule' ./install.sh"
+ k3s_sqlite_install_command: "INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_EXEC='server --disable traefik,servicelb --write-kubeconfig-mode=644 --token=\"{{ k3s_token }}\" --tls-san={{ virtual_ip }} --node-ip={{ ip }} --node-taint node-role.kubernetes.io/control-plane=true:NoSchedule' ./install.sh"
+ k3s_agent_install_command: "INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_EXEC='agent --token=\"{{ k3s_token }}\" --node-ip={{ ip }} --server=https://{{ virtual_ip }}:6443' ./install.sh"
when: file_check.stat.exists
- name: Prepare storage
ansible.builtin.command: mkdir -p /etc/rancher/k3s
# Special configuration that we need on ppc64le
- name: Configure k3s
when: k3s_binary
block:
- ansible.builtin.copy:
src: "k3s-server-config.yaml"
dest: /etc/rancher/k3s/config.yaml
owner: root
group: root
mode: '0644'
when: k3s_service_name == 'k3s'
- ansible.builtin.copy:
src: "k3s-agent-config.yaml"
dest: /etc/rancher/k3s/config.yaml
owner: root
group: root
mode: '0644'
when: k3s_service_name == 'k3s-agent'
- ansible.builtin.copy:
src: "k3s-registries.yaml"
dest: /etc/rancher/k3s/registries.yaml
owner: root
group: root
mode: '0644'
- name: Install k3s server (mariadb backend)
when: not k3s_binary and k3s_service_name == 'k3s' and k3s_mariadb_backend
ansible.builtin.shell: "{{ k3s_mariadb_install_command }}"
# This sometimes fails even though the installation was successful
ignore_errors: true
- name: Install k3s server (sqlite backend)
when: not k3s_binary and k3s_service_name == 'k3s' and not k3s_mariadb_backend
ansible.builtin.shell: "{{ k3s_sqlite_install_command }}"
# This sometimes fails even though the installation was successful
ignore_errors: true
- name: Install k3s agent
when: not k3s_binary and k3s_service_name == 'k3s-agent'
ansible.builtin.shell: "{{ k3s_agent_install_command }}"
# This sometimes fails even though the installation was successful
ignore_errors: true
- name: Install k3s from binary
when: k3s_binary
block:
- name: Copy file with owner and permissions
ansible.builtin.copy:
src: "{{ k3s_binary }}"
dest: /tmp/k3s-binaries.tar.gz
owner: root
group: root
mode: '0755'
- ansible.builtin.command:
cmd: tar xf /tmp/k3s-binaries.tar.gz --strip-components=1
chdir: /usr/local/bin
- name: Install dependencies
ansible.builtin.command: dnf -y install libseccomp-devel containernetworking-plugins tar curl
# FIXME archive the tarballs someplace, this is bound to fail otherwise
- name: Install k3s
ansible.builtin.shell: |
curl -LO https://github.com/k3s-io/k3s-selinux/releases/download/v1.4.stable.1/k3s-selinux-1.4-1.el8.noarch.rpm
dnf -y install ./k3s-selinux-1.4-1.el8.noarch.rpm
curl -O -L https://github.com/containernetworking/plugins/releases/download/v1.5.1/cni-plugins-linux-ppc64le-v1.5.1.tgz
mkdir -p /opt/cni/bin
tar -C /opt/cni/bin -xzf cni-plugins-linux-ppc64le-v1.5.1.tgz
curl -O -L https://github.com/flannel-io/cni-plugin/releases/download/v1.6.2-flannel1/cni-plugin-flannel-linux-ppc64le-v1.6.2-flannel1.tgz
tar -C /usr/libexec/cni/ -xzf cni-plugin-flannel-linux-ppc64le-v1.6.2-flannel1.tgz
mv /usr/libexec/cni/flannel-ppc64le /usr/libexec/cni/flannel
curl -o install.sh -L https://get.k3s.io
chmod +x install.sh
- name: Install k3s agent
ansible.builtin.shell: 'INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_EXEC="agent --token="{{ k3s_token }}" --node-ip={{ ip }} --server=https://{{ virtual_ip }}:6443" ./install.sh'
when: k3s_service_name == 'k3s-agent'
# This sometimes fails even though the installation was successful
ignore_errors: true
- name: Install k3s server
ansible.builtin.shell: 'INSTALL_K3S_SKIP_DOWNLOAD=true INSTALL_K3S_EXEC="server --disable traefik,servicelb --write-kubeconfig-mode=644 --token="{{ k3s_token }}" --tls-san={{ virtual_ip }} --node-ip={{ ip }} --node-taint CriticalAddonsOnly=true:NoExecute" ./install.sh'
when: k3s_service_name == 'k3s'
# This sometimes fails even though the installation was successful
ignore_errors: true
# Required to find /usr/local/bin binaries and cni plugins
- name: Prepare service environment
ansible.builtin.copy:
content: "PATH=/usr/bin:/usr/sbin/:/usr/local/bin:/usr/libexec/cni/:/root/.local/bin:/root/bin:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin"
dest: /etc/sysconfig/{{ k3s_service_name }}
- name: Ensure k3s is running
command: systemctl start {{ k3s_service_name }}
register: result
changed_when: "result.stdout != ''"
- name: Ensure k3s does not autostart on reboot
command: systemctl disable {{ k3s_service_name }}
register: result
changed_when: "result.stdout != ''"
when:

File Metadata

Mime Type
text/x-diff
Expires
Sat, Apr 4, 5:34 AM (4 d, 23 h ago)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
18822718
Default Alt Text
(7 KB)

Event Timeline