From 6f945d7427e071c49e7045d77b35b88fae7d307c Mon Sep 17 00:00:00 2001 From: Devin Buhl Date: Fri, 6 May 2022 14:51:43 -0400 Subject: [PATCH] feat: verify kube-vip IP is not in metallb range Signed-off-by: Devin Buhl --- configure.sh | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/configure.sh b/configure.sh index b2bed9e7..fef90e75 100755 --- a/configure.sh +++ b/configure.sh @@ -140,6 +140,7 @@ _has_valid_ip() { } _has_ip_in_metallb_range() { + local found_kube_vip="false" local found_k8s_gateway="false" local found_traefik="false" @@ -156,6 +157,9 @@ _has_ip_in_metallb_range() { for (( octet=ip_octet_min; octet<=ip_octet_ceil; octet++ )); do addr="${ip_cidr_min}.${octet}" + if [[ "${addr}" == "${BOOTSTRAP_KUBE_VIP_ADDRESS}" ]]; then + found_kube_vip="true" + fi if [[ "${addr}" == "${BOOTSTRAP_METALLB_K8S_GATEWAY_ADDR}" ]]; then found_k8s_gateway="true" fi @@ -171,6 +175,11 @@ _has_ip_in_metallb_range() { done done + if [[ $found_kube_vip == "true" ]]; then + _log "ERROR" "The IP for k8s_gateway '${BOOTSTRAP_KUBE_VIP_ADDRESS}' is in metallb range '${BOOTSTRAP_METALLB_LB_RANGE}'" + exit 1 + fi + if [[ $found_k8s_gateway == "false" ]]; then _log "ERROR" "The IP for k8s_gateway '${BOOTSTRAP_METALLB_K8S_GATEWAY_ADDR}' is not in metallb range '${BOOTSTRAP_METALLB_LB_RANGE}'" exit 1 @@ -354,7 +363,8 @@ verify_ansible_hosts() { } verify_success() { - _log "INFO" "All checks passed! Run the script without --verify to template all the files out" + _log "INFO" "All checks passed!" + _log "INFO" "Run the script without --verify to template all the files out" exit 0 }