1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-24 15:59:41 +02:00

feat(kubernetes/resource-usage): k8s resource usage for cluster, node and namespace EE-3 EE-1112 (#5301)

* backported resource usage functionality from EE

* utilising view bound endpoint object instead of depracated EndpointProvider

* refactor flatmap

* addressed merge conflict issues
This commit is contained in:
zees-dev 2021-07-28 14:26:03 +12:00 committed by GitHub
parent cee7ac26e9
commit ce31de5e9e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
13 changed files with 188 additions and 30 deletions

View file

@ -10,22 +10,42 @@
</span>
</div>
<div class="form-group" ng-if="$ctrl.memoryLimit !== 0">
<label for="memory-usage" class="col-sm-3 col-lg-2 control-label text-left">
<label for="memory-reservation" class="col-sm-3 col-lg-2 control-label text-left">
Memory reservation
</label>
<div class="col-sm-9" style="margin-top: 4px;">
<uib-progressbar animate="false" value="$ctrl.memoryUsage" type="{{ $ctrl.memoryUsage | kubernetesUsageLevelInfo }}">
<b style="white-space: nowrap;"> {{ $ctrl.memory }} / {{ $ctrl.memoryLimit }} MB - {{ $ctrl.memoryUsage }}% </b>
<uib-progressbar animate="false" value="$ctrl.memoryReservationPercent" type="{{ $ctrl.memoryReservationPercent | kubernetesUsageLevelInfo }}">
<b style="white-space: nowrap;"> {{ $ctrl.memoryReservation }} / {{ $ctrl.memoryLimit }} MB - {{ $ctrl.memoryReservationPercent }}% </b>
</uib-progressbar>
</div>
</div>
<div class="form-group" ng-if="$ctrl.displayUsage && $ctrl.memoryLimit !== 0">
<label for="memory-usage" class="col-sm-3 col-lg-2 control-label text-left">
Memory used
</label>
<div class="col-sm-9" style="margin-top: 4px;">
<uib-progressbar animate="false" value="$ctrl.memoryUsagePercent" type="{{ $ctrl.memoryUsagePercent | kubernetesUsageLevelInfo }}">
<b style="white-space: nowrap;"> {{ $ctrl.memoryUsage }} / {{ $ctrl.memoryLimit }} MB - {{ $ctrl.memoryUsagePercent }}% </b>
</uib-progressbar>
</div>
</div>
<div class="form-group" ng-if="$ctrl.cpuLimit !== 0">
<label for="cpu-usage" class="col-sm-3 col-lg-2 control-label text-left">
<label for="cpu-reservation" class="col-sm-3 col-lg-2 control-label text-left">
CPU reservation
</label>
<div class="col-sm-9" style="margin-top: 4px;">
<uib-progressbar animate="false" value="$ctrl.cpuUsage" type="{{ $ctrl.cpuUsage | kubernetesUsageLevelInfo }}">
<b style="white-space: nowrap;"> {{ $ctrl.cpu | kubernetesApplicationCPUValue }} / {{ $ctrl.cpuLimit }} - {{ $ctrl.cpuUsage }}% </b>
<uib-progressbar animate="false" value="$ctrl.cpuReservationPercent" type="{{ $ctrl.cpuReservationPercent | kubernetesUsageLevelInfo }}">
<b style="white-space: nowrap;"> {{ $ctrl.cpuReservation | kubernetesApplicationCPUValue }} / {{ $ctrl.cpuLimit }} - {{ $ctrl.cpuReservationPercent }}% </b>
</uib-progressbar>
</div>
</div>
<div class="form-group" ng-if="$ctrl.displayUsage && $ctrl.cpuLimit !== 0">
<label for="cpu-usage" class="col-sm-3 col-lg-2 control-label text-left">
CPU used
</label>
<div class="col-sm-9" style="margin-top: 4px;">
<uib-progressbar animate="false" value="$ctrl.cpuUsagePercent" type="{{ $ctrl.cpuUsagePercent | kubernetesUsageLevelInfo }}">
<b style="white-space: nowrap;"> {{ $ctrl.cpuUsage | kubernetesApplicationCPUValue }} / {{ $ctrl.cpuLimit }} - {{ $ctrl.cpuUsagePercent }}% </b>
</uib-progressbar>
</div>
</div>

View file

@ -3,9 +3,12 @@ angular.module('portainer.kubernetes').component('kubernetesResourceReservation'
controller: 'KubernetesResourceReservationController',
bindings: {
description: '@',
cpu: '<',
cpuReservation: '<',
cpuUsage: '<',
cpuLimit: '<',
memory: '<',
memoryReservation: '<',
memoryUsage: '<',
memoryLimit: '<',
displayUsage: '<',
},
});

View file

@ -3,10 +3,15 @@ import angular from 'angular';
class KubernetesResourceReservationController {
usageValues() {
if (this.cpuLimit) {
this.cpuUsage = Math.round((this.cpu / this.cpuLimit) * 100);
this.cpuReservationPercent = Math.round((this.cpuReservation / this.cpuLimit) * 100);
}
if (this.memoryLimit) {
this.memoryUsage = Math.round((this.memory / this.memoryLimit) * 100);
this.memoryReservationPercent = Math.round((this.memoryReservation / this.memoryLimit) * 100);
}
if (this.displayUsage && this.cpuLimit && this.memoryLimit) {
this.cpuUsagePercent = Math.round((this.cpuUsage / this.cpuLimit) * 100);
this.memoryUsagePercent = Math.round((this.memoryUsage / this.memoryLimit) * 100);
}
}