diff --git a/client/src/components/podCpuChart.tsx b/client/src/components/podCpuChart.tsx index af67ea1..25ae1aa 100644 --- a/client/src/components/podCpuChart.tsx +++ b/client/src/components/podCpuChart.tsx @@ -3,15 +3,15 @@ import React, {useEffect, useState} from 'react'; import Chart from './chart'; import LoadingChart from './loadingChart'; import {parseCpu, TO_ONE_CPU} from '../utils/unitHelpers'; -import {Pod, Metrics} from '../utils/types'; +import {Pod, Metrics, ReplicaSet} from '../utils/types'; import PrometheusGraph, {BASE_HTTP_URL} from '../views/prometheusgraph'; import api from '../services/api'; -export default function PodCpuChart({items, metrics, pod}: {items?: Pod[], metrics?: _.Dictionary, pod?: Pod}) { +export default function PodCpuChart({items, metrics, item}: {items?: Pod[], metrics?: _.Dictionary, item?: Pod | ReplicaSet}) { const totals = getPodCpuTotals(items, metrics); const decimals = totals && totals.used > 10 ? 1 : 2; const defaultLabels = "unit='core', resource='cpu'"; - const labelMatchers = pod ? `${defaultLabels}, pod="${pod.metadata.name}"` : defaultLabels; + const labelMatchers = item ? `${defaultLabels}, pod="${item.metadata.name}"` : defaultLabels; const query = { queryString: `sum(kube_pod_container_resource_requests{${labelMatchers}})`, @@ -57,7 +57,6 @@ export default function PodCpuChart({items, metrics, pod}: {items?: Pod[], metri function getPodCpuTotals(pods?: Pod[], metrics?: _.Dictionary) { if (!pods || !metrics) return null; - const used = _(metrics) .flatMap(x => x.containers) .sumBy(x => parseCpu(x.usage.cpu)); diff --git a/client/src/components/podRamChart.tsx b/client/src/components/podRamChart.tsx index 29d1289..be0dbef 100644 --- a/client/src/components/podRamChart.tsx +++ b/client/src/components/podRamChart.tsx @@ -3,16 +3,17 @@ import React, {useEffect, useState} from 'react'; import Chart from './chart'; import LoadingChart from './loadingChart'; import {parseRam, TO_GB} from '../utils/unitHelpers'; -import {Pod, Metrics} from '../utils/types'; +import {Pod, Metrics, ReplicaSet} from '../utils/types'; import PrometheusGraph, {BASE_HTTP_URL} from '../views/prometheusgraph'; import api from '../services/api'; -export default function RamChart({items, metrics, pod}: {items?: Pod[], metrics?: _.Dictionary, pod?: Pod}) { +export default function RamChart({items, metrics, item}: {items?: Pod[], metrics?: _.Dictionary, item?: Pod | ReplicaSet}) { + const totals = getPodRamTotals(items, metrics); const decimals = totals && totals.used > 10 ? 1 : 2; const defaultLabels = "unit='byte'"; - const labelMatchers = pod ? `${defaultLabels}, pod="${pod.metadata.name}"` : defaultLabels; + const labelMatchers = item ? `${defaultLabels}, pod="${item.metadata.name}"` : defaultLabels; const query = { queryString: `sum(kube_pod_container_resource_requests{${labelMatchers}}/${TO_GB})`, diff --git a/client/src/views/pod.tsx b/client/src/views/pod.tsx index 595a2fc..230d7ba 100644 --- a/client/src/views/pod.tsx +++ b/client/src/views/pod.tsx @@ -82,8 +82,8 @@ export default class PodView extends Base { {errors && !!errors.length && } - - + +
diff --git a/client/src/views/replicaSet.tsx b/client/src/views/replicaSet.tsx index 35e93b4..bd31289 100644 --- a/client/src/views/replicaSet.tsx +++ b/client/src/views/replicaSet.tsx @@ -87,8 +87,8 @@ export default class ReplicaSetView extends Base { - - + +