Skip to content

Commit

Permalink
feat: verify kube-vip IP is not in metallb range
Browse files Browse the repository at this point in the history
Signed-off-by: Devin Buhl <devin@buhl.casa>
  • Loading branch information
onedr0p committed May 6, 2022
1 parent 5ef1866 commit 6f945d7
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion configure.sh
Original file line number Diff line number Diff line change
Expand Up @@ -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"

Expand All @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
}

Expand Down

0 comments on commit 6f945d7

Please sign in to comment.