feat: add read-only storage status command
This commit is contained in:
parent
ce13442b20
commit
58b0d1fbf6
|
|
@ -31,6 +31,7 @@ var allowedCommands = map[string]bool{
|
|||
"start-cluster": true, "cleanup-debian-k8s": true,
|
||||
"status": true, "capacity": true, "capacity-advisor": true,
|
||||
"capacity-limits": true, "recover-plan": true, "gitops-status": true,
|
||||
"storage": true,
|
||||
"platform": true, "edge": true, "edge-cache-flush": true,
|
||||
"promote": true, "cert-check": true, "release-snapshot": true,
|
||||
"backup-status": true, "synthetic-checks": true, "resource-budget": true,
|
||||
|
|
|
|||
|
|
@ -105,3 +105,9 @@ func TestServerExecutesAllowlistedCommand(t *testing.T) {
|
|||
t.Fatalf("unexpected execution: %+v", completed)
|
||||
}
|
||||
}
|
||||
|
||||
func TestStorageCommandIsRemotelyEnabled(t *testing.T) {
|
||||
if !allowedCommands["storage"] {
|
||||
t.Fatal("storage must be exposed through the remote API")
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
jeannie
12
jeannie
|
|
@ -116,6 +116,7 @@ Observability And GitOps
|
|||
dex-secret {ensure|file} Generate/check SOPS-encrypted Dex bootstrap secrets.
|
||||
gitea-runner-secret {migrate|apply|file} Convert/apply the Gitea runner SOPS secret.
|
||||
gitops-status Print focused Argo CD health and sync status.
|
||||
storage status Inspect Kubernetes, OpenEBS, and Pimox storage (read-only).
|
||||
platform [all|calico|metrics|dns|metallb|ingress|storage|argocd|security|logging|monitoring|tools]
|
||||
Deploy one platform component or the full platform stack.
|
||||
edge Deploy/check the OCI edge stack only.
|
||||
|
|
@ -256,6 +257,17 @@ case "${1:-}" in
|
|||
gitops-status)
|
||||
gitops_status
|
||||
;;
|
||||
storage)
|
||||
case "${2:-status}" in
|
||||
status)
|
||||
storage_status
|
||||
;;
|
||||
*)
|
||||
echo "Usage: ./jeannie storage status" >&2
|
||||
exit 1
|
||||
;;
|
||||
esac
|
||||
;;
|
||||
platform)
|
||||
record_change_journal "platform" "$@"
|
||||
require_debian_server "platform"
|
||||
|
|
|
|||
|
|
@ -3258,6 +3258,43 @@ gitops_status() {
|
|||
"${REPO_ROOT}/scripts/gitops-status"
|
||||
}
|
||||
|
||||
storage_status() {
|
||||
require_debian_server "storage"
|
||||
local kubeconfig="${KUBECONFIG_PATH}"
|
||||
|
||||
printf '%s\n' '== Kubernetes storage =='
|
||||
printf '%s\n' '-- node pressure and capacity'
|
||||
kubectl --kubeconfig "${kubeconfig}" get nodes \
|
||||
-o custom-columns='NAME:.metadata.name,READY:.status.conditions[?(@.type=="Ready")].status,DISK_PRESSURE:.status.conditions[?(@.type=="DiskPressure")].status,EPHEMERAL:.status.capacity.ephemeral-storage' \
|
||||
2>/dev/null || true
|
||||
|
||||
printf '%s\n' '-- persistent volume claims'
|
||||
kubectl --kubeconfig "${kubeconfig}" get pvc -A \
|
||||
-o custom-columns='NAMESPACE:.metadata.namespace,NAME:.metadata.name,STATUS:.status.phase,REQUEST:.spec.resources.requests.storage,STORAGECLASS:.spec.storageClassName,VOLUME:.spec.volumeName' \
|
||||
2>/dev/null || true
|
||||
|
||||
printf '%s\n' '-- persistent volumes'
|
||||
kubectl --kubeconfig "${kubeconfig}" get pv \
|
||||
-o custom-columns='NAME:.metadata.name,STATUS:.status.phase,CAPACITY:.spec.capacity.storage,CLAIM:.spec.claimRef.namespace/.spec.claimRef.name,STORAGECLASS:.spec.storageClassName,RECLAIM:.spec.persistentVolumeReclaimPolicy' \
|
||||
2>/dev/null || true
|
||||
|
||||
printf '%s\n' '-- storage classes'
|
||||
kubectl --kubeconfig "${kubeconfig}" get storageclass \
|
||||
-o custom-columns='NAME:.metadata.name,PROVISIONER:.provisioner,DEFAULT:.metadata.annotations.storageclass\.kubernetes\.io/is-default-class,RECLAIM:.reclaimPolicy,VOLUME_BINDING:.volumeBindingMode' \
|
||||
2>/dev/null || true
|
||||
|
||||
if kubectl --kubeconfig "${kubeconfig}" get namespace openebs >/dev/null 2>&1; then
|
||||
printf '%s\n' '-- OpenEBS'
|
||||
kubectl --kubeconfig "${kubeconfig}" -n openebs get pods -o wide 2>/dev/null || true
|
||||
kubectl --kubeconfig "${kubeconfig}" -n openebs get storagepoolcluster 2>/dev/null || true
|
||||
else
|
||||
printf '%s\n' '-- OpenEBS: namespace not present'
|
||||
fi
|
||||
|
||||
printf '%s\n' '-- Pimox storage'
|
||||
check_pimox_storage || printf '%s\n' 'Pimox storage check failed or is unavailable.'
|
||||
}
|
||||
|
||||
cert_check() {
|
||||
"${REPO_ROOT}/scripts/cert-check"
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue