Skip to content

Commit 635d8fa

Browse files
authored
Merge pull request #3241 from ashu8912/add-host-and-pod-ips
frontend: Add hostIPs and podIPs to pod
2 parents d015289 + 5aa3626 commit 635d8fa

20 files changed

+271
-6631
lines changed

frontend/src/components/pod/Details.tsx

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

489+
function prepareExtraInfo(item: Pod | null) {
490+
let extraInfo: {
491+
name: string;
492+
value: React.ReactNode;
493+
hideLabel?: boolean;
494+
}[] = [];
495+
if (item) {
496+
extraInfo = [
497+
{
498+
name: t('State'),
499+
value: makePodStatusLabel(item, false),
500+
},
501+
{
502+
name: t('Node'),
503+
value: item.spec.nodeName ? (
504+
<Link
505+
routeName="node"
506+
params={{ name: item.spec.nodeName }}
507+
activeCluster={item.cluster}
508+
>
509+
{item.spec.nodeName}
510+
</Link>
511+
) : (
512+
''
513+
),
514+
},
515+
{
516+
name: t('Service Account'),
517+
value:
518+
!!item.spec.serviceAccountName || !!item.spec.serviceAccount ? (
519+
<Link
520+
routeName="serviceAccount"
521+
params={{
522+
namespace: item.metadata.namespace,
523+
name: item.spec.serviceAccountName || item.spec.serviceAccount,
524+
}}
525+
activeCluster={item.cluster}
526+
>
527+
{item.spec.serviceAccountName || item.spec.serviceAccount}
528+
</Link>
529+
) : (
530+
''
531+
),
532+
},
533+
// Show Host IP only if Host IPs doesn't exist or is empty
534+
...(item.status.hostIPs && item.status.hostIPs.length > 0
535+
? []
536+
: [
537+
{
538+
name: t('Host IP'),
539+
value: item.status.hostIP ?? '',
540+
},
541+
]),
542+
// Always include Host IPs, but hide if empty
543+
{
544+
name: t('Host IPs'),
545+
value: item.status.hostIPs
546+
? item.status.hostIPs.map((ipObj: { ip: string }) => ipObj.ip).join(', ')
547+
: '',
548+
hideLabel: !item.status.hostIPs || item.status.hostIPs.length === 0,
549+
},
550+
// Show Pod IP only if Pod IPs doesn't exist or is empty
551+
...(item.status.podIPs && item.status.podIPs.length > 0
552+
? []
553+
: [
554+
{
555+
name: t('Pod IP'),
556+
value: item.status.podIP ?? '',
557+
},
558+
]),
559+
// Always include Pod IPs, but hide if empty
560+
{
561+
name: t('Pod IPs'),
562+
value: item.status.podIPs
563+
? item.status.podIPs.map((ipObj: { ip: string }) => ipObj.ip).join(', ')
564+
: '',
565+
hideLabel: !item.status.podIPs || item.status.podIPs.length === 0,
566+
},
567+
{
568+
name: t('QoS Class'),
569+
value: item.status.qosClass,
570+
},
571+
{
572+
name: t('Priority'),
573+
value: item.spec.priority,
574+
},
575+
];
576+
}
577+
return extraInfo;
578+
}
579+
489580
return (
490581
<DetailsGrid
491582
resourceType={Pod}
@@ -566,62 +657,7 @@ export default function PodDetails(props: PodDetailsProps) {
566657
},
567658
]
568659
}
569-
extraInfo={item =>
570-
item && [
571-
{
572-
name: t('State'),
573-
value: makePodStatusLabel(item, false),
574-
},
575-
{
576-
name: t('Node'),
577-
value: item.spec.nodeName ? (
578-
<Link
579-
routeName="node"
580-
params={{ name: item.spec.nodeName }}
581-
activeCluster={item.cluster}
582-
>
583-
{item.spec.nodeName}
584-
</Link>
585-
) : (
586-
''
587-
),
588-
},
589-
{
590-
name: t('Service Account'),
591-
value:
592-
!!item.spec.serviceAccountName || !!item.spec.serviceAccount ? (
593-
<Link
594-
routeName="serviceAccount"
595-
params={{
596-
namespace: item.metadata.namespace,
597-
name: item.spec.serviceAccountName || item.spec.serviceAccount,
598-
}}
599-
activeCluster={item.cluster}
600-
>
601-
{item.spec.serviceAccountName || item.spec.serviceAccount}
602-
</Link>
603-
) : (
604-
''
605-
),
606-
},
607-
{
608-
name: t('Host IP'),
609-
value: item.status.hostIP ?? '',
610-
},
611-
{
612-
name: t('Pod IP'),
613-
value: item.status.podIP ?? '',
614-
},
615-
{
616-
name: t('QoS Class'),
617-
value: item.status.qosClass,
618-
},
619-
{
620-
name: t('Priority'),
621-
value: item.spec.priority,
622-
},
623-
]
624-
}
660+
extraInfo={item => prepareExtraInfo(item)}
625661
extraSections={item =>
626662
item && [
627663
{

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)