diff --git a/frontend/src/components/common/Resource/Resource.tsx b/frontend/src/components/common/Resource/Resource.tsx index 26777726d0..dac01c830b 100644 --- a/frontend/src/components/common/Resource/Resource.tsx +++ b/frontend/src/components/common/Resource/Resource.tsx @@ -25,6 +25,7 @@ import { KubeObject } from '../../../lib/k8s/KubeObject'; import { KubeObjectInterface } from '../../../lib/k8s/KubeObject'; import { KubeObjectClass } from '../../../lib/k8s/KubeObject'; import Pod, { KubePod, KubeVolume } from '../../../lib/k8s/pod'; +import { METRIC_REFETCH_INTERVAL_MS, PodMetrics } from '../../../lib/k8s/PodMetrics'; import { createRouteURL, RouteURLProps } from '../../../lib/router'; import { getThemeName } from '../../../lib/themes'; import { localeDate, useId } from '../../../lib/util'; @@ -976,6 +977,10 @@ export function OwnedPodsSection(props: OwnedPodsSectionProps) { }; const [pods, error] = Pod.useList(queryData); + const { items: podMetrics } = PodMetrics.useList({ + ...queryData, + refetchInterval: METRIC_REFETCH_INTERVAL_MS, + }); const onlyOneNamespace = !!resource.metadata.namespace || resource.kind === 'Namespace'; const hideNamespaceFilter = onlyOneNamespace || noSearch; @@ -984,6 +989,7 @@ export function OwnedPodsSection(props: OwnedPodsSectionProps) { hideColumns={hideColumns || onlyOneNamespace ? ['namespace'] : undefined} pods={pods} error={error} + metrics={podMetrics} noNamespaceFilter={hideNamespaceFilter} /> ); diff --git a/frontend/src/components/namespace/NamespaceDetails.stories.tsx b/frontend/src/components/namespace/NamespaceDetails.stories.tsx index 0a3a4c3496..cc952d4c56 100644 --- a/frontend/src/components/namespace/NamespaceDetails.stories.tsx +++ b/frontend/src/components/namespace/NamespaceDetails.stories.tsx @@ -69,6 +69,31 @@ Active.parameters = { http.get('http://localhost:4466/api/v1/resourcequotas', () => HttpResponse.error()), http.get('http://localhost:4466/api/v1/limitranges', () => HttpResponse.error()), http.get('http://localhost:4466/api/v1/pods', () => HttpResponse.error()), + http.get( + 'http://localhost:4466/apis/metrics.k8s.io/v1beta1/namespaces/my-namespaces/pods', + () => + HttpResponse.json({ + kind: 'PodMetricsList', + apiVersion: 'metrics.k8s.io/v1beta1', + metadata: {}, + items: [ + { + metadata: { + name: 'successful', + }, + containers: [ + { + name: 'etcd', + usage: { + cpu: '16317640n', + memory: '47544Ki', + }, + }, + ], + }, + ], + }) + ), ], }, },