Files
ansible/roles/k3s_agent
Tuan-Dat Tran 5bc3024eaf feat(k3s): replace nginx loadbalancer with kube-vip for control-plane HA
Deploys kube-vip as a DaemonSet on all k3s server nodes, advertising a
VIP (192.168.20.2) via ARP. Eliminates the single-point-of-failure
k3s-loadbalancer VM.

- New kube_vip role: RBAC + DaemonSet templates, TLS SAN cert rotation
- playbooks/kube-vip.yaml: migration playbook (serial=1, idempotent)
- Updated k3s install tasks (server primary/secondary, agent) to use k3s_vip
  instead of the loadbalancer VM IP
- Added k3s_vip: 192.168.20.2 to group_vars (below DHCP range .11-.250)

Migration steps in playbook header comment.
2026-04-26 12:08:42 +02:00
..
2025-11-07 20:44:14 +01:00
2025-07-27 16:40:46 +02:00

K3s Agent Ansible Role

This Ansible role installs and configures a K3s agent on a node.

Role Variables

  • k3s.loadbalancer.default_port: The port for the K3s load balancer. Defaults to 6443.
  • k3s_token: The token for joining the K3s cluster. This is a required variable.
  • hostvars['k3s-loadbalancer'].ansible_default_ipv4.address: The IP address of the K3s load balancer. This is a required variable.

Tasks

The main tasks are in tasks/main.yml and tasks/installation.yml.

  • installation.yml:
    • Installs qemu-guest-agent.
    • Checks if K3s is already installed.
    • Downloads the K3s installation script to /tmp/k3s_install.sh.
    • Installs K3s as an agent, connecting to the master.

Handlers

The main handlers are in handlers/main.yml.

  • Restart k3s: Restarts the k3s service.

Usage

Here is an example of how to use this role in a playbook:

---
- hosts: k3s_agents
  roles:
    - role: k3s_agent
      vars:
        k3s_token: "your_k3s_token"
        k3s.loadbalancer.default_port: 6443