Skip to content

Instantly share code, notes, and snippets.

@codatory
Created December 3, 2022 16:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codatory/b6e59b3752cf97b56d8f0417ae9ce9fa to your computer and use it in GitHub Desktop.
Save codatory/b6e59b3752cf97b56d8f0417ae9ce9fa to your computer and use it in GitHub Desktop.
- name: Kubernetes LB Config
hosts: control
gather_facts: no
become: true
order: shuffle
tasks:
- name: Enable nonlocal bind
sysctl:
name: net.ipv4.ip_nonlocal_bind
value: 1
- name: Install keepalived
apt:
cache_valid_time: 900
name: keepalived
- name: Enable keepalived daemon
service:
name: keepalived.service
state: started
enabled: true
- name: Update keepalived config file
register: config
copy:
src: keepalived.conf
dest: /etc/keepalived/keepalived.conf
- name: Reload keepalived
when: config.changed
service:
name: keepalived.service
state: reloaded
vrrp_track_process track_kube-apiserver {
process kube-apiserver
weight 100
}
vrrp_track_process track_konnectivity-server {
process konnectivity-server
weight 50
}
vrrp_track_process track_k0s {
process k0s
weight 25
}
vrrp_instance VRRP1 {
state BACKUP
interface enp0s31f6
virtual_router_id 41
priority 0
advert_int 1
authentication {
auth_type PASS
auth_pass 5551212
}
virtual_ipaddress {
10.8.0.10/24
}
track_process {
track_kube-apiserver
track_konnectivity-server
track_k0s
}
virtual_routes {
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment