feat: Add HA Kubernetes cluster with Terraform + Ansible
- 3x CX23 control plane nodes (HA) - 4x CX33 worker nodes - k3s with embedded etcd - Hetzner CCM for load balancers - Gitea CI/CD workflows - Backblaze B2 for Terraform state
This commit is contained in:
4
ansible/roles/k3s-agent/defaults/main.yml
Normal file
4
ansible/roles/k3s-agent/defaults/main.yml
Normal file
@@ -0,0 +1,4 @@
|
||||
---
|
||||
k3s_version: latest
|
||||
k3s_server_url: ""
|
||||
k3s_token: ""
|
||||
30
ansible/roles/k3s-agent/tasks/main.yml
Normal file
30
ansible/roles/k3s-agent/tasks/main.yml
Normal file
@@ -0,0 +1,30 @@
|
||||
---
|
||||
- name: Check if k3s agent is already installed
|
||||
stat:
|
||||
path: /usr/local/bin/k3s-agent
|
||||
register: k3s_agent_binary
|
||||
|
||||
- name: Download k3s install script
|
||||
get_url:
|
||||
url: https://get.k3s.io
|
||||
dest: /tmp/install-k3s.sh
|
||||
mode: "0755"
|
||||
when: not k3s_agent_binary.stat.exists
|
||||
|
||||
- name: Install k3s agent
|
||||
environment:
|
||||
INSTALL_K3S_VERSION: "{{ k3s_version if k3s_version != 'latest' else '' }}"
|
||||
K3S_URL: "{{ k3s_server_url }}"
|
||||
K3S_TOKEN: "{{ k3s_token }}"
|
||||
command: /tmp/install-k3s.sh agent
|
||||
args:
|
||||
creates: /usr/local/bin/k3s-agent
|
||||
when: not k3s_agent_binary.stat.exists
|
||||
|
||||
- name: Wait for k3s agent to be ready
|
||||
command: systemctl is-active k3s-agent
|
||||
register: agent_status
|
||||
until: agent_status.stdout == "active"
|
||||
retries: 30
|
||||
delay: 10
|
||||
changed_when: false
|
||||
Reference in New Issue
Block a user