|
|
|
@ -26,10 +26,30 @@ |
|
|
|
|
copy: |
|
|
|
|
dest: /etc/keepalived/keepalived.conf |
|
|
|
|
content: "" |
|
|
|
|
- name: Check APIServer Script |
|
|
|
|
copy: |
|
|
|
|
dest: /etc/keepalived/check_apiserver.sh |
|
|
|
|
content: | |
|
|
|
|
#!/bin/sh |
|
|
|
|
errorExit() { |
|
|
|
|
echo "*** $*" 1>&2 |
|
|
|
|
exit 1 |
|
|
|
|
} |
|
|
|
|
curl --silent --max-time 2 --insecure https://localhost:{{ APISERVER_DEST_PORT }}/ -o /dev/null || errorExit "Error GET https://localhost:{{ APISERVER_DEST_PORT }}/" |
|
|
|
|
if ip addr | grep -q {{ APISERVER_VIP }}; then |
|
|
|
|
curl --silent --max-time 2 --insecure https://{{ APISERVER_VIP }}:{{ APISERVER_DEST_PORT }}/ -o /dev/null || errorExit "Error GET https://{{ APISERVER_VIP }}:{{ APISERVER_DEST_PORT }}/" |
|
|
|
|
fi |
|
|
|
|
- name: Config keepalived |
|
|
|
|
blockinfile: |
|
|
|
|
dest: /etc/keepalived/keepalived.conf |
|
|
|
|
block: | |
|
|
|
|
vrrp_script check_apiserver { |
|
|
|
|
script "/etc/keepalived/check_apiserver.sh" |
|
|
|
|
interval 3 |
|
|
|
|
weight -2 |
|
|
|
|
fall 10 |
|
|
|
|
rise 2 |
|
|
|
|
} |
|
|
|
|
vrrp_script chk_apiserver { |
|
|
|
|
script "/usr/bin/nc localhost 6443" |
|
|
|
|
interval 5 |
|
|
|
@ -45,10 +65,10 @@ |
|
|
|
|
auth_pass 1111 |
|
|
|
|
} |
|
|
|
|
virtual_ipaddress { |
|
|
|
|
10.10.0.2 |
|
|
|
|
{{ APISERVER_VIP }} |
|
|
|
|
} |
|
|
|
|
track_script { |
|
|
|
|
chk_apiserver |
|
|
|
|
check_apiserver |
|
|
|
|
} |
|
|
|
|
} |
|
|
|
|
vrrp_script chk_haproxy { |
|
|
|
@ -66,7 +86,7 @@ |
|
|
|
|
auth_pass 2222 |
|
|
|
|
} |
|
|
|
|
virtual_ipaddress { |
|
|
|
|
10.10.0.3 |
|
|
|
|
{{ ELB_VIP }} |
|
|
|
|
} |
|
|
|
|
track_script { |
|
|
|
|
chk_haproxy |
|
|
|
|