#!/bin/bash # Diagnostic script to debug NodePort networking issues # This helps identify why some URLs work and others don't echo "๐Ÿ” NodePort Networking Diagnostics" echo "==================================" echo "" # Check pod locations echo "๐Ÿ“ Current Pod Locations:" kubectl get pods -l app=nginx-nodeport -o wide echo "" # Check node information echo "๐ŸŒ Node Information:" kubectl get nodes -o wide echo "" # Check service status echo "๐Ÿ”ง Service Status:" kubectl get svc nginx-nodeport-service echo "" # Test connectivity to each node echo "๐Ÿงช Connectivity Tests:" echo "" PODS=$(kubectl get pods -l app=nginx-nodeport -o jsonpath='{range .items[*]}{.metadata.name}{"\t"}{.spec.nodeName}{"\n"}{end}') while IFS=$'\t' read -r pod_name node_name; do echo "Testing pod: $pod_name on node: $node_name" # Get IPv6 for this specific node IPV6=$(kubectl get node "$node_name" -o jsonpath='{range .status.addresses[?(@.type=="InternalIP")]}{.address}{"\n"}{end}' | grep -E '^[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+:[0-9a-f]+$' | head -1) if [ ! -z "$IPV6" ]; then echo " Node IPv6: $IPV6" echo " Testing connectivity: curl -6 --connect-timeout 5 http://[$IPV6]:30091/health" # Test HTTP connectivity if curl -6 --connect-timeout 5 -s "http://[$IPV6]:30091/health" >/dev/null 2>&1; then echo " โœ… HTTP connectivity: WORKING" else echo " โŒ HTTP connectivity: FAILED" fi # Test ICMP connectivity echo " Testing ping: ping -6 -c 2 -W 3 $IPV6" if ping -6 -c 2 -W 3 "$IPV6" >/dev/null 2>&1; then echo " โœ… ICMP connectivity: WORKING" else echo " โŒ ICMP connectivity: FAILED" fi else echo " โŒ No IPv6 found for node: $node_name" fi echo "" done <<< "$PODS" echo "๐Ÿ“Š Summary:" echo "This shows which nodes actually have pods and whether they're accessible" echo "" echo "If some URLs work and others don't, it means:" echo " โœ… Working URLs: Nodes with good Mycelium connectivity" echo " โŒ Failed URLs: Nodes with poor Mycelium connectivity or network issues" echo "" echo "To fix connectivity issues:" echo " 1. Check Mycelium status on affected nodes" echo " 2. Restart Mycelium on nodes with failed connectivity" echo " 3. Scale to replicas only on nodes with good connectivity"