Pod Ip issue fixed

This commit is contained in:
Vaibhav Pathak 2026-01-21 16:02:06 +05:30
parent dd891787d5
commit 0fd7a54987

View File

@ -831,13 +831,16 @@ spec:
NODE_IPS=$(kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="InternalIP")].address}' 2>/dev/null || echo "") NODE_IPS=$(kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="InternalIP")].address}' 2>/dev/null || echo "")
echo "Node IPs: $NODE_IPS" echo "Node IPs: $NODE_IPS"
# 3. Get pod network CIDR gateway # 3. Get pod network CIDR gateways from ALL nodes
POD_CIDR=$(kubectl get nodes -o jsonpath='{.items[0].spec.podCIDR}' 2>/dev/null || echo "") echo "Collecting pod CIDR gateways from all nodes..."
if [ -n "$POD_CIDR" ]; then POD_CIDRS=$(kubectl get nodes -o jsonpath='{.items[*].spec.podCIDR}' 2>/dev/null || echo "")
GATEWAY_IP=$(echo "$POD_CIDR" | sed 's/\.[0-9]*\/.*/.1/') for cidr in $POD_CIDRS; do
COMMON_BRIDGE_IPS="$COMMON_BRIDGE_IPS $GATEWAY_IP" if [ -n "$cidr" ]; then
echo "Pod CIDR gateway: $GATEWAY_IP" GATEWAY_IP=$(echo "$cidr" | sed 's/\.[0-9]*\/.*/.1/')
fi COMMON_BRIDGE_IPS="$COMMON_BRIDGE_IPS $GATEWAY_IP"
echo " Pod CIDR gateway: $GATEWAY_IP (from $cidr)"
fi
done
# Combine all IPs to register # Combine all IPs to register
ALL_IPS="$COMMON_BRIDGE_IPS $NODE_IPS" ALL_IPS="$COMMON_BRIDGE_IPS $NODE_IPS"