Implement HA control plane with Load Balancer (3-3 topology)
Some checks failed
Deploy Cluster / Terraform (push) Failing after 10s
Deploy Cluster / Ansible (push) Has been skipped

Major changes:
- Terraform: Scale to 3 control planes (cx23) + 3 workers (cx33)
- Terraform: Add Hetzner Load Balancer (lb11) for Kubernetes API
- Terraform: Add kube_api_lb_ip output
- Ansible: Add community.network collection to requirements
- Ansible: Update inventory to include LB endpoint
- Ansible: Configure secondary CPs and workers to join via LB
- Ansible: Add k3s_join_endpoint variable for HA joins
- Workflow: Add imports for cp-2, cp-3, and worker-3
- Docs: Update STABLE_BASELINE.md with HA topology and phase gates

Topology:
- 3 control planes (cx23 - 2 vCPU, 8GB RAM each)
- 3 workers (cx33 - 4 vCPU, 16GB RAM each)
- 1 Load Balancer (lb11) routing to all 3 control planes on port 6443
- Workers and secondary CPs join via LB endpoint for HA

Cost impact: +~€26/month (2 extra CPs + 1 extra worker + LB)
This commit is contained in:
2026-03-23 02:39:39 +00:00
parent 8b4a445b37
commit ff31cb4e74
10 changed files with 89 additions and 21 deletions

View File

@@ -32,6 +32,7 @@ def main():
worker_names = outputs["worker_names"]["value"]
worker_ips = outputs["worker_ips"]["value"]
worker_private_ips = outputs["worker_private_ips"]["value"]
kube_api_lb_ip = outputs.get("kube_api_lb_ip", {}).get("value", control_plane_ips[0])
control_planes = [
{
@@ -59,6 +60,7 @@ def main():
"control_planes": control_planes,
"workers": workers,
"private_key_file": outputs["ssh_private_key_path"]["value"],
"kube_api_lb_ip": kube_api_lb_ip,
}
env = Environment(loader=FileSystemLoader("."))

View File

@@ -17,3 +17,4 @@ ansible_user=root
ansible_python_interpreter=/usr/bin/python3
ansible_ssh_private_key_file={{ private_key_file }}
k3s_version=latest
kube_api_endpoint={{ kube_api_lb_ip }}

View File

@@ -3,3 +3,5 @@ collections:
version: ">=2.4.0"
- name: community.general
version: ">=8.0.0"
- name: community.network
version: ">=5.0.0"

View File

@@ -15,9 +15,9 @@
set_fact:
k3s_install_needed: "{{ (not k3s_service.stat.exists) or ((k3s_service_state.stdout | default('')) != 'active') }}"
- name: Wait for primary API on 6443 (secondary only)
- name: Wait for API endpoint on 6443 (secondary only)
wait_for:
host: "{{ k3s_primary_ip }}"
host: "{{ k3s_join_endpoint | default(k3s_primary_ip) }}"
port: 6443
state: started
timeout: 120
@@ -81,7 +81,7 @@
K3S_TOKEN: "{{ k3s_token }}"
command: >-
/tmp/install-k3s.sh server
--server https://{{ k3s_primary_ip }}:6443
--server https://{{ k3s_join_endpoint | default(k3s_primary_ip) }}:6443
--advertise-address={{ k3s_node_ip }}
--node-ip={{ k3s_node_ip }}
{% if k3s_disable_embedded_ccm | bool %}--disable-cloud-controller{% endif %}

View File

@@ -73,6 +73,8 @@
k3s_primary_ip: "{{ hostvars[groups['control_plane'][0]]['k3s_primary_private_ip'] }}"
k3s_primary_public_ip: "{{ hostvars[groups['control_plane'][0]]['k3s_primary_public_ip'] }}"
k3s_node_ip: "{{ k3s_private_ip }}"
# Use Load Balancer for HA - all control planes join via LB endpoint
k3s_join_endpoint: "{{ kube_api_endpoint | default(hostvars[groups['control_plane'][0]]['k3s_primary_private_ip']) }}"
roles:
- k3s-server
@@ -83,7 +85,8 @@
vars:
k3s_token: "{{ hostvars[groups['control_plane'][0]]['k3s_token'] }}"
k3s_server_url: "https://{{ hostvars[groups['control_plane'][0]]['k3s_primary_private_ip'] }}:6443"
# Use Load Balancer for HA - workers join via LB endpoint
k3s_server_url: "https://{{ kube_api_endpoint | default(hostvars[groups['control_plane'][0]]['k3s_primary_private_ip']) }}:6443"
k3s_node_ip: "{{ k3s_private_ip }}"
roles: