/**
* PodsPage — lists all Rook-Ceph daemon pods grouped by role.
*/
import {
Loader,
NameValueTable,
SectionBox,
SectionHeader,
SimpleTable,
StatusLabel,
} from '@kinvolk/headlamp-plugin/lib/CommonComponents';
import React from 'react';
import { formatAge, getPodRestarts, isPodReady, RookCephPod } from '../api/k8s';
import { useRookCephContext } from '../api/RookCephDataContext';
function PodTable({ pods, title }: { pods: RookCephPod[]; title: string }) {
if (pods.length === 0) return null;
return (
p.metadata.name },
{
label: 'Status',
getter: p => (
{p.status?.phase ?? 'Unknown'}
),
},
{ label: 'Node', getter: p => p.spec?.nodeName ?? '—' },
{ label: 'Restarts', getter: p => String(getPodRestarts(p)) },
{ label: 'Age', getter: p => formatAge(p.metadata.creationTimestamp) },
]}
data={pods}
/>
);
}
function OsdTable({ pods }: { pods: RookCephPod[] }) {
if (pods.length === 0) return null;
return (
p.metadata.labels?.['osd'] ?? p.metadata.name },
{
label: 'Status',
getter: p => {
const st = isPodReady(p)
? 'success'
: p.status?.phase === 'Pending'
? 'warning'
: 'error';
return {p.status?.phase ?? 'Unknown'};
},
},
{
label: 'Node',
getter: p => p.spec?.nodeName ?? p.metadata.labels?.['topology-location-host'] ?? '—',
},
{ label: 'Device Class', getter: p => p.metadata.labels?.['device-class'] ?? '—' },
{ label: 'Store', getter: p => p.metadata.labels?.['osd-store'] ?? '—' },
{ label: 'Failure Domain', getter: p => p.metadata.labels?.['failure-domain'] ?? '—' },
{ label: 'Restarts', getter: p => String(getPodRestarts(p)) },
{ label: 'Age', getter: p => formatAge(p.metadata.creationTimestamp) },
]}
data={pods}
/>
);
}
export default function PodsPage() {
const { operatorPods, monPods, osdPods, mgrPods, csiRbdPods, csiCephfsPods, loading, error } =
useRookCephContext();
if (loading) return ;
const allPods = [
...operatorPods,
...monPods,
...osdPods,
...mgrPods,
...csiRbdPods,
...csiCephfsPods,
];
const totalReady = allPods.filter(isPodReady).length;
return (
<>
{error && (
{error} }]}
/>
)}
0 ? 'success' : 'warning'
}
>
{totalReady}/{allPods.length} pods ready
),
},
]}
/>
{allPods.length === 0 && (
)}
>
);
}