Files
2026-03-09 20:21:35 -05:00

47 lines
1.7 KiB
Bash
Executable File
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/bin/bash
# Health check script for Kubernetes cluster
echo "======================================"
echo " Kubernetes Cluster Health Check"
echo "======================================"
echo ""
echo "=== Node Resources ==="
kubectl top nodes 2>&1 || echo "❌ Metrics server not working!"
echo ""
echo "=== High Memory Nodes (>85%) ==="
kubectl top nodes --no-headers | awk '$5 > 85 {print "⚠️ "$1" - "$5"% memory"}'
echo ""
echo "=== Pods without Resource Limits ==="
COUNT=$(kubectl get pods -A -o json | jq -r '.items[] | select(.spec.containers[].resources.limits == null) | .metadata.namespace + "/" + .metadata.name' 2>/dev/null | wc -l)
echo "$COUNT pods without resource limits"
echo ""
echo "=== Failing Pods ==="
kubectl get pods -A --field-selector=status.phase!=Running,status.phase!=Succeeded 2>/dev/null | grep -v "No resources found" || echo "✅ All pods running"
echo ""
echo "=== HPA Status ==="
kubectl get hpa -A 2>/dev/null | grep -v "No resources found" || echo "️ No HPAs configured"
echo ""
echo "=== Pods with High Restarts (>10) ==="
kubectl get pods -A -o json | jq -r '.items[] | select(.status.containerStatuses != null) | select(.status.containerStatuses[].restartCount > 10) | .metadata.namespace + "/" + .metadata.name + " - " + (.status.containerStatuses[].restartCount|tostring) + " restarts"' 2>/dev/null || echo "✅ No pods with excessive restarts"
echo ""
echo "=== Storage Status ==="
kubectl get pv | grep -c "Bound"
echo "persistent volumes bound"
echo ""
echo "=== Ingress Status ==="
kubectl get ingress -A | tail -n +2 | wc -l
echo "ingresses configured"
echo ""
echo "======================================"
echo " Health Check Complete"
echo "======================================"