1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-22 23:09:41 +02:00

fix(gke): port metrics to the backend EE-5447 (#9041)

This commit is contained in:
Dakota Walsh 2023-07-24 12:16:29 +12:00 committed by GitHub
parent e996d29d52
commit 704d70c99b
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 441 additions and 247 deletions

View file

@ -3,27 +3,17 @@ import _ from 'lodash-es';
import filesizeParser from 'filesize-parser';
import KubernetesResourceReservationHelper from 'Kubernetes/helpers/resourceReservationHelper';
import { KubernetesResourceReservation } from 'Kubernetes/models/resource-reservation/models';
import { getMetricsForAllNodes } from '@/react/kubernetes/services/service.ts';
class KubernetesClusterController {
/* @ngInject */
constructor(
$async,
$state,
Authentication,
Notifications,
LocalStorage,
KubernetesNodeService,
KubernetesMetricsService,
KubernetesApplicationService,
KubernetesEndpointService
) {
constructor($async, $state, Notifications, LocalStorage, Authentication, KubernetesNodeService, KubernetesApplicationService, KubernetesEndpointService) {
this.$async = $async;
this.$state = $state;
this.Authentication = Authentication;
this.Notifications = Notifications;
this.LocalStorage = LocalStorage;
this.KubernetesNodeService = KubernetesNodeService;
this.KubernetesMetricsService = KubernetesMetricsService;
this.KubernetesApplicationService = KubernetesApplicationService;
this.KubernetesEndpointService = KubernetesEndpointService;
@ -108,7 +98,7 @@ class KubernetesClusterController {
async getResourceUsage(endpointId) {
try {
const nodeMetrics = await this.KubernetesMetricsService.getNodes(endpointId);
const nodeMetrics = await getMetricsForAllNodes(endpointId);
const resourceUsageList = nodeMetrics.items.map((i) => i.usage);
const clusterResourceUsage = resourceUsageList.reduce((total, u) => {
total.CPU += KubernetesResourceReservationHelper.parseCPU(u.cpu);