import "./pod-details-container.scss" import * as React from "react"; import { t, Trans } from "@lingui/macro"; import { IPodContainer, Pod } from "../../api/endpoints"; import { DrawerItem } from "../drawer"; import { cssNames } from "../../utils"; import { StatusBrick } from "../status-brick"; import { Badge } from "../badge"; import { ContainerEnvironment } from "./pod-container-env"; import { ResourceMetrics } from "../resource-metrics"; import { IMetrics } from "../../api/endpoints/metrics.api"; import { ContainerCharts } from "./container-charts"; import { _i18n } from "../../i18n"; interface Props { pod: Pod; container: IPodContainer; metrics?: { [key: string]: IMetrics }; } export class PodDetailsContainer extends React.Component { render() { const { pod, container, metrics } = this.props if (!pod || !container) return null const { name, image, imagePullPolicy, ports, volumeMounts, command, args } = container const status = pod.getContainerStatuses().find(status => status.name === container.name) const state = status ? Object.keys(status.state)[0] : "" const ready = status ? status.ready : "" const liveness = pod.getLivenessProbe(container) const readiness = pod.getReadinessProbe(container) const isInitContainer = !!pod.getInitContainers().find(c => c.name == name); const metricTabs = [ CPU, Memory, Filesystem, ]; return (
{name}
{!isInitContainer && } {status && Status}> {state}{ready ? `, ${_i18n._(t`ready`)}` : ""} {state === 'terminated' ? ` - ${status.state.terminated.reason} (${_i18n._(t`exit code`)}: ${status.state.terminated.exitCode})` : ''} } Image}> {image} {imagePullPolicy && imagePullPolicy !== "IfNotPresent" && ImagePullPolicy}> {imagePullPolicy} } {ports && ports.length > 0 && Ports}> { ports.map(port => { const { name, containerPort, protocol } = port; const key = `${container.name}-port-${containerPort}-${protocol}` return (
{name ? name + ': ' : ''}{containerPort}/{protocol}
) }) }
} {} {volumeMounts && volumeMounts.length > 0 && Mounts}> { volumeMounts.map(mount => { const { name, mountPath, readOnly } = mount; return ( {mountPath} from {name} ({readOnly ? 'ro' : 'rw'}) ) }) } } {liveness.length > 0 && Liveness} labelsOnly> { liveness.map((value, index) => ( )) } } {readiness.length > 0 && Readiness} labelsOnly> { readiness.map((value, index) => ( )) } } {command && Command}> {command} } {args && Arguments}> {args.join(' ')} }
) } }