docs: Add comprehensive troubleshooting guide for nginx-nodeport with improved test script

This commit is contained in:
mik-tf
2025-11-06 20:53:56 -05:00
parent 2028fc87ff
commit b195cd0171
2 changed files with 386 additions and 15 deletions

View File

@@ -67,9 +67,11 @@ else
exit 1
fi
# Get pod information
# Get pod information and node it's running on
POD_NAME=$(kubectl get pods -l app=nginx-nodeport -o name | head -1)
POD_NODE=$(kubectl get pods -l app=nginx-nodeport -o jsonpath='{.items[0].spec.nodeName}')
print_info "Testing pod: $POD_NAME"
print_info "Pod is running on node: $POD_NODE"
# Test nginx configuration
print_info "Testing nginx configuration..."
@@ -118,30 +120,48 @@ else
fi
print_info "NodePort: $NODEPORT"
# Get node IPv6 address
print_info "Getting node IPv6 address..."
NODE_IPV6=$(kubectl get nodes -o jsonpath='{.items[0].status.addresses[?(@.type=="InternalIP")].address}' 2>/dev/null || echo "")
# Get the Mycelium IPv6 address of the SPECIFIC node where the pod is running
# This is critical with externalTrafficPolicy: Local
print_info "Getting Mycelium IPv6 address of node where pod is running..."
# Get Mycelium IPv6 of the specific node where our pod is running
NODE_IPV6=$(kubectl get node "$POD_NODE" -o jsonpath='{range .status.addresses[?(@.type=="InternalIP")]}{.address}{"\n"}{end}' 2>/dev/null | 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 "$NODE_IPV6" ]; then
print_warning "Could not get node IPv6 address automatically"
print_warning "Could not get Mycelium IPv6 address for node $POD_NODE"
print_info "Please manually find your node IPv6 address with:"
echo " kubectl get nodes -o wide"
echo " kubectl get node $POD_NODE -o jsonpath='{range .status.addresses[?(@.type==\"InternalIP\")]}{.address}{\"\n\"}{end}' | grep ':'"
else
print_status "Node IPv6 address: $NODE_IPV6"
print_status "Pod's node ($POD_NODE) Mycelium IPv6: $NODE_IPV6"
print_info "⚠️ NOTE: With externalTrafficPolicy: Local, service is only accessible on THIS node's IP"
# Test external connectivity
print_info "Testing external IPv6 connectivity..."
print_info "Testing external Mycelium IPv6 connectivity..."
# Test with IPv6
if command -v curl &> /dev/null; then
if curl -6 -s -m 10 "http://[$NODE_IPV6]:$NODEPORT/" &> /dev/null; then
print_status "External IPv6 connectivity is working!"
print_info "Your website is accessible at: http://[$NODE_IPV6]:$NODEPORT/"
print_info "Testing: curl -6 \"http://[$NODE_IPV6]:$NODEPORT/\""
if curl -6 -s -m 10 "http://[$NODE_IPV6]:$NODEPORT/" > /tmp/nodeport_test.html 2>/dev/null; then
if [ -s /tmp/nodeport_test.html ]; then
print_status "External Mycelium IPv6 connectivity is working!"
print_info "Your website is accessible at: http://[$NODE_IPV6]:$NODEPORT/"
print_info "Content preview:"
head -3 /tmp/nodeport_test.html | sed 's/^/ /'
rm -f /tmp/nodeport_test.html
else
print_warning "Connected but received no content"
fi
else
print_warning "External IPv6 connectivity test failed"
print_info "This might be due to firewall or network policies"
print_info "Website should still be accessible from within the cluster"
print_warning "External Mycelium IPv6 connectivity test failed"
print_info "This might be due to:"
print_info " • Firewall or network policies blocking port $NODEPORT"
print_info " • Pod not running on this specific node"
print_info " • Mycelium network not properly configured"
print_info ""
print_info "Try testing from within the cluster:"
echo " kubectl exec $POD_NAME -- curl -s http://localhost:8080/"
fi
rm -f /tmp/nodeport_test.html
else
print_info "curl not available, skipping external connectivity test"
fi
@@ -198,8 +218,12 @@ if [ ! -z "$NODE_IPV6" ]; then
echo " • External URL: http://[$NODE_IPV6]:$NODEPORT/"
echo " • Health check: http://[$NODE_IPV6]:$NODEPORT/health"
echo " • Internal test: kubectl exec $POD_NAME -- curl -s http://localhost:8080/"
echo ""
echo " 💡 All worker node Mycelium IPv6 addresses:"
kubectl get nodes -o jsonpath='{range .items[*]}{range .status.addresses[?(@.type=="InternalIP")]}{.address}{"\n"}{end}{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]+$' | nl -v 1 -w 5 -s '. ' | sed 's/^/ /'
else
echo " • Please get your node IPv6 address: kubectl get nodes -o wide"
echo " • Get your node Mycelium IPv6 addresses:"
echo " kubectl get nodes -o jsonpath='{range .items[*]}{range .status.addresses[?(@.type==\"InternalIP\")]}{.address}{\"\n\"}{end}{end}' | grep ':'"
echo " • Access URL: http://[YOUR-NODE-IPV6]:$NODEPORT/"
fi
echo ""