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.

Add Kubernetes services native table

rcourtmanaa14a9664435
diff --git a/docs/release-control/v6/internal/subsystems/frontend-primitives.md b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
index 2e1950f419..2d412cea32 100644
--- a/docs/release-control/v6/internal/subsystems/frontend-primitives.md
+++ b/docs/release-control/v6/internal/subsystems/frontend-primitives.md
@@ -179,11 +179,13 @@ Secret rows: the shared table wording may indicate metadata-only inventory, but
must not imply payload fields were read when the agent used Kubernetes
metadata-only API responses. Kubernetes Node inventory must also be reachable
through a dedicated native tab, not only the overview stack, while retaining the
-shared `PlatformSectionTabs` shell. Kubernetes storage inventory must likewise
+shared `PlatformSectionTabs` shell. Kubernetes Service inventory must likewise
stay on the shared tab, toolbar, table, table-alignment, and inline-detail
-primitives while the unified-resource owner supplies StorageClass,
+primitives while the unified-resource owner supplies Service type, virtual IP,
+published port, and selector columns. Kubernetes storage inventory follows that
+same primitive boundary while the unified-resource owner supplies StorageClass,
PersistentVolume, and PersistentVolumeClaim-specific columns. Kubernetes
-networking inventory follows that same primitive boundary while the
+networking inventory also follows that same primitive boundary while the
unified-resource owner supplies Service, Ingress, and EndpointSlice-specific
columns.
diff --git a/docs/release-control/v6/internal/subsystems/monitoring.md b/docs/release-control/v6/internal/subsystems/monitoring.md
index 64aee3a6ce..0f4a6d90d0 100644
--- a/docs/release-control/v6/internal/subsystems/monitoring.md
+++ b/docs/release-control/v6/internal/subsystems/monitoring.md
@@ -198,12 +198,13 @@ truth for live infrastructure data.
the report contract. Mock/demo Kubernetes ConfigMap and Secret inventory
must mirror the current metadata-only trust boundary rather than seeding
payload key names. Mock/demo Kubernetes inventory must also seed
- representative Service, Ingress, EndpointSlice, storage-class,
- persistent-volume, and persistent-volume-claim rows so the native
- networking and storage tabs exercise the same report/resource contract as
- live agents. Monitoring must preserve those objects as native cluster
- inventory instead of flattening them into pods, deployments, or generic
- networking, storage, or configuration rows.
+ representative Service rows with ClusterIP, external IP, ServicePort,
+ targetPort, nodePort, and selector metadata, plus Ingress, EndpointSlice,
+ storage-class, persistent-volume, and persistent-volume-claim rows so the
+ native services, networking, and storage tabs exercise the same
+ report/resource contract as live agents. Monitoring must preserve those
+ objects as native cluster inventory instead of flattening them into pods,
+ deployments, or generic networking, storage, or configuration rows.
## Forbidden Paths
diff --git a/docs/release-control/v6/internal/subsystems/unified-resources.md b/docs/release-control/v6/internal/subsystems/unified-resources.md
index 21b3e82ce9..8ac5ef7fd2 100644
--- a/docs/release-control/v6/internal/subsystems/unified-resources.md
+++ b/docs/release-control/v6/internal/subsystems/unified-resources.md
@@ -131,6 +131,7 @@ cross-source deduplication.
107. `frontend-modern/src/features/kubernetes/KubernetesNodesTable.tsx`
108. `frontend-modern/src/features/kubernetes/KubernetesStorageTable.tsx`
109. `frontend-modern/src/features/kubernetes/KubernetesNetworkingTable.tsx`
+110. `frontend-modern/src/features/kubernetes/KubernetesServicesTable.tsx`
## Shared Boundaries
@@ -273,6 +274,11 @@ reintroduce false Swarm capability surfaces.
Kubernetes Node inventory is an API-native resource surface, not merely
overview chrome: `/kubernetes/nodes` must expose the bespoke node table while
the overview may still include the same rows for cluster orientation.
+ Kubernetes Service inventory is likewise API-native: `/kubernetes/services`
+ must render Service rows through a service-specific table that preserves
+ cluster/namespace scope, Service type, ClusterIP, external IP metadata,
+ ServicePort/targetPort/nodePort publication, and selectors instead of
+ routing those API objects through the generic Kubernetes inventory table.
Kubernetes storage inventory is likewise API-native: `/kubernetes/storage`
must render StorageClass, PersistentVolume, and PersistentVolumeClaim rows
through a storage-specific table that preserves cluster scope, binding mode
diff --git a/frontend-modern/src/features/kubernetes/KubernetesInventoryTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesInventoryTable.tsx
index fa96538b4e..9745af8231 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesInventoryTable.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesInventoryTable.tsx
@@ -28,23 +28,12 @@ import {
} from '@/features/platformPage/sharedPlatformPage';
import type { Resource } from '@/types/resource';
-type KubernetesInventoryVariant =
- | 'controllers'
- | 'services'
- | 'config'
- | 'policy'
- | 'autoscaling'
- | 'events';
+type KubernetesInventoryVariant = 'controllers' | 'config' | 'policy' | 'autoscaling' | 'events';
const textValue = (value: string | undefined): string => asTrimmedString(value) || '—';
const numberValue = (value: number | undefined): JSX.Element => (
<span class="tabular-nums">{value ?? 0}</span>
);
-const joinValues = (values: readonly (string | undefined)[] | undefined): string =>
- (values ?? [])
- .map((value) => asTrimmedString(value))
- .filter((value): value is string => typeof value === 'string' && value.length > 0)
- .join(', ') || '—';
const k8sKind = (resource: Resource): string =>
resource.kubernetes?.resourceKind || getResourceTypeLabel(resource.type) || resource.type;
@@ -54,8 +43,6 @@ const tableTitle = (variant: KubernetesInventoryVariant, explicit?: string): str
switch (variant) {
case 'controllers':
return 'Controllers';
- case 'services':
- return 'Services';
case 'config':
return 'Config';
case 'policy':
@@ -147,19 +134,6 @@ const KubernetesInventoryHeader: Component<{ variant: KubernetesInventoryVariant
>
Namespace
</TableHead>
- <Show when={props.variant === 'services'}>
- <TableHead class={`${getPlatformTableHeadClassForKind('text')} md:w-[14%]`}>Type</TableHead>
- <TableHead
- class={`${getPlatformTableHeadClassForKind('text')} hidden md:table-cell md:w-[20%]`}
- >
- Address
- </TableHead>
- <TableHead
- class={`${getPlatformTableHeadClassForKind('text')} hidden md:table-cell md:w-[25%]`}
- >
- Ports / Hosts
- </TableHead>
- </Show>
<Show when={props.variant === 'controllers'}>
<TableHead class={`${getPlatformTableHeadClassForKind('numeric-value')} md:w-[10%]`}>
Desired
@@ -240,48 +214,6 @@ const KubernetesInventoryRow: Component<{
const name = () => asTrimmedString(props.resource.name) || props.resource.id;
const namespace = () => textValue(props.resource.kubernetes?.namespace);
const kind = () => k8sKind(props.resource);
- const address = () =>
- textValue(
- props.resource.kubernetes?.clusterIp ||
- props.resource.kubernetes?.addresses?.[0] ||
- props.resource.kubernetes?.externalIps?.[0] ||
- (typeof props.resource.kubernetes?.endpointCount === 'number'
- ? `${props.resource.kubernetes.endpointCount} endpoints`
- : undefined),
- );
- const ports = () =>
- joinValues(
- props.resource.kubernetes?.servicePorts?.length
- ? props.resource.kubernetes.servicePorts.map((port) => {
- const protocol = port.protocol ? `/${port.protocol.toLowerCase()}` : '';
- const target = port.targetPort ? `:${port.targetPort}` : '';
- return port.port ? `${port.port}${target}${protocol}` : undefined;
- })
- : props.resource.kubernetes?.endpointPorts?.length
- ? props.resource.kubernetes.endpointPorts.map((port) => {
- const protocol = port.protocol ? `/${port.protocol.toLowerCase()}` : '';
- return port.port ? `${port.port}${protocol}` : undefined;
- })
- : props.resource.kubernetes?.hosts?.length
- ? props.resource.kubernetes.hosts
- : props.resource.kubernetes?.policyTypes?.length
- ? props.resource.kubernetes.policyTypes
- : [
- typeof props.resource.kubernetes?.ingressRuleCount === 'number'
- ? `${props.resource.kubernetes.ingressRuleCount} ingress`
- : undefined,
- typeof props.resource.kubernetes?.egressRuleCount === 'number'
- ? `${props.resource.kubernetes.egressRuleCount} egress`
- : undefined,
- ],
- );
- const networkType = () =>
- textValue(
- props.resource.kubernetes?.serviceType ||
- props.resource.kubernetes?.className ||
- props.resource.kubernetes?.addressType ||
- props.resource.kubernetes?.policyTypes?.join(', '),
- );
const configState = () =>
textValue(
props.resource.kubernetes?.phase ||
@@ -406,21 +338,6 @@ const KubernetesInventoryRow: Component<{
>
{namespace()}
</TableCell>
- <Show when={props.variant === 'services'}>
- <TableCell class={`${getPlatformTableCellClassForKind('text')} text-base-content`}>
- {networkType()}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
- >
- {address()}
- </TableCell>
- <TableCell
- class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
- >
- {ports()}
- </TableCell>
- </Show>
<Show when={props.variant === 'controllers'}>
<TableCell class={`${getPlatformTableCellClassForKind('numeric-value')} text-base-content`}>
{numberValue(desired())}
diff --git a/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx b/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx
index f3a5742021..b816ad093e 100644
--- a/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx
+++ b/frontend-modern/src/features/kubernetes/KubernetesPageSurface.tsx
@@ -18,6 +18,7 @@ import { KubernetesDeploymentsTable } from './KubernetesDeploymentsTable';
import { KubernetesInventoryTable } from './KubernetesInventoryTable';
import { KubernetesNetworkingTable } from './KubernetesNetworkingTable';
import { KubernetesNodesTable } from './KubernetesNodesTable';
+import { KubernetesServicesTable } from './KubernetesServicesTable';
import { KubernetesStorageTable } from './KubernetesStorageTable';
import {
KUBERNETES_TAB_SPECS,
@@ -112,9 +113,8 @@ export function KubernetesPageSurface() {
<KubernetesWorkloads model={model} />
</Show>
<Show when={activeTab() === 'services'}>
- <KubernetesInventoryTable
+ <KubernetesServicesTable
resources={model().services}
- variant="services"
emptyIcon={k8sIcon()}
emptyTitle="No services reported"
emptyDescription="Services appear here once the agent can read Service resources."
diff --git a/frontend-modern/src/features/kubernetes/KubernetesServicesTable.tsx b/frontend-modern/src/features/kubernetes/KubernetesServicesTable.tsx
new file mode 100644
index 0000000000..a87f41a6fa
--- /dev/null
+++ b/frontend-modern/src/features/kubernetes/KubernetesServicesTable.tsx
@@ -0,0 +1,281 @@
+import { For, Show, type Component, type JSX } from 'solid-js';
+import { StatusDot } from '@/components/shared/StatusDot';
+import { TableCard } from '@/components/shared/TableCard';
+import { TableCardHeader } from '@/components/shared/TableCardHeader';
+import {
+ Table,
+ TableBody,
+ TableCell,
+ TableHead,
+ TableHeader,
+ TableRow,
+} from '@/components/shared/Table';
+import { getSimpleStatusIndicator } from '@/utils/status';
+import { asTrimmedString } from '@/utils/stringUtils';
+import {
+ PLATFORM_HEALTH_FILTER_OPTIONS,
+ PLATFORM_TABLE_BODY_CLASS,
+ PLATFORM_TABLE_CARD_CLASS,
+ PLATFORM_TABLE_HEADER_ROW_CLASS,
+ PlatformTableEmptyState,
+ PlatformTableToolbar,
+ createPlatformTableFilterState,
+ filterPlatformResources,
+ getPlatformTableCellClassForKind,
+ getPlatformTableHeadClassForKind,
+ type PlatformResourceStatusFilter,
+} from '@/features/platformPage/sharedPlatformPage';
+import {
+ PlatformResourceDetailTableRow,
+ createPlatformResourceDetailState,
+ createPlatformResourceLabelResolver,
+ getPlatformResourceDetailRowClass,
+} from '@/features/platformPage/PlatformResourceDetailTableRow';
+import type { Resource } from '@/types/resource';
+
+// Services have a distinct API contract from Ingress and EndpointSlice:
+// operators need the Service type, virtual IP, exposed ports, node ports, and
+// selector together rather than in a generic networking/detail table.
+
+const textValue = (value: string | undefined): string => asTrimmedString(value) || '—';
+
+const serviceName = (resource: Resource): string =>
+ asTrimmedString(resource.displayName) || asTrimmedString(resource.name) || resource.id;
+
+const serviceScope = (resource: Resource): string => {
+ const cluster =
+ asTrimmedString(resource.kubernetes?.clusterId) ||
+ asTrimmedString(resource.kubernetes?.clusterName);
+ const namespace = asTrimmedString(resource.kubernetes?.namespace);
+ if (namespace) return cluster ? `${cluster}/${namespace}` : namespace;
+ return cluster || 'Cluster';
+};
+
+const summarizeValues = (
+ values: readonly (string | undefined)[] | undefined,
+ visible = 2,
+): { label: string; title: string } => {
+ const normalized = (values ?? [])
+ .map((value) => asTrimmedString(value))
+ .filter((value): value is string => typeof value === 'string' && value.length > 0);
+ if (normalized.length === 0) return { label: '—', title: '' };
+ const shown = normalized.slice(0, visible);
+ const suffix = normalized.length > shown.length ? ` +${normalized.length - shown.length}` : '';
+ return { label: `${shown.join(', ')}${suffix}`, title: normalized.join(', ') };
+};
+
+const portSummary = (resource: Resource): { label: string; title: string } => {
+ const ports = resource.kubernetes?.servicePorts ?? [];
+ const labels = ports.map((port) => {
+ if (!port.port) return undefined;
+ const protocol = port.protocol ? `/${port.protocol.toLowerCase()}` : '';
+ const target = port.targetPort ? `:${port.targetPort}` : '';
+ const nodePort = port.nodePort ? ` node:${port.nodePort}` : '';
+ return `${port.port}${target}${protocol}${nodePort}`;
+ });
+ return summarizeValues(labels, 2);
+};
+
+const selectorSummary = (resource: Resource): { label: string; title: string } => {
+ const selector = resource.kubernetes?.selector;
+ if (!selector || Object.keys(selector).length === 0) return { label: '—', title: '' };
+ const pairs = Object.entries(selector)
+ .sort(([left], [right]) => left.localeCompare(right))
+ .map(([key, value]) => `${key}=${value}`);
+ return summarizeValues(pairs, 2);
+};
+
+const externalIpSummary = (resource: Resource): { label: string; title: string } =>
+ summarizeValues(resource.kubernetes?.externalIps);
+
+export const KubernetesServicesTable: Component<{
+ resources: Resource[];
+ emptyIcon: JSX.Element;
+ emptyTitle: string;
+ emptyDescription: string;
+ title?: string;
+ showToolbar?: boolean;
+}> = (props) => {
+ const tableState = createPlatformTableFilterState({
+ resources: () => props.resources,
+ initialStatus: 'all' as PlatformResourceStatusFilter,
+ filter: filterPlatformResources,
+ });
+ const drawer = createPlatformResourceDetailState({ idPrefix: 'kubernetes-service-drawer' });
+ const resolveResourceLabel = createPlatformResourceLabelResolver(() => props.resources);
+
+ return (
+ <Show
+ when={props.resources.length > 0}
+ fallback={
+ <PlatformTableEmptyState
+ icon={props.emptyIcon}
+ title={props.emptyTitle}
+ description={props.emptyDescription}
+ />
+ }
+ >
+ <div class="space-y-3">
+ <Show when={props.showToolbar !== false}>
+ <PlatformTableToolbar
+ search={tableState.search}
+ onSearchChange={tableState.setSearch}
+ searchPlaceholder="Search services"
+ status={tableState.status()}
+ onStatusChange={tableState.setStatus}
+ statusOptions={PLATFORM_HEALTH_FILTER_OPTIONS}
+ visible={tableState.visible()}
+ total={tableState.total()}
+ rowNoun="services"
+ />
+ </Show>
+
+ <Show
+ when={tableState.filtered().length > 0}
+ fallback={
+ <PlatformTableEmptyState
+ icon={props.emptyIcon}
+ title="No services match current filters"
+ description="Adjust the search or status filter to see more Kubernetes services."
+ />
+ }
+ >
+ <TableCard class={PLATFORM_TABLE_CARD_CLASS}>
+ <TableCardHeader title={props.title ?? 'Services'} />
+ <Table class="min-w-full table-fixed text-xs md:min-w-[1120px]">
+ <TableHeader>
+ <TableRow class={PLATFORM_TABLE_HEADER_ROW_CLASS}>
+ <TableHead class={`${getPlatformTableHeadClassForKind('name')} md:w-[19%]`}>
+ Service
+ </TableHead>
+ <TableHead
+ class={`${getPlatformTableHeadClassForKind('text')} hidden md:table-cell md:w-[15%]`}
+ >
+ Scope
+ </TableHead>
+ <TableHead class={`${getPlatformTableHeadClassForKind('text')} md:w-[11%]`}>
+ Type
+ </TableHead>
+ <TableHead class={`${getPlatformTableHeadClassForKind('text')} md:w-[13%]`}>
+ Cluster IP
+ </TableHead>
+ <TableHead
+ class={`${getPlatformTableHeadClassForKind('text')} hidden md:table-cell md:w-[13%]`}
+ >
+ External IPs
+ </TableHead>
+ <TableHead class={`${getPlatformTableHeadClassForKind('text')} md:w-[16%]`}>
+ Ports
+ </TableHead>
+ <TableHead
+ class={`${getPlatformTableHeadClassForKind('text')} hidden md:table-cell md:w-[13%]`}
+ >
+ Selector
+ </TableHead>
+ </TableRow>
+ </TableHeader>
+ <TableBody class={PLATFORM_TABLE_BODY_CLASS}>
+ <For each={tableState.filtered()}>
+ {(resource) => {
+ const indicator = () => getSimpleStatusIndicator(resource.status);
+ const name = () => serviceName(resource);
+ const scope = () => serviceScope(resource);
+ const serviceType = () => textValue(resource.kubernetes?.serviceType);
+ const clusterIp = () => textValue(resource.kubernetes?.clusterIp);
+ const externalIps = () => externalIpSummary(resource);
+ const ports = () => portSummary(resource);
+ const selector = () => selectorSummary(resource);
+ const detailRowId = () => drawer.detailRowId(resource);
+ const isExpanded = () => drawer.isExpanded(resource);
+
+ return (
+ <>
+ <TableRow
+ class={`${getPlatformResourceDetailRowClass(isExpanded())} text-[11px] sm:text-xs`}
+ aria-controls={isExpanded() ? detailRowId() : undefined}
+ aria-expanded={isExpanded() ? 'true' : 'false'}
+ data-kubernetes-service-row={resource.id}
+ onClick={() => drawer.toggle(resource)}
+ onKeyDown={drawer.handleActivationKey(resource)}
+ tabIndex={0}
+ >
+ <TableCell class={getPlatformTableCellClassForKind('name')}>
+ <div class="flex min-w-0 items-center gap-2">
+ <StatusDot
+ size="sm"
+ variant={indicator().variant}
+ title={resource.status || 'unknown'}
+ ariaHidden
+ />
+ <span class="truncate font-semibold text-base-content" title={name()}>
+ {name()}
+ </span>
+ </div>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
+ >
+ <span class="inline-block max-w-[12rem] truncate" title={scope()}>
+ {scope()}
+ </span>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ {serviceType()}
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ {clusterIp()}
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
+ >
+ <span
+ class="inline-block max-w-[12rem] truncate"
+ title={externalIps().title}
+ >
+ {externalIps().label}
+ </span>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} text-base-content`}
+ >
+ <span class="inline-block max-w-[15rem] truncate" title={ports().title}>
+ {ports().label}
+ </span>
+ </TableCell>
+ <TableCell
+ class={`${getPlatformTableCellClassForKind('text')} hidden text-base-content md:table-cell`}
+ >
+ <span
+ class="inline-block max-w-[13rem] truncate"
+ title={selector().title}
+ >
+ {selector().label}
+ </span>
+ </TableCell>
+ </TableRow>
+ <PlatformResourceDetailTableRow
+ resource={resource}
+ open={isExpanded()}
+ detailRowId={detailRowId()}
+ colSpan={7}
+ resolveResourceLabel={resolveResourceLabel}
+ onClose={() => drawer.close(resource)}
+ />
+ </>
+ );
+ }}
+ </For>
+ </TableBody>
+ </Table>
+ </TableCard>
+ </Show>
+ </div>
+ </Show>
+ );
+};
+
+export default KubernetesServicesTable;
diff --git a/frontend-modern/src/features/kubernetes/__tests__/KubernetesPageSurface.contract.test.tsx b/frontend-modern/src/features/kubernetes/__tests__/KubernetesPageSurface.contract.test.tsx
index c479bac376..d98bb5560d 100644
--- a/frontend-modern/src/features/kubernetes/__tests__/KubernetesPageSurface.contract.test.tsx
+++ b/frontend-modern/src/features/kubernetes/__tests__/KubernetesPageSurface.contract.test.tsx
@@ -54,6 +54,10 @@ vi.mock('../KubernetesNodesTable', () => ({
KubernetesNodesTable: () => <div data-testid="nodes-table" />,
}));
+vi.mock('../KubernetesServicesTable', () => ({
+ KubernetesServicesTable: () => <div data-testid="services-table" />,
+}));
+
vi.mock('../KubernetesDeploymentsTable', () => ({
KubernetesDeploymentsTable: () => <div data-testid="deployments-table" />,
}));
@@ -269,6 +273,63 @@ describe('KubernetesPageSurface contract', () => {
expect(screen.queryByTestId('kubernetes-workloads-surface')).not.toBeInTheDocument();
});
+ it('renders Kubernetes services through the service-native table', () => {
+ mockPathname.mockReturnValue('/kubernetes/services');
+ mockUseUnifiedResources.mockReturnValue({
+ resources: () => [
+ {
+ id: 'checkout-api',
+ type: 'k8s-service',
+ name: 'checkout-api',
+ displayName: 'checkout-api',
+ platformId: 'cluster-1',
+ platformType: 'kubernetes',
+ sourceType: 'agent',
+ sources: ['kubernetes'],
+ status: 'online',
+ lastSeen: 1_700_000_000_000,
+ },
+ ],
+ loading: () => false,
+ error: () => null,
+ refetch: vi.fn(),
+ });
+ mockUseWorkloadsState.mockReturnValue({
+ allGuests: () => [],
+ clearPinnedSummaryScope: vi.fn(),
+ containerRuntimeFilterConfig: () => undefined,
+ focusedSummaryWorkloadGroupId: () => null,
+ groupingMode: () => 'grouped',
+ handleBeforeAutoFocus: vi.fn(),
+ search: () => '',
+ selectedGuestId: () => null,
+ setGroupingMode: vi.fn(),
+ setMetricDisplayMode: vi.fn(),
+ setSearch: vi.fn(),
+ setSortDirection: vi.fn(),
+ setSortKey: vi.fn(),
+ setStatusMode: vi.fn(),
+ setViewMode: vi.fn(),
+ setWorkloadMetricHistoryRange: vi.fn(),
+ statusMode: () => 'all',
+ surfaceConnected: () => false,
+ surfaceInitialDataReceived: () => false,
+ viewMode: () => 'pod',
+ workloadMetricDisplayMode: () => 'bars',
+ workloadMetricHistoryRange: () => '1h',
+ workloadsFilterColumnVisibility: () => undefined,
+ });
+
+ render(() => (
+ <Router>
+ <Route path="/" component={KubernetesPageSurface} />
+ </Router>
+ ));
+
+ expect(screen.getByTestId('services-table')).toBeInTheDocument();
+ expect(screen.queryByTestId('kubernetes-workloads-surface')).not.toBeInTheDocument();
+ });
+
it('renders Kubernetes networking inventory through the networking-native table', () => {
mockPathname.mockReturnValue('/kubernetes/networking');
mockUseUnifiedResources.mockReturnValue({
diff --git a/frontend-modern/src/features/kubernetes/__tests__/KubernetesServicesTable.test.tsx b/frontend-modern/src/features/kubernetes/__tests__/KubernetesServicesTable.test.tsx
new file mode 100644
index 0000000000..f2b18efdb0
--- /dev/null
+++ b/frontend-modern/src/features/kubernetes/__tests__/KubernetesServicesTable.test.tsx
@@ -0,0 +1,78 @@
+import { cleanup, render, screen } from '@solidjs/testing-library';
+import { afterEach, describe, expect, it } from 'vitest';
+
+import type { Resource } from '@/types/resource';
+import { KubernetesServicesTable } from '../KubernetesServicesTable';
+
+const makeResource = ({
+ id,
+ type,
+ ...overrides
+}: Partial<Resource> & Pick<Resource, 'id' | 'type'>): Resource => ({
+ id,
+ name: id,
+ displayName: id,
+ platformId: 'cluster-1',
+ platformType: 'kubernetes',
+ sourceType: 'agent',
+ sources: ['kubernetes'],
+ status: 'online',
+ type,
+ lastSeen: 1_700_000_000_000,
+ ...overrides,
+});
+
+afterEach(() => {
+ cleanup();
+});
+
+describe('KubernetesServicesTable', () => {
+ it('renders Service fields from the Kubernetes Service API contract', () => {
+ render(() => (
+ <KubernetesServicesTable
+ resources={[
+ makeResource({
+ id: 'checkout-public',
+ type: 'k8s-service',
+ kubernetes: {
+ clusterId: 'cluster-1',
+ namespace: 'apps',
+ resourceKind: 'Service',
+ serviceType: 'NodePort',
+ clusterIp: '10.96.12.20',
+ externalIps: ['203.0.113.24'],
+ servicePorts: [
+ {
+ name: 'https',
+ protocol: 'TCP',
+ port: 443,
+ targetPort: '8443',
+ nodePort: 30443,
+ },
+ ],
+ selector: {
+ app: 'checkout-web',
+ tier: 'frontend',
+ },
+ },
+ }),
+ ]}
+ emptyIcon={<span />}
+ emptyTitle="No services"
+ emptyDescription="No services"
+ showToolbar={false}
+ />
+ ));
+
+ expect(screen.getByText('Service')).toBeInTheDocument();
+ expect(screen.getByText('Scope')).toBeInTheDocument();
+ expect(screen.getByText('Cluster IP')).toBeInTheDocument();
+ expect(screen.getByText('External IPs')).toBeInTheDocument();
+ expect(screen.getByText('Selector')).toBeInTheDocument();
+ expect(screen.getByText('NodePort')).toBeInTheDocument();
+ expect(screen.getByText('10.96.12.20')).toBeInTheDocument();
+ expect(screen.getByText('203.0.113.24')).toBeInTheDocument();
+ expect(screen.getByText('443:8443/tcp node:30443')).toBeInTheDocument();
+ expect(screen.getByText('app=checkout-web, tier=frontend')).toBeInTheDocument();
+ });
+});
diff --git a/internal/mock/demo_scenarios.go b/internal/mock/demo_scenarios.go
index 859fe4bcdb..a63424b23a 100644
--- a/internal/mock/demo_scenarios.go
+++ b/internal/mock/demo_scenarios.go
@@ -640,6 +640,7 @@ func applyDemoKubernetesNativeInventory(cluster *models.KubernetesCluster, now t
}
cluster.Services = []models.KubernetesService{
{UID: cluster.ID + "-svc-checkout-web", Name: "checkout-web", Namespace: "apps", ServiceType: "ClusterIP", ClusterIP: "10.96.12.10", Ports: []models.KubernetesServicePort{{Name: "http", Protocol: "TCP", Port: 80, TargetPort: "8080"}}, Selector: map[string]string{"app.kubernetes.io/name": "checkout-web"}, CreatedAt: createdAt, Labels: labels("checkout-web")},
+ {UID: cluster.ID + "-svc-checkout-public", Name: "checkout-public", Namespace: "apps", ServiceType: "NodePort", ClusterIP: "10.96.12.20", ExternalIPs: []string{"203.0.113.24"}, Ports: []models.KubernetesServicePort{{Name: "https", Protocol: "TCP", Port: 443, TargetPort: "8443", NodePort: 30443}}, Selector: map[string]string{"app.kubernetes.io/name": "checkout-web"}, CreatedAt: createdAt, Labels: labels("checkout-web")},
{UID: cluster.ID + "-svc-checkout-api", Name: "checkout-api", Namespace: "services", ServiceType: "ClusterIP", ClusterIP: "10.96.18.24", Ports: []models.KubernetesServicePort{{Name: "http", Protocol: "TCP", Port: 8080, TargetPort: "8080"}}, Selector: map[string]string{"app.kubernetes.io/name": "checkout-api"}, CreatedAt: createdAt, Labels: labels("checkout-api")},
}
cluster.EndpointSlices = []models.KubernetesEndpointSlice{
diff --git a/internal/mock/generator.go b/internal/mock/generator.go
index 107594bbaa..d416a94dc3 100644
--- a/internal/mock/generator.go
+++ b/internal/mock/generator.go
@@ -1355,10 +1355,14 @@ func generateKubernetesNetworkingInventory(
now time.Time,
) ([]models.KubernetesService, []models.KubernetesIngress, []models.KubernetesEndpointSlice) {
createdAt := now.Add(-68 * time.Hour)
- labels := map[string]string{
+ apiLabels := map[string]string{
"app.kubernetes.io/name": "checkout-api",
"app.kubernetes.io/part-of": "pulse-demo-estate",
}
+ webLabels := map[string]string{
+ "app.kubernetes.io/name": "checkout-web",
+ "app.kubernetes.io/part-of": "pulse-demo-estate",
+ }
services := []models.KubernetesService{
{
UID: clusterID + "-svc-checkout-api",
@@ -1371,7 +1375,21 @@ func generateKubernetesNetworkingInventory(
},
Selector: map[string]string{"app.kubernetes.io/name": "checkout-api"},
CreatedAt: createdAt,
- Labels: cloneStringMap(labels),
+ Labels: cloneStringMap(apiLabels),
+ },
+ {
+ UID: clusterID + "-svc-checkout-public",
+ Name: "checkout-public",
+ Namespace: "apps",
+ ServiceType: "NodePort",
+ ClusterIP: "10.96.12.20",
+ ExternalIPs: []string{"203.0.113.24"},
+ Ports: []models.KubernetesServicePort{
+ {Name: "https", Protocol: "TCP", Port: 443, TargetPort: "8443", NodePort: 30443},
+ },
+ Selector: map[string]string{"app.kubernetes.io/name": "checkout-web"},
+ CreatedAt: createdAt.Add(5 * time.Minute),
+ Labels: cloneStringMap(webLabels),
},
}
ingresses := []models.KubernetesIngress{
@@ -1383,7 +1401,7 @@ func generateKubernetesNetworkingInventory(
Hosts: []string{"checkout.example.test"},
Addresses: []string{"198.51.100.24"},
CreatedAt: createdAt.Add(10 * time.Minute),
- Labels: cloneStringMap(labels),
+ Labels: cloneStringMap(apiLabels),
},
}
endpointSlices := []models.KubernetesEndpointSlice{
@@ -1399,7 +1417,7 @@ func generateKubernetesNetworkingInventory(
{Name: "http", Protocol: "TCP", Port: 8080, AppProtocol: "kubernetes.io/http"},
},
CreatedAt: createdAt.Add(15 * time.Minute),
- Labels: cloneStringMap(labels),
+ Labels: cloneStringMap(apiLabels),
},
}
diff --git a/internal/mock/generator_test.go b/internal/mock/generator_test.go
index 937c94ab71..ffb0dbfe16 100644
--- a/internal/mock/generator_test.go
+++ b/internal/mock/generator_test.go
@@ -445,6 +445,20 @@ func TestBuildFixtureStateIncludesKubernetesNetworkingInventory(t *testing.T) {
if len(cluster.Services) == 0 {
t.Fatal("expected kubernetes service inventory")
}
+ foundPublishedService := false
+ for _, service := range cluster.Services {
+ if service.ServiceType != "NodePort" || len(service.ExternalIPs) == 0 {
+ continue
+ }
+ for _, port := range service.Ports {
+ if port.NodePort > 0 {
+ foundPublishedService = true
+ }
+ }
+ }
+ if !foundPublishedService {
+ t.Fatal("expected kubernetes service inventory to include node-port/external service metadata")
+ }
if len(cluster.Ingresses) == 0 {
t.Fatal("expected kubernetes ingress inventory")
}