extract vrrp_script to external sh script, rename image to keepalived-k8s

This commit is contained in:
RouxAntoine 2022-01-02 12:52:37 +01:00
parent 3a25c46484
commit 8fa595ca1e
Signed by: antoine
GPG Key ID: 098FB66FC0475E70
4 changed files with 17 additions and 3 deletions

View File

@ -10,6 +10,9 @@ RUN apk add --no-cache \
&& adduser -S -s /sbin/nologin -G keepalived_script -H keepalived_script
COPY keepalived.conf /etc/keepalived/keepalived.conf
COPY check_apiserver.sh /etc/keepalived/check_apiserver.sh
COPY init.sh /
RUN chmod +x /init.sh
RUN chmod +x /init.sh && chmod +x /etc/keepalived/check_apiserver.sh
CMD ["/init.sh"]

View File

@ -17,7 +17,7 @@ shell_build_image = $(OCI_CLI_BUILD) build --platform $(PLATFORM) -t $(REGISTRY_
$(OCI_CLI) push $(REGISTRY_IP):5000/$(1);
imageKeepalived:
$(call shell_build_image,keepalived)
$(call shell_build_image,keepalived-k8s)
## management

11
check_apiserver.sh Normal file
View File

@ -0,0 +1,11 @@
#!/bin/sh
errorExit() {
echo "*** $*" 1>&2
exit 1
}
curl --silent --max-time 2 --insecure https://localhost:6443/ -o /dev/null || errorExit "Error GET https://localhost:6443/"
if ip addr | grep -q 100.105.163.74; then
curl --silent --max-time 2 --insecure https://100.105.163.74:6443/ -o /dev/null || errorExit "Error GET https://100.105.163.74:6443/"
fi

View File

@ -3,7 +3,7 @@ global_defs {
}
vrrp_script chk_kube {
script /usr/bin/curl --silent --max-time 2 --insecure https://100.105.163.74:6443/ -o /dev/null || echo "*** Error GET https://100.105.163.74:6443/" 1>&2 && exit 1
script "/etc/keepalived/check_apiserver.sh"
interval 2 # check every 2 seconds
weight 2 # add n points of prio if OK
}