Created
February 3, 2023 16:47
-
-
Save rjchicago/e33e4146977d8ed69b9cf8a5d3f20bac to your computer and use it in GitHub Desktop.
Script to verify MetalLB floating IP assignment to a given service.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
set -Eeuo pipefail | |
echo | |
: ${NAMESPACE:?NAMESPACE is required} | |
: ${SERVICE:?SERVICE is required} | |
: ${FLOATING_IP:?FLOATING_IP is required} | |
echo "VERIFY FLOATING IP: $FLOATING_IP" | |
while true; do | |
ASSIGNED_IP=$(kubectl get svc -n $NAMESPACE $SERVICE -o=jsonpath='{.status.loadBalancer.ingress[0].ip}') | |
[[ "$ASSIGNED_IP" = "$FLOATING_IP" ]] && exit 0 | |
echo " ..." | |
sleep 1 | |
done | |
### EXAMPLE USAGE ### | |
# export FLOATING_IP="1.2.3.4" | |
# export NAMESPACE="my-namespace" | |
# export SERVICE="my-service" | |
# verification_passed() { echo " ✅ VERIFICATION PASSED"; } | |
# verification_failed() { echo " 💀 VERIFICATION FAILED" && exit 1; } | |
# timeout 5s $(dirname $0)/verify-floating-ip.sh && verification_passed || verification_failed | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment