Skip to content

Commit

Permalink
frontend: Add pod metrics to owned pods section
Browse files Browse the repository at this point in the history
Signed-off-by: Oleksandr Dubenko <[email protected]>
  • Loading branch information
sniok committed Dec 10, 2024
1 parent 87b3df4 commit 72f6e1a
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 0 deletions.
6 changes: 6 additions & 0 deletions frontend/src/components/common/Resource/Resource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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';
Expand Down Expand Up @@ -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;

Expand All @@ -984,6 +989,7 @@ export function OwnedPodsSection(props: OwnedPodsSectionProps) {
hideColumns={hideColumns || onlyOneNamespace ? ['namespace'] : undefined}
pods={pods}
error={error}
metrics={podMetrics}
noNamespaceFilter={hideNamespaceFilter}
/>
);
Expand Down
25 changes: 25 additions & 0 deletions frontend/src/components/namespace/NamespaceDetails.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -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',
},
},
],
},
],
})
),
],
},
},
Expand Down

0 comments on commit 72f6e1a

Please sign in to comment.