From e19ba910f57341db94a21e7d73ef187221ffc59a Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Fri, 6 May 2022 12:51:52 -0400 Subject: [PATCH] fix: add validations for node IPs and load balancer IPs Signed-off-by: Devin Buhl --- .config.sample.env | 4 +++- configure.sh | 15 +++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/.config.sample.env b/.config.sample.env index e1418646..ffc06277 100644 --- a/.config.sample.env +++ b/.config.sample.env @@ -36,10 +36,12 @@ export BOOTSTRAP_AGE_PUBLIC_KEY="" # # The network interface on the host kube-vip should attach to +# Look this up on your nodes to verify what NIC to use # e.g. eno1 export BOOTSTRAP_ANSIBLE_KUBE_VIP_INTERFACE="" -# IP Address to use with KubeVIP +# The IP Address to use with KubeVIP # Pick a unused IP that is on the same network as your nodes +# and also outside the ${BOOTSTRAP_METALLB_TRAEFIK_ADDR} range # e.g. 192.168.1.254 export BOOTSTRAP_ANSIBLE_KUBE_VIP_ADDRESS="" diff --git a/configure.sh b/configure.sh index 4caa73fb..182bde92 100755 --- a/configure.sh +++ b/configure.sh @@ -284,6 +284,21 @@ verify_ansible_hosts() { _has_envar "${node_control}" _has_optional_envar "${node_hostname}" + if [[ "${node_addr}" == "${BOOTSTRAP_ANSIBLE_KUBE_VIP_ADDRESS}" ]]; then + _log "ERROR" "The kube-vip IP '${BOOTSTRAP_ANSIBLE_KUBE_VIP_ADDRESS}' should not be the same as the IP for node '${node_addr}'" + exit 1 + fi + + if [[ "${node_addr}" == "${BOOTSTRAP_METALLB_K8S_GATEWAY_ADDR}" ]]; then + _log "ERROR" "The k8s-gateway load balancer IP '${BOOTSTRAP_METALLB_K8S_GATEWAY_ADDR}' should not be the same as the IP for node '${node_addr}'" + exit 1 + fi + + if [[ "${node_addr}" == "${BOOTSTRAP_METALLB_TRAEFIK_ADDR}" ]]; then + _log "ERROR" "The traefik load balancer IP '${BOOTSTRAP_METALLB_TRAEFIK_ADDR}' should not be the same as the IP for node '${node_addr}'" + exit 1 + fi + if ssh -q -o BatchMode=yes -o ConnectTimeout=5 "${!node_username}"@"${!var}" "true"; then _log "INFO" "Successfully SSH'ed into host '${!var}' with username '${!node_username}'" else