Initial commit: k8s cluster manifests and scripts

This commit is contained in:
2026-04-01 15:34:02 +08:00
commit 2f04fa4473
49 changed files with 4109 additions and 0 deletions

49
cluster/check_access.sh Executable file
View File

@@ -0,0 +1,49 @@
#!/usr/bin/env bash
# 用途:快速查看目前所有服務「怎麼連」
# 不修改任何資源,純顯示資訊
set -euo pipefail
echo
echo "=== Pods ==="
kubectl get pods -o wide
echo
echo "=== Services ==="
kubectl get svc
echo
echo "=== Node IPs ==="
kubectl get nodes -o wide | awk 'NR>1 {print $1 "\t" $6}'
echo
echo "=== NodePort Access ==="
NODE_IPS=$(kubectl get nodes -o jsonpath='{range .items[*]}{.status.addresses[?(@.type=="InternalIP")].address}{" "}{end}')
kubectl get svc --no-headers | awk '$2=="NodePort"' | while read -r name type clusterip external ports age; do
PORTS=$(echo "$ports" | tr ',' '\n' | awk -F: '{print $NF}')
for ip in $NODE_IPS; do
for p in $PORTS; do
echo "- $ip:$p ($name)"
done
done
done
echo
echo "=== Ingress (HTTP/HTTPS) ==="
kubectl get ingress --no-headers | while read -r name class hosts address ports age; do
echo "- $name"
kubectl get ingress "$name" -o jsonpath='{range .spec.rules[*]}{.host}{"\n"}{end}' | while read -r host; do
TLS=$(kubectl get ingress "$name" -o jsonpath='{.spec.tls}')
if [[ -n "$TLS" && "$TLS" != "[]" ]]; then
echo " https://$host"
else
echo " http://$host"
fi
done
done
echo
echo "=== PVC ==="
kubectl get pvc

7
cluster/check_nodes.sh Executable file
View File

@@ -0,0 +1,7 @@
#!/usr/bin/env bash
# 用途:檢查叢集節點狀態
set -euo pipefail
kubectl get nodes -o wide

14
cluster/check_storage.sh Executable file
View File

@@ -0,0 +1,14 @@
#!/usr/bin/env bash
# 用途檢查儲存狀態PVC / Longhorn
set -euo pipefail
echo "=== PVC ==="
kubectl get pvc
if kubectl get ns longhorn-system >/dev/null 2>&1; then
echo
echo "=== Longhorn Volumes ==="
kubectl -n longhorn-system get volumes
fi