From 7cf8d105df70c816c90e65d799a430b32a237428 Mon Sep 17 00:00:00 2001 From: atu Date: Mon, 3 Aug 2020 21:48:50 -0700 Subject: [PATCH 1/2] Add support for Horizontal Pod Autoscaling (HPA) --- client/src/components/hpaPanel.js | 31 +++++++++++++++++++++++++++++++ client/src/services/api.js | 2 ++ client/src/views/deployment.js | 5 +++++ client/src/views/replicaSet.js | 6 +++++- 4 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 client/src/components/hpaPanel.js diff --git a/client/src/components/hpaPanel.js b/client/src/components/hpaPanel.js new file mode 100644 index 0000000..e4a8816 --- /dev/null +++ b/client/src/components/hpaPanel.js @@ -0,0 +1,31 @@ +import React from 'react'; +import Field from './field'; + +const HpaPanel = ({spec}) => ( + <> + {spec && +
+
Container
+
+ {spec.minReplicas && ( + <> + {spec.minReplicas} + + )} + {spec.maxReplicas && ( + <> + {spec.maxReplicas} + + )} + {spec.targetCPUUtilizationPercentage && ( + <> + {spec.targetCPUUtilizationPercentage} + + )} +
+
+ } + +); + +export default HpaPanel; diff --git a/client/src/services/api.js b/client/src/services/api.js index b2c0f6e..7c4f47b 100644 --- a/client/src/services/api.js +++ b/client/src/services/api.js @@ -23,6 +23,7 @@ const daemonSet = apiFactoryWithNamespace('apps', 'v1', 'daemonsets'); const deployment = apiFactoryWithNamespace('apps', 'v1', 'deployments', true); const replicaSet = apiFactoryWithNamespace('apps', 'v1', 'replicasets', true); const statefulSet = apiFactoryWithNamespace('apps', 'v1', 'statefulsets', true); +const hpa = apiFactoryWithNamespace('autoscaling', 'v1', 'horizontalpodautoscalers', true); const cronJob = apiFactoryWithNamespace('batch', 'v1beta1', 'cronjobs'); const job = apiFactoryWithNamespace('batch', 'v1', 'jobs'); @@ -63,6 +64,7 @@ const apis = { serviceAccount, statefulSet, roleBinding, + hpa, }; async function testAuth() { diff --git a/client/src/views/deployment.js b/client/src/views/deployment.js index 537a28d..28c1e64 100644 --- a/client/src/views/deployment.js +++ b/client/src/views/deployment.js @@ -18,6 +18,7 @@ import getMetrics from '../utils/metricsHelpers'; import {defaultSortInfo} from '../components/sorter'; import ReplicasChart from '../components/replicasChart'; import ChartsContainer from '../components/chartsContainer'; +import HpaPanel from '../components/hpaPanel'; const service = api.deployment; @@ -37,6 +38,7 @@ export default class Deployment extends Base { events: api.event.list(namespace, x => this.setState({events: x})), pods: api.pod.list(namespace, x => this.setState({pods: x})), metrics: api.metrics.pods(namespace, x => this.setState({metrics: x})), + hpa: api.hpa.get(namespace, name, x => this.setState({hpa: x})) }); } @@ -48,6 +50,7 @@ export default class Deployment extends Base { replicaSets, pods, metrics, + hpa, replicaSetsSort, podsSort, eventsSort, @@ -95,6 +98,8 @@ export default class Deployment extends Base { + +
Replica Sets
this.setState({pods})), events: api.event.list(namespace, events => this.setState({events})), metrics: api.metrics.pods(namespace, metrics => this.setState({metrics})), + hpa: api.hpa.get(namespace, name, x => this.setState({hpa: x})), }); } render() { const {namespace, name} = this.props; - const {item, pods, metrics, events, podsSort, eventsSort} = this.state; + const {item, pods, metrics, events, podsSort, eventsSort, hpa} = this.state; const filteredPods = filterByOwner(pods, item); const filteredEvents = filterByOwner(events, item); @@ -94,6 +96,8 @@ export default class ReplicaSet extends Base { + +
Pods
Date: Wed, 5 Aug 2020 10:17:46 -0700 Subject: [PATCH 2/2] remove empty check and empty tag --- client/src/components/hpaPanel.js | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/client/src/components/hpaPanel.js b/client/src/components/hpaPanel.js index e4a8816..4cdb63f 100644 --- a/client/src/components/hpaPanel.js +++ b/client/src/components/hpaPanel.js @@ -7,21 +7,9 @@ const HpaPanel = ({spec}) => (
Container
- {spec.minReplicas && ( - <> - {spec.minReplicas} - - )} - {spec.maxReplicas && ( - <> - {spec.maxReplicas} - - )} - {spec.targetCPUUtilizationPercentage && ( - <> - {spec.targetCPUUtilizationPercentage} - - )} + {spec.minReplicas} + {spec.maxReplicas} + {spec.targetCPUUtilizationPercentage}
}