Skip to content

Commit

Permalink
Merge pull request #1492 from headlamp-k8s/ephemeral-containers-pods
Browse files Browse the repository at this point in the history
frontend: Add ephemeral containers section
  • Loading branch information
joaquimrocha authored Nov 7, 2023
2 parents 22796b0 + 86aadd8 commit dd67bbe
Show file tree
Hide file tree
Showing 8 changed files with 117 additions and 9 deletions.
30 changes: 26 additions & 4 deletions frontend/src/components/common/Resource/Resource.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -850,7 +850,13 @@ export function ContainersSection(props: { resource: KubeObjectInterface | null
return resource?.spec?.initContainers || [];
}

function getStatuses() {
function getEphemeralContainers() {
return resource?.spec?.ephemeralContainers || [];
}

function getStatuses(
statusKind: 'containerStatuses' | 'initContainerStatuses' | 'ephemeralContainerStatuses'
) {
if (!resource || resource.kind !== 'Pod') {
return {};
}
Expand All @@ -859,7 +865,7 @@ export function ContainersSection(props: { resource: KubeObjectInterface | null
[key: string]: ContainerInfoProps['status'];
} = {};

((resource as KubePod).status.containerStatuses || []).forEach(containerStatus => {
((resource as KubePod).status[statusKind] || []).forEach(containerStatus => {
const { name, ...status } = containerStatus;
statuses[name] = { ...status };
});
Expand All @@ -869,7 +875,10 @@ export function ContainersSection(props: { resource: KubeObjectInterface | null

const containers = getContainers();
const initContainers = getInitContainers();
const statuses = getStatuses();
const ephemContainers = getEphemeralContainers();
const statuses = getStatuses('containerStatuses');
const initStatuses = getStatuses('initContainerStatuses');
const ephemStatuses = getStatuses('ephemeralContainerStatuses');
const numContainers = containers.length;

return (
Expand All @@ -889,14 +898,27 @@ export function ContainersSection(props: { resource: KubeObjectInterface | null
)}
</SectionBox>

{ephemContainers.length > 0 && (
<SectionBox title={t('glossary|Ephemeral Containers')}>
{ephemContainers.map((ephemContainer: KubeContainer) => (
<ContainerInfo
key={`ephem_container_${ephemContainer.name}`}
resource={resource}
container={ephemContainer}
status={ephemStatuses[ephemContainer.name]}
/>
))}
</SectionBox>
)}

{initContainers.length > 0 && (
<SectionBox title={t('translation|Init Containers')}>
{initContainers.map((initContainer: KubeContainer, i: number) => (
<ContainerInfo
key={`init_container_${i}`}
resource={resource}
container={initContainer}
status={statuses[initContainer.name]}
status={initStatuses[initContainer.name]}
/>
))}
</SectionBox>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1794,6 +1794,45 @@ exports[`Storyshots Pod/PodDetailsView Initializing 1`] = `
>
init-myservice
</dt>
<dt
class="MuiGrid-root makeStyles-metadataNameCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4"
>
Status
</dt>
<dd
class="MuiGrid-root makeStyles-metadataCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8"
>
<span
class="MuiTypography-root makeStyles-statusLabel MuiTypography-body1"
style="background-color: rgb(248, 255, 240); color: rgb(46, 125, 50);"
>
Running
</span>
</dd>
<dt
class="MuiGrid-root makeStyles-metadataNameCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4"
>
Restart Count
</dt>
<dd
class="MuiGrid-root makeStyles-metadataCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8"
>
0
</dd>
<dt
class="MuiGrid-root makeStyles-metadataNameCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4"
>
Container ID
</dt>
<dd
class="MuiGrid-root makeStyles-metadataCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8"
>
<span
class="MuiTypography-root makeStyles-valueLabel MuiTypography-body1"
>
containerd://5fd564933040cc489ad0774b3f4d99866547cfef02a5277d7459a0fc800c9307
</span>
</dd>
<dt
class="MuiGrid-root makeStyles-metadataNameCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4"
>
Expand Down Expand Up @@ -1821,6 +1860,18 @@ exports[`Storyshots Pod/PodDetailsView Initializing 1`] = `
>
busybox
</p>
<p
class="MuiTypography-root makeStyles-imageID MuiTypography-body1"
>
<span
class="MuiTypography-root MuiTypography-body1"
style="font-weight: bold;"
>
ID:
</span>

docker.io/library/busybox@sha256:125113b35efe765c89a8ed49593e719532318d26828c58e26b26dd7c4c28a673
</p>
</dd>
<dt
class="MuiGrid-root makeStyles-metadataLast makeStyles-metadataNameCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4"
Expand Down Expand Up @@ -1849,6 +1900,39 @@ exports[`Storyshots Pod/PodDetailsView Initializing 1`] = `
>
init-mydb
</dt>
<dt
class="MuiGrid-root makeStyles-metadataNameCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4"
>
Status
</dt>
<dd
class="MuiGrid-root makeStyles-metadataCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8"
>
<span
class="MuiTypography-root makeStyles-statusLabel MuiTypography-body1"
style="background-color: rgb(255, 243, 224); color: rgb(196, 69, 0);"
>
Waiting (PodInitializing)
</span>
</dd>
<dt
class="MuiGrid-root makeStyles-metadataNameCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4"
>
Restart Count
</dt>
<dd
class="MuiGrid-root makeStyles-metadataCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8"
>
0
</dd>
<dt
class="MuiGrid-root makeStyles-metadataNameCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4"
>
Container ID
</dt>
<dd
class="MuiGrid-root makeStyles-metadataCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-8"
/>
<dt
class="MuiGrid-root makeStyles-metadataNameCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4"
>
Expand Down Expand Up @@ -1876,6 +1960,7 @@ exports[`Storyshots Pod/PodDetailsView Initializing 1`] = `
>
busybox
</p>

</dd>
<dt
class="MuiGrid-root makeStyles-metadataLast makeStyles-metadataNameCell MuiGrid-item MuiGrid-grid-xs-12 MuiGrid-grid-sm-4"
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/i18n/locales/de/glossary.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"Volume Mounts": "Speichereinhängpunkte",
"Containers": "Container",
"Container Spec": "Container-Spezifikation",
"Container": "Container",
"Ephemeral Containers": "",
"Container": "Container",
"Config Maps": "Config Maps",
"Definition": "Definition",
"CRD: {{ crdName }}": "CRD: {{ crdName }}",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/i18n/locales/en/glossary.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"Volume Mounts": "Volume Mounts",
"Containers": "Containers",
"Container Spec": "Container Spec",
"Container": "Container",
"Ephemeral Containers": "Ephemeral Containers",
"Container": "Container",
"Config Maps": "Config Maps",
"Definition": "Definition",
"CRD: {{ crdName }}": "CRD: {{ crdName }}",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/i18n/locales/es/glossary.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"Volume Mounts": "Montaje de Volumenes",
"Containers": "Contenedores",
"Container Spec": "Espec. de Contenedor",
"Container": "Contenedor",
"Ephemeral Containers": "",
"Container": "Contenedor",
"Config Maps": "Config Maps",
"Definition": "Definición",
"CRD: {{ crdName }}": "CRD: {{ crdName }}",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/i18n/locales/fr/glossary.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"Volume Mounts": "Supports de volume",
"Containers": "Conteneurs",
"Container Spec": "Spécifications des conteneurs",
"Container": "Conteneur",
"Ephemeral Containers": "",
"Container": "Conteneur",
"Config Maps": "Config Maps",
"Definition": "Définition",
"CRD: {{ crdName }}": "CRD: {{ crdName }}",
Expand Down
2 changes: 1 addition & 1 deletion frontend/src/i18n/locales/pt/glossary.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@
"Volume Mounts": "Montagem de Volumes",
"Containers": "Containers",
"Container Spec": "Espec. de \"Container\"",
"Container": "Container",
"Ephemeral Containers": "",
"Container": "Container",
"Config Maps": "Config Maps",
"Definition": "Definição",
"CRD: {{ crdName }}": "CRD: {{ crdName }}",
Expand Down
1 change: 1 addition & 0 deletions frontend/src/lib/k8s/pod.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ export interface KubePod extends KubeObjectInterface {
conditions: KubeCondition[];
containerStatuses: KubeContainerStatus[];
initContainerStatuses?: KubeContainerStatus[];
ephemeralContainerStatuses?: KubeContainerStatus[];
hostIP: string;
message?: string;
phase: string;
Expand Down

0 comments on commit dd67bbe

Please sign in to comment.