-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdiagnostic-k8s.sh
More file actions
executable file
·47 lines (41 loc) · 1.23 KB
/
diagnostic-k8s.sh
File metadata and controls
executable file
·47 lines (41 loc) · 1.23 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
#!/bin/bash
echo "=== Kubernetes Diagnostic ==="
echo
echo "1. Checking if k3s is installed..."
if command -v k3s &> /dev/null; then
echo "✓ k3s is installed"
k3s --version
else
echo "❌ k3s is not installed in PATH"
fi
echo
echo "2. Checking if kubectl is available..."
if command -v kubectl &> /dev/null; then
echo "✓ kubectl is available"
kubectl version --client
else
echo "❌ kubectl is not available"
fi
echo
echo "3. Checking for k3s service status..."
if systemctl is-active --quiet k3s 2>/dev/null; then
echo "✓ k3s service is active"
else
echo "ℹ k3s service is not active"
# Check if k3s command exists but service isn't running
if command -v k3s &> /dev/null; then
echo " Note: k3s is installed but the service may not be running"
echo " You may need to start it with: sudo k3s server --write-kubeconfig-mode 644 &"
fi
fi
echo
echo "4. Checking for kubeconfig..."
if [ -f "$HOME/.kube/config" ]; then
echo "✓ Found kubeconfig at ~/.kube/config"
elif [ -f "/etc/rancher/k3s/k3s.yaml" ]; then
echo "✓ Found k3s config at /etc/rancher/k3s/k3s.yaml"
else
echo "ℹ No kubeconfig found - this explains why kubectl hangs"
fi
echo
echo "=== Diagnostic Complete ==="