diff --git a/cmd/jeannie-server/main.go b/cmd/jeannie-server/main.go index b0b4de2..aeb1e15 100644 --- a/cmd/jeannie-server/main.go +++ b/cmd/jeannie-server/main.go @@ -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, diff --git a/cmd/jeannie-server/main_test.go b/cmd/jeannie-server/main_test.go index 5b3a709..fa3d3f0 100644 --- a/cmd/jeannie-server/main_test.go +++ b/cmd/jeannie-server/main_test.go @@ -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") + } +} diff --git a/jeannie b/jeannie index 714c8f0..a723290 100755 --- a/jeannie +++ b/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" diff --git a/lib/jeannie/commands.sh b/lib/jeannie/commands.sh index 5a43f80..45e1b86 100644 --- a/lib/jeannie/commands.sh +++ b/lib/jeannie/commands.sh @@ -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" }