extract vrrp_script to external sh script, rename image to keepalived-k8s
This commit is contained in:
parent
3a25c46484
commit
8fa595ca1e
@ -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"]
|
||||
|
2
Makefile
2
Makefile
@ -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
11
check_apiserver.sh
Normal 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
|
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user