Skip to content

Commit fe7756a

Browse files
committed
frontend: Add hostIPs and podIPs to pod
1 parent 60889c5 commit fe7756a

10 files changed

+183
-7219
lines changed

frontend/src/components/pod/Details.tsx

Lines changed: 92 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -410,6 +410,97 @@ export default function PodDetails(props: PodDetailsProps) {
410410
const [isAttached, setIsAttached] = React.useState(false);
411411
const dispatchHeadlampEvent = useEventCallback();
412412

413+
function prepareExtraInfo(item: Pod | null) {
414+
let extraInfo: {
415+
name: string;
416+
value: React.ReactNode;
417+
hideLabel?: boolean;
418+
}[] = [];
419+
if (item) {
420+
extraInfo = [
421+
{
422+
name: t('State'),
423+
value: makePodStatusLabel(item, false),
424+
},
425+
{
426+
name: t('Node'),
427+
value: item.spec.nodeName ? (
428+
<Link
429+
routeName="node"
430+
params={{ name: item.spec.nodeName }}
431+
activeCluster={item.cluster}
432+
>
433+
{item.spec.nodeName}
434+
</Link>
435+
) : (
436+
''
437+
),
438+
},
439+
{
440+
name: t('Service Account'),
441+
value:
442+
!!item.spec.serviceAccountName || !!item.spec.serviceAccount ? (
443+
<Link
444+
routeName="serviceAccount"
445+
params={{
446+
namespace: item.metadata.namespace,
447+
name: item.spec.serviceAccountName || item.spec.serviceAccount,
448+
}}
449+
activeCluster={item.cluster}
450+
>
451+
{item.spec.serviceAccountName || item.spec.serviceAccount}
452+
</Link>
453+
) : (
454+
''
455+
),
456+
},
457+
// Show Host IP only if Host IPs doesn't exist or is empty
458+
...(item.status.hostIPs && item.status.hostIPs.length > 0
459+
? []
460+
: [
461+
{
462+
name: t('Host IP'),
463+
value: item.status.hostIP ?? '',
464+
},
465+
]),
466+
// Always include Host IPs, but hide if empty
467+
{
468+
name: t('Host IPs'),
469+
value: item.status.hostIPs
470+
? item.status.hostIPs.map((ipObj: { ip: string }) => ipObj.ip).join(', ')
471+
: '',
472+
hideLabel: !item.status.hostIPs || item.status.hostIPs.length === 0,
473+
},
474+
// Show Pod IP only if Pod IPs doesn't exist or is empty
475+
...(item.status.podIPs && item.status.podIPs.length > 0
476+
? []
477+
: [
478+
{
479+
name: t('Pod IP'),
480+
value: item.status.podIP ?? '',
481+
},
482+
]),
483+
// Always include Pod IPs, but hide if empty
484+
{
485+
name: t('Pod IPs'),
486+
value: item.status.podIPs
487+
? item.status.podIPs.map((ipObj: { ip: string }) => ipObj.ip).join(', ')
488+
: '',
489+
hideLabel: !item.status.podIPs || item.status.podIPs.length === 0,
490+
},
491+
{
492+
name: t('QoS Class'),
493+
value: item.status.qosClass,
494+
},
495+
{
496+
name: t('Priority'),
497+
value: item.spec.priority,
498+
},
499+
];
500+
}
501+
return extraInfo;
502+
}
503+
413504
return (
414505
<DetailsGrid
415506
resourceType={Pod}
@@ -486,62 +577,7 @@ export default function PodDetails(props: PodDetailsProps) {
486577
},
487578
]
488579
}
489-
extraInfo={item =>
490-
item && [
491-
{
492-
name: t('State'),
493-
value: makePodStatusLabel(item, false),
494-
},
495-
{
496-
name: t('Node'),
497-
value: item.spec.nodeName ? (
498-
<Link
499-
routeName="node"
500-
params={{ name: item.spec.nodeName }}
501-
activeCluster={item.cluster}
502-
>
503-
{item.spec.nodeName}
504-
</Link>
505-
) : (
506-
''
507-
),
508-
},
509-
{
510-
name: t('Service Account'),
511-
value:
512-
!!item.spec.serviceAccountName || !!item.spec.serviceAccount ? (
513-
<Link
514-
routeName="serviceAccount"
515-
params={{
516-
namespace: item.metadata.namespace,
517-
name: item.spec.serviceAccountName || item.spec.serviceAccount,
518-
}}
519-
activeCluster={item.cluster}
520-
>
521-
{item.spec.serviceAccountName || item.spec.serviceAccount}
522-
</Link>
523-
) : (
524-
''
525-
),
526-
},
527-
{
528-
name: t('Host IP'),
529-
value: item.status.hostIP ?? '',
530-
},
531-
{
532-
name: t('Pod IP'),
533-
value: item.status.podIP ?? '',
534-
},
535-
{
536-
name: t('QoS Class'),
537-
value: item.status.qosClass,
538-
},
539-
{
540-
name: t('Priority'),
541-
value: item.spec.priority,
542-
},
543-
]
544-
}
580+
extraInfo={item => prepareExtraInfo(item)}
545581
extraSections={item =>
546582
item && [
547583
{

frontend/src/components/pod/__snapshots__/PodDetails.Error.stories.storyshot

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,19 @@
281281
<dt
282282
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
283283
>
284-
Pod IP
284+
Host IPs
285+
</dt>
286+
<dd
287+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"
288+
>
289+
<span
290+
class="MuiTypography-root MuiTypography-body1 css-e06lsu-MuiTypography-root"
291+
/>
292+
</dd>
293+
<dt
294+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
295+
>
296+
Pod IPs
285297
</dt>
286298
<dd
287299
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"

frontend/src/components/pod/__snapshots__/PodDetails.Initializing.stories.storyshot

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,19 @@
281281
<dt
282282
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
283283
>
284-
Pod IP
284+
Host IPs
285+
</dt>
286+
<dd
287+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"
288+
>
289+
<span
290+
class="MuiTypography-root MuiTypography-body1 css-e06lsu-MuiTypography-root"
291+
/>
292+
</dd>
293+
<dt
294+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
295+
>
296+
Pod IPs
285297
</dt>
286298
<dd
287299
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"

frontend/src/components/pod/__snapshots__/PodDetails.LivenessFailed.stories.storyshot

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,19 @@
281281
<dt
282282
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
283283
>
284-
Pod IP
284+
Host IPs
285+
</dt>
286+
<dd
287+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"
288+
>
289+
<span
290+
class="MuiTypography-root MuiTypography-body1 css-e06lsu-MuiTypography-root"
291+
/>
292+
</dd>
293+
<dt
294+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
295+
>
296+
Pod IPs
285297
</dt>
286298
<dd
287299
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"

frontend/src/components/pod/__snapshots__/PodDetails.PullBackOff.stories.storyshot

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,19 @@
281281
<dt
282282
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
283283
>
284-
Pod IP
284+
Host IPs
285+
</dt>
286+
<dd
287+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"
288+
>
289+
<span
290+
class="MuiTypography-root MuiTypography-body1 css-e06lsu-MuiTypography-root"
291+
/>
292+
</dd>
293+
<dt
294+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
295+
>
296+
Pod IPs
285297
</dt>
286298
<dd
287299
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"

frontend/src/components/pod/__snapshots__/PodDetails.Running.stories.storyshot

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -281,7 +281,19 @@
281281
<dt
282282
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
283283
>
284-
Pod IP
284+
Host IPs
285+
</dt>
286+
<dd
287+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"
288+
>
289+
<span
290+
class="MuiTypography-root MuiTypography-body1 css-e06lsu-MuiTypography-root"
291+
/>
292+
</dd>
293+
<dt
294+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
295+
>
296+
Pod IPs
285297
</dt>
286298
<dd
287299
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"

frontend/src/components/pod/__snapshots__/PodDetails.Successful.stories.storyshot

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -276,6 +276,18 @@
276276
class="MuiTypography-root MuiTypography-body1 css-e06lsu-MuiTypography-root"
277277
/>
278278
</dd>
279+
<dt
280+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
281+
>
282+
Host IPs
283+
</dt>
284+
<dd
285+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"
286+
>
287+
<span
288+
class="MuiTypography-root MuiTypography-body1 css-e06lsu-MuiTypography-root"
289+
/>
290+
</dd>
279291
<dt
280292
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
281293
>
@@ -288,6 +300,18 @@
288300
class="MuiTypography-root MuiTypography-body1 css-e06lsu-MuiTypography-root"
289301
/>
290302
</dd>
303+
<dt
304+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
305+
>
306+
Pod IPs
307+
</dt>
308+
<dd
309+
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8 css-deb4a-MuiGrid-root"
310+
>
311+
<span
312+
class="MuiTypography-root MuiTypography-body1 css-e06lsu-MuiTypography-root"
313+
/>
314+
</dd>
291315
<dt
292316
class="MuiGrid-root MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4 css-1iczkge-MuiGrid-root"
293317
>

0 commit comments

Comments
 (0)