Skip to content

armgit / Pulse

Public Imported from GitHub
0

Real-time monitoring dashboard for Proxmox VE, PBS, Docker, Kubernetes, TrueNAS and vSphere. Self-hosted, with alerts for failed backups, full disks, unhealthy containers and offline nodes.

Align Kubernetes page with Proxmox/Docker layout

rcourtman2cd4d095f14d
diff --git a/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx
index 86e256853b..ef64d1c0f5 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx
@@ -1,7 +1,9 @@
import { For, Show, type Component, type JSX } from 'solid-js';
import { StatusDot } from '@/components/shared/StatusDot';
+import { ResponsiveMetricCell } from '@/components/shared/responsive';
import { TableCard } from '@/components/shared/TableCard';
import { TableCardHeader } from '@/components/shared/TableCardHeader';
+import { StackedMemoryBar } from '@/components/Workloads/StackedMemoryBar';
import {
Table,
TableBody,
@@ -12,6 +14,7 @@ import {
} from '@/components/shared/Table';
import { getSimpleStatusIndicator } from '@/utils/status';
import { asTrimmedString } from '@/utils/stringUtils';
+import { buildMetricKeyForUnifiedResource } from '@/utils/metricsKeys';
import {
PLATFORM_TABLE_BODY_CLASS,
PLATFORM_TABLE_CARD_CLASS,
@@ -35,13 +38,20 @@ import type { Resource } from '@/types/resource';
// the agent metrics fine but omits the K8s context that matters to the
// cluster operator. This bespoke table reuses canonical shared
// primitives and surfaces the Kubelet-native columns alongside the
-// usual CPU/Memory utilisation.
+// canonical bar treatment (ResponsiveMetricCell / StackedMemoryBar) so
+// the Overview stack reads as one consistent surface alongside the
+// Docker / Proxmox / vSphere host tables.
-const formatPercent = (percent?: number): JSX.Element => {
- if (typeof percent !== 'number' || Number.isNaN(percent))
- return <span class="text-muted">—</span>;
- return <span class="tabular-nums">{percent.toFixed(1)}%</span>;
-};
+const finiteMetric = (value: number | undefined): number | undefined =>
+ typeof value === 'number' && Number.isFinite(value) ? value : undefined;
+
+const metricFallback = () => (
+ <div class="flex justify-center">
+ <span class="text-xs text-muted" aria-hidden="true">
+ —
+ </span>
+ </div>
+);
const formatUptime = (seconds: number | undefined): string => {
if (!seconds || seconds <= 0) return '—';
@@ -171,6 +181,15 @@ export const KubernetesNodesTable: Component<{
return capacityLabel();
};
const indicator = () => getSimpleStatusIndicator(node.status);
+ const metricsKey = () => buildMetricKeyForUnifiedResource(node);
+ const cpuPercent = () => finiteMetric(node.cpu?.current);
+ const memoryTotal = () => finiteMetric(node.memory?.total) ?? 0;
+ const memoryUsed = () => finiteMetric(node.memory?.used) ?? 0;
+ const memoryPercentOnly = () =>
+ memoryTotal() > 0 ? undefined : finiteMetric(node.memory?.current);
+ const hasMemoryMetric = () =>
+ memoryTotal() > 0 || memoryPercentOnly() !== undefined;
+ const canRenderMetrics = () => indicator().variant !== 'muted';
return (
<TableRow class="text-[11px] sm:text-xs">
<TableCell class={getPlatformTableCellClass()}>
@@ -209,14 +228,30 @@ export const KubernetesNodesTable: Component<{
</span>
</TableCell>
<TableCell
- class={`${getPlatformTableCellClass('right')} text-base-content`}
+ class={`${getPlatformTableCellClass('right')} w-[20%] md:w-auto`}
>
- {formatPercent(node.cpu?.current)}
+ <ResponsiveMetricCell
+ class="w-full"
+ value={cpuPercent() ?? 0}
+ type="cpu"
+ resourceId={metricsKey()}
+ isRunning={canRenderMetrics() && cpuPercent() !== undefined}
+ showMobile={false}
+ />
</TableCell>
<TableCell
- class={`${getPlatformTableCellClass('right')} text-base-content`}
+ class={`${getPlatformTableCellClass('right')} w-[20%] md:w-auto`}
>
- {formatPercent(node.memory?.current)}
+ <Show
+ when={canRenderMetrics() && hasMemoryMetric()}
+ fallback={metricFallback()}
+ >
+ <StackedMemoryBar
+ used={memoryUsed()}
+ total={memoryTotal()}
+ percentOnly={memoryPercentOnly()}
+ />
+ </Show>
</TableCell>
<TableCell
class={`${getPlatformTableCellClass('right')} text-base-content tabular-nums`}
diff --git a/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx b/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx
index da75a9cef2..cc745e8407 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx
@@ -1,4 +1,3 @@
-import { useLocation } from '@solidjs/router';
import ShipWheelIcon from 'lucide-solid/icons/ship-wheel';
import { Show, createMemo } from 'solid-js';
import { WorkloadsSurface } from '@/components/Workloads/WorkloadsSurface';
@@ -11,41 +10,30 @@ import {
import { KubernetesClustersTable } from './KubernetesClustersTable';
import { KubernetesDeploymentsTable } from './KubernetesDeploymentsTable';
import { KubernetesNodesTable } from './KubernetesNodesTable';
-import {
- KUBERNETES_TAB_SPECS,
- buildKubernetesPageModel,
- type KubernetesPageTabId,
-} from './kubernetesPageModel';
+import { KUBERNETES_TAB_SPECS, buildKubernetesPageModel } from './kubernetesPageModel';
// Include `agent` rows so K8s nodes that the backend registry merged onto
// the linked agent host (sources=['agent','kubernetes']) still appear in the
-// Nodes tab; the page model filters them down to those tagged kubernetes.
+// Nodes section of the Overview stack; the page model filters them down to
+// those tagged kubernetes.
const KUBERNETES_RESOURCE_QUERY = 'type=k8s-cluster,k8s-node,pod,k8s-deployment,agent';
const KUBERNETES_PLATFORM_FILTER = 'kubernetes';
-const VALID_TABS = new Set<KubernetesPageTabId>(KUBERNETES_TAB_SPECS.map((tab) => tab.id));
const k8sIcon = () => <ShipWheelIcon class="h-6 w-6 text-slate-400" />;
export function KubernetesPageSurface() {
- const location = useLocation();
const { resources, loading, error, refetch } = useUnifiedResources({
query: KUBERNETES_RESOURCE_QUERY,
cacheKey: 'kubernetes-workspace',
initialHydration: 'prefer-ws-then-rest',
});
- const activeTab = createMemo<KubernetesPageTabId>(() => {
- const segment = location.pathname.split('/').filter(Boolean)[1] as
- | KubernetesPageTabId
- | undefined;
- return segment && VALID_TABS.has(segment) ? segment : 'overview';
- });
const model = createMemo(() => buildKubernetesPageModel(resources()));
return (
<div data-testid="kubernetes-page" class="space-y-3">
<PlatformSectionTabs
tabs={KUBERNETES_TAB_SPECS}
- active={activeTab()}
+ active="overview"
ariaLabel="Kubernetes sections"
/>
@@ -79,55 +67,22 @@ export function KubernetesPageSurface() {
/>
}
>
- <Show when={activeTab() === 'overview'}>
- <div class="space-y-4">
- <KubernetesClustersTable
- clusters={model().clusters}
- scope={model().resources}
- emptyIcon={k8sIcon()}
- emptyTitle="No clusters reported"
- emptyDescription="Kubernetes clusters appear here once at least one agent reports cluster context."
- showToolbar={false}
- />
- <KubernetesNodesTable
- resources={model().nodes}
- emptyIcon={k8sIcon()}
- emptyTitle="No nodes reported"
- emptyDescription="Kubernetes nodes appear here as soon as the agent enumerates them."
- showToolbar={false}
- />
- <WorkloadsSurface
- vms={[]}
- containers={[]}
- nodes={[]}
- useWorkloads
- embedded
- tableOnly
- showFilterToolbar
- suppressPlatformFilter
- forcedPlatform={KUBERNETES_PLATFORM_FILTER}
- compactGroupHeaders
- />
- <Show when={model().deployments.length > 0}>
- <KubernetesDeploymentsTable
- resources={model().deployments}
- emptyIcon={k8sIcon()}
- emptyTitle="No deployments reported"
- emptyDescription="Deployments appear here once the cluster reports them."
- showToolbar={false}
- />
- </Show>
- </div>
- </Show>
- <Show when={activeTab() === 'nodes'}>
+ <div class="space-y-4">
+ <KubernetesClustersTable
+ clusters={model().clusters}
+ scope={model().resources}
+ emptyIcon={k8sIcon()}
+ emptyTitle="No clusters reported"
+ emptyDescription="Kubernetes clusters appear here once at least one agent reports cluster context."
+ showToolbar={false}
+ />
<KubernetesNodesTable
resources={model().nodes}
emptyIcon={k8sIcon()}
emptyTitle="No nodes reported"
emptyDescription="Kubernetes nodes appear here as soon as the agent enumerates them."
+ showToolbar={false}
/>
- </Show>
- <Show when={activeTab() === 'pods'}>
<WorkloadsSurface
vms={[]}
containers={[]}
@@ -138,16 +93,18 @@ export function KubernetesPageSurface() {
showFilterToolbar
suppressPlatformFilter
forcedPlatform={KUBERNETES_PLATFORM_FILTER}
+ compactGroupHeaders
/>
- </Show>
- <Show when={activeTab() === 'deployments'}>
- <KubernetesDeploymentsTable
- resources={model().deployments}
- emptyIcon={k8sIcon()}
- emptyTitle="No deployments reported"
- emptyDescription="Deployments appear here once the cluster reports them."
- />
- </Show>
+ <Show when={model().deployments.length > 0}>
+ <KubernetesDeploymentsTable
+ resources={model().deployments}
+ emptyIcon={k8sIcon()}
+ emptyTitle="No deployments reported"
+ emptyDescription="Deployments appear here once the cluster reports them."
+ showToolbar={false}
+ />
+ </Show>
+ </div>
</Show>
</Show>
</Show>
diff --git a/frontend-modern/src/features/kubernetes/__tests__/kubernetesPageModel.test.ts b/frontend-modern/src/features/kubernetes/__tests__/kubernetesPageModel.test.ts
index 0492661d60..1a6edbe33d 100644
--- a/frontend-modern/src/features/kubernetes/__tests__/kubernetesPageModel.test.ts
+++ b/frontend-modern/src/features/kubernetes/__tests__/kubernetesPageModel.test.ts
@@ -15,13 +15,8 @@ const makeResource = (resource: Partial<Resource> & Pick<Resource, 'id' | 'type'
});
describe('kubernetesPageModel', () => {
- it('declares the Kubernetes section set, omitting Services until the canonical projection exists', () => {
- expect(KUBERNETES_TAB_SPECS.map((tab) => tab.id)).toEqual([
- 'overview',
- 'nodes',
- 'pods',
- 'deployments',
- ]);
+ it('declares the Kubernetes section set as a single Overview tab', () => {
+ expect(KUBERNETES_TAB_SPECS.map((tab) => tab.id)).toEqual(['overview']);
});
it('buckets clusters, nodes, pods, and deployments', () => {
diff --git a/frontend-modern/src/features/kubernetes/kubernetesPageModel.ts b/frontend-modern/src/features/kubernetes/kubernetesPageModel.ts
index 6aa506040a..2ac2c94b70 100644
--- a/frontend-modern/src/features/kubernetes/kubernetesPageModel.ts
+++ b/frontend-modern/src/features/kubernetes/kubernetesPageModel.ts
@@ -1,11 +1,16 @@
import { resolveResourcePlatformType } from '@/utils/sourcePlatforms';
import type { Resource, ResourceType } from '@/types/resource';
-// Kubernetes services are not surfaced by the canonical unified resource
-// model today (no ResourceTypeK8sService projection on the backend), so the
-// Services sub-tab is intentionally absent from the page until that gap is
-// closed in the canonical adapter.
-export type KubernetesPageTabId = 'overview' | 'nodes' | 'pods' | 'deployments';
+// The Overview tab mirrors Proxmox / Docker: cluster + nodes table on top,
+// embedded WorkloadsSurface (pods) underneath, deployments table beneath
+// that when the cluster reports any. The standalone Nodes / Pods /
+// Deployments tabs that used to live here were pure duplicates of the
+// Overview stack, so they're intentionally absent — the Workloads filter
+// inside Overview owns search/grouping for pods. Services are not surfaced
+// by the canonical unified resource model today (no ResourceTypeK8sService
+// projection on the backend), so a Services tab is similarly absent until
+// that gap is closed in the canonical adapter.
+export type KubernetesPageTabId = 'overview';
export type KubernetesTabSpec = {
id: KubernetesPageTabId;
@@ -14,10 +19,7 @@ export type KubernetesTabSpec = {
};
export const KUBERNETES_TAB_SPECS: readonly KubernetesTabSpec[] = [
- { id: 'overview', label: 'Clusters', path: '/kubernetes/overview' },
- { id: 'nodes', label: 'Nodes', path: '/kubernetes/nodes' },
- { id: 'pods', label: 'Pods', path: '/kubernetes/pods' },
- { id: 'deployments', label: 'Deployments', path: '/kubernetes/deployments' },
+ { id: 'overview', label: 'Overview', path: '/kubernetes/overview' },
] as const;
const KUBERNETES_RESOURCE_TYPES = new Set<ResourceType>([