Refactor MetalLB config job to create temporary YAML files for IPAddressPool and L2Advertisement

This commit is contained in:
2025-03-23 14:05:16 +01:00
parent c02cb46292
commit 4345d5dbf6

View File

@@ -37,7 +37,10 @@ spec:
exit 1 exit 1
fi fi
cat <<EOF | kubectl apply -f - # Create a temporary file for the IPAddressPool
echo "Creating IPAddressPool with IP: $SERVER_IP/32"
cat > /tmp/ippool.yaml << EOF
apiVersion: metallb.io/v1beta1 apiVersion: metallb.io/v1beta1
kind: IPAddressPool kind: IPAddressPool
metadata: metadata:
@@ -45,10 +48,13 @@ spec:
namespace: metallb-system namespace: metallb-system
spec: spec:
addresses: addresses:
- ${SERVER_IP}/32 - "$SERVER_IP/32"
EOF EOF
cat <<EOF | kubectl apply -f - kubectl apply -f /tmp/ippool.yaml
# Create the L2Advertisement
cat > /tmp/l2advert.yaml << EOF
apiVersion: metallb.io/v1beta1 apiVersion: metallb.io/v1beta1
kind: L2Advertisement kind: L2Advertisement
metadata: metadata:
@@ -59,6 +65,8 @@ spec:
- first-pool - first-pool
EOF EOF
kubectl apply -f /tmp/l2advert.yaml
echo "MetalLB configured to use IP: $SERVER_IP" echo "MetalLB configured to use IP: $SERVER_IP"
restartPolicy: OnFailure restartPolicy: OnFailure
--- ---