diff --git a/.changeset/stupid-tigers-bake.md b/.changeset/stupid-tigers-bake.md new file mode 100644 index 0000000000..8572caa675 --- /dev/null +++ b/.changeset/stupid-tigers-bake.md @@ -0,0 +1,8 @@ +--- +'@backstage/plugin-kubernetes-backend': minor +'@backstage/plugin-kubernetes-common': minor +'@backstage/plugin-kubernetes-react': minor +'@backstage/plugin-kubernetes': minor +--- + +Update kubernetes plugins to use autoscaling/v2 diff --git a/plugins/kubernetes-backend/examples/dice-roller/dice-roller-manifests.yaml b/plugins/kubernetes-backend/examples/dice-roller/dice-roller-manifests.yaml index 8f225e666a..4d564b7552 100644 --- a/plugins/kubernetes-backend/examples/dice-roller/dice-roller-manifests.yaml +++ b/plugins/kubernetes-backend/examples/dice-roller/dice-roller-manifests.yaml @@ -221,7 +221,7 @@ spec: - containerPort: 80 --- -apiVersion: autoscaling/v1 +apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: dice-roller diff --git a/plugins/kubernetes-backend/src/service/KubernetesFanOutHandler.ts b/plugins/kubernetes-backend/src/service/KubernetesFanOutHandler.ts index 53b5070e61..54a038fffd 100644 --- a/plugins/kubernetes-backend/src/service/KubernetesFanOutHandler.ts +++ b/plugins/kubernetes-backend/src/service/KubernetesFanOutHandler.ts @@ -103,7 +103,7 @@ export const DEFAULT_OBJECTS: ObjectToFetch[] = [ }, { group: 'autoscaling', - apiVersion: 'v1', + apiVersion: 'v2', plural: 'horizontalpodautoscalers', objectType: 'horizontalpodautoscalers', }, diff --git a/plugins/kubernetes-common/api-report.md b/plugins/kubernetes-common/api-report.md index 2f46ef90e5..81e9ca28e7 100644 --- a/plugins/kubernetes-common/api-report.md +++ b/plugins/kubernetes-common/api-report.md @@ -14,7 +14,6 @@ import { V1ConfigMap } from '@kubernetes/client-node'; import { V1CronJob } from '@kubernetes/client-node'; import { V1DaemonSet } from '@kubernetes/client-node'; import { V1Deployment } from '@kubernetes/client-node'; -import { V1HorizontalPodAutoscaler } from '@kubernetes/client-node'; import { V1Ingress } from '@kubernetes/client-node'; import { V1Job } from '@kubernetes/client-node'; import { V1LimitRange } from '@kubernetes/client-node'; @@ -23,6 +22,7 @@ import { V1ReplicaSet } from '@kubernetes/client-node'; import { V1ResourceQuota } from '@kubernetes/client-node'; import { V1Service } from '@kubernetes/client-node'; import { V1StatefulSet } from '@kubernetes/client-node'; +import { V2HorizontalPodAutoscaler } from '@kubernetes/client-node'; // @public export const ANNOTATION_KUBERNETES_API_SERVER = 'kubernetes.io/api-server'; @@ -192,7 +192,7 @@ export interface DeploymentResources { // (undocumented) deployments: V1Deployment[]; // (undocumented) - horizontalPodAutoscalers: V1HorizontalPodAutoscaler[]; + horizontalPodAutoscalers: V2HorizontalPodAutoscaler[]; // (undocumented) pods: V1Pod[]; // (undocumented) @@ -294,7 +294,7 @@ export const groupResponses: ( // @public (undocumented) export interface HorizontalPodAutoscalersFetchResponse { // (undocumented) - resources: Array; + resources: Array; // (undocumented) type: 'horizontalpodautoscalers'; } diff --git a/plugins/kubernetes-common/src/error-detection/__fixtures__/hpa-healthy.json b/plugins/kubernetes-common/src/error-detection/__fixtures__/hpa-healthy.json index 23edee5a07..29c74b4839 100644 --- a/plugins/kubernetes-common/src/error-detection/__fixtures__/hpa-healthy.json +++ b/plugins/kubernetes-common/src/error-detection/__fixtures__/hpa-healthy.json @@ -1,32 +1,77 @@ { + "apiVersion": "autoscaling/v2", + "kind": "HorizontalPodAutoscaler", "metadata": { - "annotations": { - "autoscaling.alpha.kubernetes.io/conditions": "[{\"type\":\"AbleToScale\",\"status\":\"True\",\"lastTransitionTime\":\"2020-09-28T13:28:15Z\",\"reason\":\"SucceededGetScale\",\"message\":\"the HPA controller was able to get the target's current scale\"},{\"type\":\"ScalingActive\",\"status\":\"False\",\"lastTransitionTime\":\"2020-09-28T13:28:15Z\",\"reason\":\"FailedGetResourceMetric\",\"message\":\"the HPA was unable to compute the replica count: unable to get metrics for resource cpu: unable to fetch metrics from resource metrics API: the server could not find the requested resource (get pods.metrics.k8s.io)\"}]", - "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"autoscaling/v1\",\"kind\":\"HorizontalPodAutoscaler\",\"metadata\":{\"annotations\":{},\"labels\":{\"backstage.io/kubernetes-id\":\"dice-roller\"},\"name\":\"dice-roller\",\"namespace\":\"default\"},\"spec\":{\"maxReplicas\":15,\"minReplicas\":10,\"scaleTargetRef\":{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"name\":\"dice-roller\"},\"targetCPUUtilizationPercentage\":50}}\n" - }, - "creationTimestamp": "2020-09-28T13:28:00.000Z", + "annotations": {}, + "creationTimestamp": "2024-02-13T20:13:52Z", "labels": { "backstage.io/kubernetes-id": "dice-roller" }, "name": "dice-roller", "namespace": "default", - "resourceVersion": "698957", - "selfLink": "/apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers/dice-roller", - "uid": "a70c8a90-5605-4d7d-adea-05cfb8d9d446" + "resourceVersion": "6717s736", + "uid": "a34c90e1-8e8f-407f-b4c5-b4543bd56c1b" }, "spec": { - "maxReplicas": 15, - "minReplicas": 10, + "maxReplicas": 2, + "metrics": [ + { + "resource": { + "name": "cpu", + "target": { + "averageUtilization": 50, + "type": "Utilization" + } + }, + "type": "Resource" + } + ], + "minReplicas": 1, "scaleTargetRef": { "apiVersion": "apps/v1", "kind": "Deployment", "name": "dice-roller" - }, - "targetCPUUtilizationPercentage": 50 + } }, "status": { - "currentReplicas": 13, - "desiredReplicas": 14, - "currentCPUUtilizationPercentage": 30 + "conditions": [ + { + "lastTransitionTime": "2024-05-17T19:50:35Z", + "message": "recent recommendations were higher than current one, applying the highest recent recommendation", + "reason": "ScaleDownStabilized", + "status": "True", + "type": "AbleToScale" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the HPA was able to successfully calculate a replica count from cpu resource utilization (percentage of request)", + "reason": "ValidMetricFound", + "status": "True", + "type": "ScalingActive" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the desired replica count is more than the maximum replica count", + "reason": "TooManyReplicas", + "status": "True", + "type": "ScalingLimited" + } + ], + "currentMetrics": [ + { + "resource": { + "current": { + "averageUtilization": 100, + "averageValue": "50m", + "value": "100m" + }, + "name": "cpu" + }, + "type": "Resource" + } + ], + "currentReplicas": 2, + "desiredReplicas": 2, + "lastScaleTime": "2024-02-13T20:14:23Z" } } diff --git a/plugins/kubernetes-common/src/error-detection/__fixtures__/hpa-maxed-out.json b/plugins/kubernetes-common/src/error-detection/__fixtures__/hpa-maxed-out.json index 4466e7b4b1..29c74b4839 100644 --- a/plugins/kubernetes-common/src/error-detection/__fixtures__/hpa-maxed-out.json +++ b/plugins/kubernetes-common/src/error-detection/__fixtures__/hpa-maxed-out.json @@ -1,32 +1,77 @@ { + "apiVersion": "autoscaling/v2", + "kind": "HorizontalPodAutoscaler", "metadata": { - "annotations": { - "autoscaling.alpha.kubernetes.io/conditions": "[{\"type\":\"AbleToScale\",\"status\":\"True\",\"lastTransitionTime\":\"2020-09-28T13:28:15Z\",\"reason\":\"SucceededGetScale\",\"message\":\"the HPA controller was able to get the target's current scale\"},{\"type\":\"ScalingActive\",\"status\":\"False\",\"lastTransitionTime\":\"2020-09-28T13:28:15Z\",\"reason\":\"FailedGetResourceMetric\",\"message\":\"the HPA was unable to compute the replica count: unable to get metrics for resource cpu: unable to fetch metrics from resource metrics API: the server could not find the requested resource (get pods.metrics.k8s.io)\"}]", - "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"autoscaling/v1\",\"kind\":\"HorizontalPodAutoscaler\",\"metadata\":{\"annotations\":{},\"labels\":{\"backstage.io/kubernetes-id\":\"dice-roller\"},\"name\":\"dice-roller\",\"namespace\":\"default\"},\"spec\":{\"maxReplicas\":15,\"minReplicas\":10,\"scaleTargetRef\":{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"name\":\"dice-roller\"},\"targetCPUUtilizationPercentage\":50}}\n" - }, - "creationTimestamp": "2020-09-28T13:28:00.000Z", + "annotations": {}, + "creationTimestamp": "2024-02-13T20:13:52Z", "labels": { "backstage.io/kubernetes-id": "dice-roller" }, "name": "dice-roller", "namespace": "default", - "resourceVersion": "698957", - "selfLink": "/apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers/dice-roller", - "uid": "a70c8a90-5605-4d7d-adea-05cfb8d9d446" + "resourceVersion": "6717s736", + "uid": "a34c90e1-8e8f-407f-b4c5-b4543bd56c1b" }, "spec": { - "maxReplicas": 10, - "minReplicas": 5, + "maxReplicas": 2, + "metrics": [ + { + "resource": { + "name": "cpu", + "target": { + "averageUtilization": 50, + "type": "Utilization" + } + }, + "type": "Resource" + } + ], + "minReplicas": 1, "scaleTargetRef": { "apiVersion": "apps/v1", "kind": "Deployment", "name": "dice-roller" - }, - "targetCPUUtilizationPercentage": 70 + } }, "status": { - "currentReplicas": 10, - "desiredReplicas": 10, - "currentCPUUtilizationPercentage": 100 + "conditions": [ + { + "lastTransitionTime": "2024-05-17T19:50:35Z", + "message": "recent recommendations were higher than current one, applying the highest recent recommendation", + "reason": "ScaleDownStabilized", + "status": "True", + "type": "AbleToScale" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the HPA was able to successfully calculate a replica count from cpu resource utilization (percentage of request)", + "reason": "ValidMetricFound", + "status": "True", + "type": "ScalingActive" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the desired replica count is more than the maximum replica count", + "reason": "TooManyReplicas", + "status": "True", + "type": "ScalingLimited" + } + ], + "currentMetrics": [ + { + "resource": { + "current": { + "averageUtilization": 100, + "averageValue": "50m", + "value": "100m" + }, + "name": "cpu" + }, + "type": "Resource" + } + ], + "currentReplicas": 2, + "desiredReplicas": 2, + "lastScaleTime": "2024-02-13T20:14:23Z" } } diff --git a/plugins/kubernetes-common/src/error-detection/error-detection.test.ts b/plugins/kubernetes-common/src/error-detection/error-detection.test.ts index ae4605c3c5..f57226a01c 100644 --- a/plugins/kubernetes-common/src/error-detection/error-detection.test.ts +++ b/plugins/kubernetes-common/src/error-detection/error-detection.test.ts @@ -17,7 +17,7 @@ import { V1Pod, V1Deployment, - V1HorizontalPodAutoscaler, + V2HorizontalPodAutoscaler, } from '@kubernetes/client-node'; import { detectErrors } from './error-detection'; import * as healthyPod from './__fixtures__/pod.json'; @@ -61,7 +61,7 @@ const oneDeployment = (deployment: V1Deployment): ObjectsByEntityResponse => { }); }; -const oneHpa = (hpa: V1HorizontalPodAutoscaler): ObjectsByEntityResponse => { +const oneHpa = (hpa: V2HorizontalPodAutoscaler): ObjectsByEntityResponse => { return oneItem({ type: 'horizontalpodautoscalers', resources: [hpa], @@ -328,7 +328,7 @@ describe('detectErrors', () => { expect(err1).toStrictEqual({ sourceRef: { - apiGroup: 'autoscaling/v1', + apiGroup: 'autoscaling/v2', kind: 'HorizontalPodAutoscaler', name: 'dice-roller', namespace: 'default', diff --git a/plugins/kubernetes-common/src/error-detection/error-detection.ts b/plugins/kubernetes-common/src/error-detection/error-detection.ts index a3a4d58d9e..6fa9211db4 100644 --- a/plugins/kubernetes-common/src/error-detection/error-detection.ts +++ b/plugins/kubernetes-common/src/error-detection/error-detection.ts @@ -21,7 +21,7 @@ import { detectErrorsInPods } from './pods'; import { detectErrorsInDeployments } from './deployments'; import { detectErrorsInHpa } from './hpas'; import { Deployment } from 'kubernetes-models/apps/v1'; -import { HorizontalPodAutoscaler } from 'kubernetes-models/autoscaling/v1'; +import { HorizontalPodAutoscaler } from 'kubernetes-models/autoscaling/v2'; import { Pod } from 'kubernetes-models/v1'; /** diff --git a/plugins/kubernetes-common/src/error-detection/hpas.ts b/plugins/kubernetes-common/src/error-detection/hpas.ts index 6f15c119b6..785e6b0e9b 100644 --- a/plugins/kubernetes-common/src/error-detection/hpas.ts +++ b/plugins/kubernetes-common/src/error-detection/hpas.ts @@ -14,7 +14,7 @@ * limitations under the License. */ -import { HorizontalPodAutoscaler } from 'kubernetes-models/autoscaling/v1'; +import { HorizontalPodAutoscaler } from 'kubernetes-models/autoscaling/v2'; import { DetectedError, ErrorMapper } from './types'; import { detectErrorsInObjects } from './common'; @@ -35,7 +35,7 @@ const hpaErrorMappers: ErrorMapper[] = [ name: hpa.metadata?.name ?? 'unknown hpa', namespace: hpa.metadata?.namespace ?? 'unknown namespace', kind: 'HorizontalPodAutoscaler', - apiGroup: 'autoscaling/v1', + apiGroup: 'autoscaling/v2', }, occurrenceCount: 1, }, diff --git a/plugins/kubernetes-common/src/types.ts b/plugins/kubernetes-common/src/types.ts index c4bb5fd32f..a63c157948 100644 --- a/plugins/kubernetes-common/src/types.ts +++ b/plugins/kubernetes-common/src/types.ts @@ -21,7 +21,7 @@ import { V1CronJob, V1DaemonSet, V1Deployment, - V1HorizontalPodAutoscaler, + V2HorizontalPodAutoscaler, V1Ingress, V1Job, V1LimitRange, @@ -186,7 +186,7 @@ export interface ResourceQuotaFetchResponse { /** @public */ export interface HorizontalPodAutoscalersFetchResponse { type: 'horizontalpodautoscalers'; - resources: Array; + resources: Array; } /** @public */ @@ -282,7 +282,7 @@ export interface DeploymentResources { pods: V1Pod[]; replicaSets: V1ReplicaSet[]; deployments: V1Deployment[]; - horizontalPodAutoscalers: V1HorizontalPodAutoscaler[]; + horizontalPodAutoscalers: V2HorizontalPodAutoscaler[]; } /** @public */ diff --git a/plugins/kubernetes-react/api-report.md b/plugins/kubernetes-react/api-report.md index ccc2e1643d..2d080d110d 100644 --- a/plugins/kubernetes-react/api-report.md +++ b/plugins/kubernetes-react/api-report.md @@ -33,10 +33,10 @@ import { ProfileInfoApi } from '@backstage/core-plugin-api'; import { default as React_2 } from 'react'; import * as React_3 from 'react'; import { TypeMeta } from '@kubernetes-models/base'; -import { V1HorizontalPodAutoscaler } from '@kubernetes/client-node'; import { V1Job } from '@kubernetes/client-node'; import { V1ObjectMeta } from '@kubernetes/client-node'; import { V1Pod } from '@kubernetes/client-node'; +import { V2HorizontalPodAutoscaler } from '@kubernetes/client-node'; import { WorkloadsByEntityRequest } from '@backstage/plugin-kubernetes-common'; // @public (undocumented) @@ -285,7 +285,7 @@ export const GroupedResponsesContext: React_2.Context; // @public (undocumented) export const HorizontalPodAutoscalerDrawer: (props: { - hpa: V1HorizontalPodAutoscaler; + hpa: V2HorizontalPodAutoscaler; expanded?: boolean; children?: React_2.ReactNode; }) => React_2.JSX.Element; diff --git a/plugins/kubernetes-react/src/__fixtures__/1-deployments.json b/plugins/kubernetes-react/src/__fixtures__/1-deployments.json index 5ad847dc49..3a9da2a33a 100644 --- a/plugins/kubernetes-react/src/__fixtures__/1-deployments.json +++ b/plugins/kubernetes-react/src/__fixtures__/1-deployments.json @@ -2826,85 +2826,80 @@ ], "horizontalPodAutoscalers": [ { - "apiVersion": "autoscaling/v1", + "apiVersion": "autoscaling/v2", "kind": "HorizontalPodAutoscaler", "metadata": { - "annotations": { - "autoscaling.alpha.kubernetes.io/conditions": "[{\"type\":\"AbleToScale\",\"status\":\"True\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"SucceededGetScale\",\"message\":\"the HPA controller was able to get the target's current scale\"},{\"type\":\"ScalingActive\",\"status\":\"False\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"FailedGetResourceMetric\",\"message\":\"the HPA was unable to compute the replica count: unable to get metrics for resource cpu: no metrics returned from resource metrics API\"}]", - "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"autoscaling/v1\",\"kind\":\"HorizontalPodAutoscaler\",\"metadata\":{\"annotations\":{},\"labels\":{\"backstage.io/kubernetes-id\":\"dice-roller\"},\"name\":\"dice-roller\",\"namespace\":\"default\"},\"spec\":{\"maxReplicas\":15,\"minReplicas\":10,\"scaleTargetRef\":{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"name\":\"dice-roller\"},\"targetCPUUtilizationPercentage\":50}}\n" - }, - "creationTimestamp": "2021-01-05T10:25:48Z", + "annotations": {}, + "creationTimestamp": "2024-02-13T20:13:52Z", "labels": { "backstage.io/kubernetes-id": "dice-roller" }, - "managedFields": [ - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - ".": {}, - "f:kubectl.kubernetes.io/last-applied-configuration": {} - }, - "f:labels": { - ".": {}, - "f:backstage.io/kubernetes-id": {} - } - }, - "f:spec": { - "f:maxReplicas": {}, - "f:minReplicas": {}, - "f:scaleTargetRef": { - "f:apiVersion": {}, - "f:kind": {}, - "f:name": {} - }, - "f:targetCPUUtilizationPercentage": {} - } - }, - "manager": "kubectl-client-side-apply", - "operation": "Update", - "time": "2021-01-05T10:25:48Z" - }, - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - "f:autoscaling.alpha.kubernetes.io/conditions": {} - } - }, - "f:status": { - "f:currentReplicas": {} - } - }, - "manager": "kube-controller-manager", - "operation": "Update", - "time": "2021-01-05T10:26:04Z" - } - ], "name": "dice-roller", "namespace": "default", - "resourceVersion": "598", - "selfLink": "/apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers/dice-roller", - "uid": "dd7c5329-567c-43c2-b159-756808d90a8e" + "resourceVersion": "6717s736", + "uid": "a34c90e1-8e8f-407f-b4c5-b4543bd56c1b" }, "spec": { - "maxReplicas": 15, - "minReplicas": 10, + "maxReplicas": 2, + "metrics": [ + { + "resource": { + "name": "cpu", + "target": { + "averageUtilization": 50, + "type": "Utilization" + } + }, + "type": "Resource" + } + ], + "minReplicas": 1, "scaleTargetRef": { "apiVersion": "apps/v1", "kind": "Deployment", "name": "dice-roller" - }, - "targetCPUUtilizationPercentage": 50 + } }, "status": { - "currentReplicas": 10, - "desiredReplicas": 0, - "currentCPUUtilizationPercentage": 30 + "conditions": [ + { + "lastTransitionTime": "2024-05-17T19:50:35Z", + "message": "recent recommendations were higher than current one, applying the highest recent recommendation", + "reason": "ScaleDownStabilized", + "status": "True", + "type": "AbleToScale" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the HPA was able to successfully calculate a replica count from cpu resource utilization (percentage of request)", + "reason": "ValidMetricFound", + "status": "True", + "type": "ScalingActive" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the desired replica count is more than the maximum replica count", + "reason": "TooManyReplicas", + "status": "True", + "type": "ScalingLimited" + } + ], + "currentMetrics": [ + { + "resource": { + "current": { + "averageUtilization": 100, + "averageValue": "50m", + "value": "100m" + }, + "name": "cpu" + }, + "type": "Resource" + } + ], + "currentReplicas": 2, + "desiredReplicas": 2, + "lastScaleTime": "2024-02-13T20:14:23Z" } } ] diff --git a/plugins/kubernetes-react/src/__fixtures__/1-statefulsets.json b/plugins/kubernetes-react/src/__fixtures__/1-statefulsets.json index 6c04774ff1..5d9b56300a 100644 --- a/plugins/kubernetes-react/src/__fixtures__/1-statefulsets.json +++ b/plugins/kubernetes-react/src/__fixtures__/1-statefulsets.json @@ -2827,85 +2827,80 @@ ], "horizontalPodAutoscalers": [ { - "apiVersion": "autoscaling/v1", + "apiVersion": "autoscaling/v2", "kind": "HorizontalPodAutoscaler", "metadata": { - "annotations": { - "autoscaling.alpha.kubernetes.io/conditions": "[{\"type\":\"AbleToScale\",\"status\":\"True\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"SucceededGetScale\",\"message\":\"the HPA controller was able to get the target's current scale\"},{\"type\":\"ScalingActive\",\"status\":\"False\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"FailedGetResourceMetric\",\"message\":\"the HPA was unable to compute the replica count: unable to get metrics for resource cpu: no metrics returned from resource metrics API\"}]", - "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"autoscaling/v1\",\"kind\":\"HorizontalPodAutoscaler\",\"metadata\":{\"annotations\":{},\"labels\":{\"backstage.io/kubernetes-id\":\"dice-roller\"},\"name\":\"dice-roller\",\"namespace\":\"default\"},\"spec\":{\"maxReplicas\":15,\"minReplicas\":10,\"scaleTargetRef\":{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"name\":\"dice-roller\"},\"targetCPUUtilizationPercentage\":50}}\n" - }, - "creationTimestamp": "2021-01-05T10:25:48Z", + "annotations": {}, + "creationTimestamp": "2024-02-13T20:13:52Z", "labels": { "backstage.io/kubernetes-id": "dice-roller" }, - "managedFields": [ - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - ".": {}, - "f:kubectl.kubernetes.io/last-applied-configuration": {} - }, - "f:labels": { - ".": {}, - "f:backstage.io/kubernetes-id": {} - } - }, - "f:spec": { - "f:maxReplicas": {}, - "f:minReplicas": {}, - "f:scaleTargetRef": { - "f:apiVersion": {}, - "f:kind": {}, - "f:name": {} - }, - "f:targetCPUUtilizationPercentage": {} - } - }, - "manager": "kubectl-client-side-apply", - "operation": "Update", - "time": "2021-01-05T10:25:48Z" - }, - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - "f:autoscaling.alpha.kubernetes.io/conditions": {} - } - }, - "f:status": { - "f:currentReplicas": {} - } - }, - "manager": "kube-controller-manager", - "operation": "Update", - "time": "2021-01-05T10:26:04Z" - } - ], "name": "dice-roller", "namespace": "default", - "resourceVersion": "598", - "selfLink": "/apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers/dice-roller", - "uid": "dd7c5329-567c-43c2-b159-756808d90a8e" + "resourceVersion": "6717s736", + "uid": "a34c90e1-8e8f-407f-b4c5-b4543bd56c1b" }, "spec": { - "maxReplicas": 15, - "minReplicas": 10, + "maxReplicas": 2, + "metrics": [ + { + "resource": { + "name": "cpu", + "target": { + "averageUtilization": 50, + "type": "Utilization" + } + }, + "type": "Resource" + } + ], + "minReplicas": 1, "scaleTargetRef": { "apiVersion": "apps/v1", "kind": "Deployment", "name": "dice-roller" - }, - "targetCPUUtilizationPercentage": 50 + } }, "status": { - "currentReplicas": 10, - "desiredReplicas": 0, - "currentCPUUtilizationPercentage": 30 + "conditions": [ + { + "lastTransitionTime": "2024-05-17T19:50:35Z", + "message": "recent recommendations were higher than current one, applying the highest recent recommendation", + "reason": "ScaleDownStabilized", + "status": "True", + "type": "AbleToScale" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the HPA was able to successfully calculate a replica count from cpu resource utilization (percentage of request)", + "reason": "ValidMetricFound", + "status": "True", + "type": "ScalingActive" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the desired replica count is more than the maximum replica count", + "reason": "TooManyReplicas", + "status": "True", + "type": "ScalingLimited" + } + ], + "currentMetrics": [ + { + "resource": { + "current": { + "averageUtilization": 100, + "averageValue": "50m", + "value": "100m" + }, + "name": "cpu" + }, + "type": "Resource" + } + ], + "currentReplicas": 2, + "desiredReplicas": 2, + "lastScaleTime": "2024-02-13T20:14:23Z" } } ] diff --git a/plugins/kubernetes-react/src/__fixtures__/2-deployments.json b/plugins/kubernetes-react/src/__fixtures__/2-deployments.json index f5efdbf1cb..829636b6f3 100644 --- a/plugins/kubernetes-react/src/__fixtures__/2-deployments.json +++ b/plugins/kubernetes-react/src/__fixtures__/2-deployments.json @@ -4434,85 +4434,80 @@ ], "horizontalPodAutoscalers": [ { - "apiVersion": "autoscaling/v1", + "apiVersion": "autoscaling/v2", "kind": "HorizontalPodAutoscaler", "metadata": { - "annotations": { - "autoscaling.alpha.kubernetes.io/conditions": "[{\"type\":\"AbleToScale\",\"status\":\"True\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"SucceededGetScale\",\"message\":\"the HPA controller was able to get the target's current scale\"},{\"type\":\"ScalingActive\",\"status\":\"False\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"FailedGetResourceMetric\",\"message\":\"the HPA was unable to compute the replica count: unable to get metrics for resource cpu: no metrics returned from resource metrics API\"}]", - "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"autoscaling/v1\",\"kind\":\"HorizontalPodAutoscaler\",\"metadata\":{\"annotations\":{},\"labels\":{\"backstage.io/kubernetes-id\":\"dice-roller\"},\"name\":\"dice-roller\",\"namespace\":\"default\"},\"spec\":{\"maxReplicas\":15,\"minReplicas\":10,\"scaleTargetRef\":{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"name\":\"dice-roller\"},\"targetCPUUtilizationPercentage\":50}}\n" - }, - "creationTimestamp": "2021-01-05T10:25:48Z", + "annotations": {}, + "creationTimestamp": "2024-02-13T20:13:52Z", "labels": { "backstage.io/kubernetes-id": "dice-roller" }, - "managedFields": [ - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - ".": {}, - "f:kubectl.kubernetes.io/last-applied-configuration": {} - }, - "f:labels": { - ".": {}, - "f:backstage.io/kubernetes-id": {} - } - }, - "f:spec": { - "f:maxReplicas": {}, - "f:minReplicas": {}, - "f:scaleTargetRef": { - "f:apiVersion": {}, - "f:kind": {}, - "f:name": {} - }, - "f:targetCPUUtilizationPercentage": {} - } - }, - "manager": "kubectl-client-side-apply", - "operation": "Update", - "time": "2021-01-05T10:25:48Z" - }, - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - "f:autoscaling.alpha.kubernetes.io/conditions": {} - } - }, - "f:status": { - "f:currentReplicas": {} - } - }, - "manager": "kube-controller-manager", - "operation": "Update", - "time": "2021-01-05T10:26:04Z" - } - ], "name": "dice-roller", "namespace": "default", - "resourceVersion": "598", - "selfLink": "/apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers/dice-roller", - "uid": "dd7c5329-567c-43c2-b159-756808d90a8e" + "resourceVersion": "6717s736", + "uid": "a34c90e1-8e8f-407f-b4c5-b4543bd56c1b" }, "spec": { "maxReplicas": 15, + "metrics": [ + { + "resource": { + "name": "cpu", + "target": { + "averageUtilization": 50, + "type": "Utilization" + } + }, + "type": "Resource" + } + ], "minReplicas": 10, "scaleTargetRef": { "apiVersion": "apps/v1", "kind": "Deployment", "name": "dice-roller" - }, - "targetCPUUtilizationPercentage": 50 + } }, "status": { - "currentReplicas": 10, - "desiredReplicas": 0, - "currentCPUUtilizationPercentage": 30 + "conditions": [ + { + "lastTransitionTime": "2024-05-17T19:50:35Z", + "message": "recent recommendations were higher than current one, applying the highest recent recommendation", + "reason": "ScaleDownStabilized", + "status": "True", + "type": "AbleToScale" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the HPA was able to successfully calculate a replica count from cpu resource utilization (percentage of request)", + "reason": "ValidMetricFound", + "status": "True", + "type": "ScalingActive" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the desired replica count is more than the maximum replica count", + "reason": "TooManyReplicas", + "status": "True", + "type": "ScalingLimited" + } + ], + "currentMetrics": [ + { + "resource": { + "current": { + "averageUtilization": 30, + "averageValue": "50m", + "value": "100m" + }, + "name": "cpu" + }, + "type": "Resource" + } + ], + "currentReplicas": 2, + "desiredReplicas": 2, + "lastScaleTime": "2024-02-13T20:14:23Z" } } ] diff --git a/plugins/kubernetes-react/src/__fixtures__/2-statefulsets.json b/plugins/kubernetes-react/src/__fixtures__/2-statefulsets.json index 0a8c26c198..c45b1070d6 100644 --- a/plugins/kubernetes-react/src/__fixtures__/2-statefulsets.json +++ b/plugins/kubernetes-react/src/__fixtures__/2-statefulsets.json @@ -4436,85 +4436,80 @@ ], "horizontalPodAutoscalers": [ { - "apiVersion": "autoscaling/v1", + "apiVersion": "autoscaling/v2", "kind": "HorizontalPodAutoscaler", "metadata": { - "annotations": { - "autoscaling.alpha.kubernetes.io/conditions": "[{\"type\":\"AbleToScale\",\"status\":\"True\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"SucceededGetScale\",\"message\":\"the HPA controller was able to get the target's current scale\"},{\"type\":\"ScalingActive\",\"status\":\"False\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"FailedGetResourceMetric\",\"message\":\"the HPA was unable to compute the replica count: unable to get metrics for resource cpu: no metrics returned from resource metrics API\"}]", - "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"autoscaling/v1\",\"kind\":\"HorizontalPodAutoscaler\",\"metadata\":{\"annotations\":{},\"labels\":{\"backstage.io/kubernetes-id\":\"dice-roller\"},\"name\":\"dice-roller\",\"namespace\":\"default\"},\"spec\":{\"maxReplicas\":15,\"minReplicas\":10,\"scaleTargetRef\":{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"name\":\"dice-roller\"},\"targetCPUUtilizationPercentage\":50}}\n" - }, - "creationTimestamp": "2021-01-05T10:25:48Z", + "annotations": {}, + "creationTimestamp": "2024-02-13T20:13:52Z", "labels": { "backstage.io/kubernetes-id": "dice-roller" }, - "managedFields": [ - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - ".": {}, - "f:kubectl.kubernetes.io/last-applied-configuration": {} - }, - "f:labels": { - ".": {}, - "f:backstage.io/kubernetes-id": {} - } - }, - "f:spec": { - "f:maxReplicas": {}, - "f:minReplicas": {}, - "f:scaleTargetRef": { - "f:apiVersion": {}, - "f:kind": {}, - "f:name": {} - }, - "f:targetCPUUtilizationPercentage": {} - } - }, - "manager": "kubectl-client-side-apply", - "operation": "Update", - "time": "2021-01-05T10:25:48Z" - }, - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - "f:autoscaling.alpha.kubernetes.io/conditions": {} - } - }, - "f:status": { - "f:currentReplicas": {} - } - }, - "manager": "kube-controller-manager", - "operation": "Update", - "time": "2021-01-05T10:26:04Z" - } - ], "name": "dice-roller", "namespace": "default", - "resourceVersion": "598", - "selfLink": "/apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers/dice-roller", - "uid": "dd7c5329-567c-43c2-b159-756808d90a8e" + "resourceVersion": "6717s736", + "uid": "a34c90e1-8e8f-407f-b4c5-b4543bd56c1b" }, "spec": { - "maxReplicas": 15, - "minReplicas": 10, + "maxReplicas": 2, + "metrics": [ + { + "resource": { + "name": "cpu", + "target": { + "averageUtilization": 50, + "type": "Utilization" + } + }, + "type": "Resource" + } + ], + "minReplicas": 1, "scaleTargetRef": { "apiVersion": "apps/v1", "kind": "Deployment", "name": "dice-roller" - }, - "targetCPUUtilizationPercentage": 50 + } }, "status": { - "currentReplicas": 10, - "desiredReplicas": 0, - "currentCPUUtilizationPercentage": 30 + "conditions": [ + { + "lastTransitionTime": "2024-05-17T19:50:35Z", + "message": "recent recommendations were higher than current one, applying the highest recent recommendation", + "reason": "ScaleDownStabilized", + "status": "True", + "type": "AbleToScale" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the HPA was able to successfully calculate a replica count from cpu resource utilization (percentage of request)", + "reason": "ValidMetricFound", + "status": "True", + "type": "ScalingActive" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the desired replica count is more than the maximum replica count", + "reason": "TooManyReplicas", + "status": "True", + "type": "ScalingLimited" + } + ], + "currentMetrics": [ + { + "resource": { + "current": { + "averageUtilization": 100, + "averageValue": "50m", + "value": "100m" + }, + "name": "cpu" + }, + "type": "Resource" + } + ], + "currentReplicas": 2, + "desiredReplicas": 2, + "lastScaleTime": "2024-02-13T20:14:23Z" } } ] diff --git a/plugins/kubernetes-react/src/components/CustomResources/ArgoRollouts/Rollout.tsx b/plugins/kubernetes-react/src/components/CustomResources/ArgoRollouts/Rollout.tsx index 65749c2ea2..8e62b2606f 100644 --- a/plugins/kubernetes-react/src/components/CustomResources/ArgoRollouts/Rollout.tsx +++ b/plugins/kubernetes-react/src/components/CustomResources/ArgoRollouts/Rollout.tsx @@ -21,7 +21,7 @@ import AccordionSummary from '@material-ui/core/AccordionSummary'; import Grid from '@material-ui/core/Grid'; import Typography from '@material-ui/core/Typography'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; -import { V1Pod, V1HorizontalPodAutoscaler } from '@kubernetes/client-node'; +import { V1Pod, V2HorizontalPodAutoscaler } from '@kubernetes/client-node'; import { PodsTable } from '../../Pods'; import { HorizontalPodAutoscalerDrawer } from '../../HorizontalPodAutoscalers'; import { RolloutDrawer } from './RolloutDrawer'; @@ -50,7 +50,7 @@ type RolloutAccordionProps = { rollout: any; ownedPods: V1Pod[]; defaultExpanded?: boolean; - matchingHpa?: V1HorizontalPodAutoscaler; + matchingHpa?: V2HorizontalPodAutoscaler; children?: React.ReactNode; }; @@ -58,7 +58,7 @@ type RolloutSummaryProps = { rollout: any; numberOfCurrentPods: number; numberOfPodsWithErrors: number; - hpa?: V1HorizontalPodAutoscaler; + hpa?: V2HorizontalPodAutoscaler; children?: React.ReactNode; }; @@ -93,6 +93,13 @@ const RolloutSummary = ({ (p: any) => p.reason === 'CanaryPauseStep', )?.startTime; const abortedMessage = findAbortedMessage(rollout); + const specCpuUtil = hpa?.spec?.metrics?.find( + metric => metric.type === 'Resource' && metric.resource?.name === 'cpu', + )?.resource?.target.averageUtilization; + + const cpuUtil = hpa?.status?.currentMetrics?.find( + metric => metric.type === 'Resource' && metric.resource?.name === 'cpu', + )?.resource?.current.averageUtilization; return ( - current CPU usage:{' '} - {hpa.status?.currentCPUUtilizationPercentage ?? '?'}% + current CPU usage: {cpuUtil ?? '?'}% - target CPU usage:{' '} - {hpa.spec?.targetCPUUtilizationPercentage ?? '?'}% + target CPU usage: {specCpuUtil ?? '?'}% diff --git a/plugins/kubernetes-react/src/components/DeploymentsAccordions/DeploymentsAccordions.tsx b/plugins/kubernetes-react/src/components/DeploymentsAccordions/DeploymentsAccordions.tsx index 3d048f22df..8cfc79a8ae 100644 --- a/plugins/kubernetes-react/src/components/DeploymentsAccordions/DeploymentsAccordions.tsx +++ b/plugins/kubernetes-react/src/components/DeploymentsAccordions/DeploymentsAccordions.tsx @@ -24,7 +24,7 @@ import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import { V1Deployment, V1Pod, - V1HorizontalPodAutoscaler, + V2HorizontalPodAutoscaler, } from '@kubernetes/client-node'; import { PodsTable } from '../Pods'; import { DeploymentDrawer } from './DeploymentDrawer'; @@ -47,7 +47,7 @@ type DeploymentsAccordionsProps = { type DeploymentAccordionProps = { deployment: V1Deployment; ownedPods: V1Pod[]; - matchingHpa?: V1HorizontalPodAutoscaler; + matchingHpa?: V2HorizontalPodAutoscaler; children?: React.ReactNode; }; @@ -55,7 +55,7 @@ type DeploymentSummaryProps = { deployment: V1Deployment; numberOfCurrentPods: number; numberOfPodsWithErrors: number; - hpa?: V1HorizontalPodAutoscaler; + hpa?: V2HorizontalPodAutoscaler; children?: React.ReactNode; }; @@ -65,6 +65,14 @@ const DeploymentSummary = ({ numberOfPodsWithErrors, hpa, }: DeploymentSummaryProps) => { + const specCpuUtil = hpa?.spec?.metrics?.find( + metric => metric.type === 'Resource' && metric.resource?.name === 'cpu', + )?.resource?.target.averageUtilization; + + const cpuUtil = hpa?.status?.currentMetrics?.find( + metric => metric.type === 'Resource' && metric.resource?.name === 'cpu', + )?.resource?.current.averageUtilization; + return ( - current CPU usage:{' '} - {hpa.status?.currentCPUUtilizationPercentage ?? '?'}% + current CPU usage: {cpuUtil ?? '?'}% - target CPU usage:{' '} - {hpa.spec?.targetCPUUtilizationPercentage ?? '?'}% + target CPU usage: {specCpuUtil ?? '?'}% diff --git a/plugins/kubernetes-react/src/components/HorizontalPodAutoscalers/HorizontalPodAutoscalerDrawer.tsx b/plugins/kubernetes-react/src/components/HorizontalPodAutoscalers/HorizontalPodAutoscalerDrawer.tsx index dba942155c..0194bfca2a 100644 --- a/plugins/kubernetes-react/src/components/HorizontalPodAutoscalers/HorizontalPodAutoscalerDrawer.tsx +++ b/plugins/kubernetes-react/src/components/HorizontalPodAutoscalers/HorizontalPodAutoscalerDrawer.tsx @@ -15,32 +15,39 @@ */ import React from 'react'; -import { V1HorizontalPodAutoscaler } from '@kubernetes/client-node'; +import { V2HorizontalPodAutoscaler } from '@kubernetes/client-node'; import { KubernetesStructuredMetadataTableDrawer } from '../KubernetesDrawer'; /** @public */ export const HorizontalPodAutoscalerDrawer = (props: { - hpa: V1HorizontalPodAutoscaler; + hpa: V2HorizontalPodAutoscaler; expanded?: boolean; children?: React.ReactNode; }) => { const { hpa, expanded, children } = props; + const specCpuUtil = hpa?.spec?.metrics?.find( + metric => metric.type === 'Resource' && metric.resource?.name === 'cpu', + )?.resource?.target.averageUtilization; + + const cpuUtil = hpa?.status?.currentMetrics?.find( + metric => metric.type === 'Resource' && metric.resource?.name === 'cpu', + )?.resource?.current.averageUtilization; + return ( { + renderObject={(hpaObject: V2HorizontalPodAutoscaler) => { return { - targetCPUUtilizationPercentage: - hpaObject.spec?.targetCPUUtilizationPercentage, - currentCPUUtilizationPercentage: - hpaObject.status?.currentCPUUtilizationPercentage, + targetCPUUtilizationPercentage: specCpuUtil, + currentCPUUtilizationPercentage: cpuUtil, minReplicas: hpaObject.spec?.minReplicas, maxReplicas: hpaObject.spec?.maxReplicas, currentReplicas: hpaObject.status?.currentReplicas, desiredReplicas: hpaObject.status?.desiredReplicas, + lastScaleTime: hpa?.status?.lastScaleTime, }; }} > diff --git a/plugins/kubernetes-react/src/components/HorizontalPodAutoscalers/__fixtures__/horizontalpodautoscalers.json b/plugins/kubernetes-react/src/components/HorizontalPodAutoscalers/__fixtures__/horizontalpodautoscalers.json index 6afdda48ed..94cc8a840d 100644 --- a/plugins/kubernetes-react/src/components/HorizontalPodAutoscalers/__fixtures__/horizontalpodautoscalers.json +++ b/plugins/kubernetes-react/src/components/HorizontalPodAutoscalers/__fixtures__/horizontalpodautoscalers.json @@ -1,82 +1,79 @@ [ { + "apiVersion": "autoscaling/v2", + "kind": "HorizontalPodAutoscaler", "metadata": { - "annotations": { - "autoscaling.alpha.kubernetes.io/conditions": "[{\"type\":\"AbleToScale\",\"status\":\"True\",\"lastTransitionTime\":\"2020-09-28T13:28:15Z\",\"reason\":\"SucceededGetScale\",\"message\":\"the HPA controller was able to get the target's current scale\"},{\"type\":\"ScalingActive\",\"status\":\"False\",\"lastTransitionTime\":\"2020-09-28T13:28:15Z\",\"reason\":\"FailedGetResourceMetric\",\"message\":\"the HPA was unable to compute the replica count: unable to get metrics for resource cpu: unable to fetch metrics from resource metrics API: the server could not find the requested resource (get pods.metrics.k8s.io)\"}]", - "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"autoscaling/v1\",\"kind\":\"HorizontalPodAutoscaler\",\"metadata\":{\"annotations\":{},\"labels\":{\"backstage.io/kubernetes-id\":\"dice-roller\"},\"name\":\"dice-roller\",\"namespace\":\"default\"},\"spec\":{\"maxReplicas\":15,\"minReplicas\":10,\"scaleTargetRef\":{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"name\":\"dice-roller\"},\"targetCPUUtilizationPercentage\":50}}\n" - }, - "creationTimestamp": "2020-09-28T13:28:00.000Z", + "annotations": {}, + "creationTimestamp": "2024-02-13T20:13:52Z", "labels": { "backstage.io/kubernetes-id": "dice-roller" }, - "managedFields": [ - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - "f:autoscaling.alpha.kubernetes.io/conditions": {} - } - }, - "f:status": { - "f:currentReplicas": {} - } - }, - "manager": "kube-controller-manager", - "operation": "Update", - "time": "2020-09-28T13:28:15.000Z" - }, - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - ".": {}, - "f:kubectl.kubernetes.io/last-applied-configuration": {} - }, - "f:labels": { - ".": {}, - "f:backstage.io/kubernetes-id": {} - } - }, - "f:spec": { - "f:maxReplicas": {}, - "f:minReplicas": {}, - "f:scaleTargetRef": { - "f:apiVersion": {}, - "f:kind": {}, - "f:name": {} - }, - "f:targetCPUUtilizationPercentage": {} - } - }, - "manager": "kubectl", - "operation": "Update", - "time": "2020-09-28T13:28:21.000Z" - } - ], "name": "dice-roller", "namespace": "default", - "resourceVersion": "698957", - "selfLink": "/apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers/dice-roller", - "uid": "a70c8a90-5605-4d7d-adea-05cfb8d9d446" + "resourceVersion": "6717s736", + "uid": "a34c90e1-8e8f-407f-b4c5-b4543bd56c1b" }, "spec": { "maxReplicas": 15, + "metrics": [ + { + "resource": { + "name": "cpu", + "target": { + "averageUtilization": 30, + "type": "Utilization" + } + }, + "type": "Resource" + } + ], "minReplicas": 10, "scaleTargetRef": { "apiVersion": "apps/v1", "kind": "Deployment", "name": "dice-roller" - }, - "targetCPUUtilizationPercentage": 50 + } }, "status": { + "conditions": [ + { + "lastTransitionTime": "2024-05-17T19:50:35Z", + "message": "recent recommendations were higher than current one, applying the highest recent recommendation", + "reason": "ScaleDownStabilized", + "status": "True", + "type": "AbleToScale" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the HPA was able to successfully calculate a replica count from cpu resource utilization (percentage of request)", + "reason": "ValidMetricFound", + "status": "True", + "type": "ScalingActive" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the desired replica count is more than the maximum replica count", + "reason": "TooManyReplicas", + "status": "True", + "type": "ScalingLimited" + } + ], + "currentMetrics": [ + { + "resource": { + "current": { + "averageUtilization": 50, + "averageValue": "50m", + "value": "100m" + }, + "name": "cpu" + }, + "type": "Resource" + } + ], "currentReplicas": 13, "desiredReplicas": 14, - "currentCPUUtilizationPercentage": 30 + "lastScaleTime": "2024-02-13T20:14:23Z" } } ] diff --git a/plugins/kubernetes-react/src/components/StatefulSetsAccordions/StatefulSetsAccordions.tsx b/plugins/kubernetes-react/src/components/StatefulSetsAccordions/StatefulSetsAccordions.tsx index 00f08c3c98..80fff510e7 100644 --- a/plugins/kubernetes-react/src/components/StatefulSetsAccordions/StatefulSetsAccordions.tsx +++ b/plugins/kubernetes-react/src/components/StatefulSetsAccordions/StatefulSetsAccordions.tsx @@ -23,7 +23,7 @@ import Typography from '@material-ui/core/Typography'; import ExpandMoreIcon from '@material-ui/icons/ExpandMore'; import { V1Pod, - V1HorizontalPodAutoscaler, + V2HorizontalPodAutoscaler, V1StatefulSet, } from '@kubernetes/client-node'; import { PodsTable } from '../Pods'; @@ -44,7 +44,7 @@ type StatefulSetsAccordionsProps = { type StatefulSetAccordionProps = { statefulset: V1StatefulSet; ownedPods: V1Pod[]; - matchingHpa?: V1HorizontalPodAutoscaler; + matchingHpa?: V2HorizontalPodAutoscaler; children?: React.ReactNode; }; @@ -52,7 +52,7 @@ type StatefulSetSummaryProps = { statefulset: V1StatefulSet; numberOfCurrentPods: number; numberOfPodsWithErrors: number; - hpa?: V1HorizontalPodAutoscaler; + hpa?: V2HorizontalPodAutoscaler; children?: React.ReactNode; }; @@ -62,6 +62,14 @@ const StatefulSetSummary = ({ numberOfPodsWithErrors, hpa, }: StatefulSetSummaryProps) => { + const specCpuUtil = hpa?.spec?.metrics?.find( + metric => metric.type === 'Resource' && metric.resource?.name === 'cpu', + )?.resource?.target.averageUtilization; + + const cpuUtil = hpa?.status?.currentMetrics?.find( + metric => metric.type === 'Resource' && metric.resource?.name === 'cpu', + )?.resource?.current.averageUtilization; + return ( - current CPU usage:{' '} - {hpa.status?.currentCPUUtilizationPercentage ?? '?'}% + current CPU usage: {cpuUtil ?? '?'}% - target CPU usage:{' '} - {hpa.spec?.targetCPUUtilizationPercentage ?? '?'}% + target CPU usage: {specCpuUtil ?? '?'}% diff --git a/plugins/kubernetes-react/src/utils/owner.ts b/plugins/kubernetes-react/src/utils/owner.ts index 1c1d8089a3..bd0cd39677 100644 --- a/plugins/kubernetes-react/src/utils/owner.ts +++ b/plugins/kubernetes-react/src/utils/owner.ts @@ -16,7 +16,7 @@ import { V1ObjectMeta } from '@kubernetes/client-node/dist/gen/model/v1ObjectMeta'; import { - V1HorizontalPodAutoscaler, + V2HorizontalPodAutoscaler, V1Pod, V1ReplicaSet, } from '@kubernetes/client-node'; @@ -62,8 +62,8 @@ interface ResourceRef { export const getMatchingHpa = ( owner: ResourceRef, - hpas: V1HorizontalPodAutoscaler[], -): V1HorizontalPodAutoscaler | undefined => { + hpas: V2HorizontalPodAutoscaler[], +): V2HorizontalPodAutoscaler | undefined => { return hpas.find(hpa => { return ( (hpa.spec?.scaleTargetRef?.kind ?? '').toLocaleLowerCase('en-US') === diff --git a/plugins/kubernetes/src/__fixtures__/1-deployments.json b/plugins/kubernetes/src/__fixtures__/1-deployments.json index 5ad847dc49..3a9da2a33a 100644 --- a/plugins/kubernetes/src/__fixtures__/1-deployments.json +++ b/plugins/kubernetes/src/__fixtures__/1-deployments.json @@ -2826,85 +2826,80 @@ ], "horizontalPodAutoscalers": [ { - "apiVersion": "autoscaling/v1", + "apiVersion": "autoscaling/v2", "kind": "HorizontalPodAutoscaler", "metadata": { - "annotations": { - "autoscaling.alpha.kubernetes.io/conditions": "[{\"type\":\"AbleToScale\",\"status\":\"True\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"SucceededGetScale\",\"message\":\"the HPA controller was able to get the target's current scale\"},{\"type\":\"ScalingActive\",\"status\":\"False\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"FailedGetResourceMetric\",\"message\":\"the HPA was unable to compute the replica count: unable to get metrics for resource cpu: no metrics returned from resource metrics API\"}]", - "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"autoscaling/v1\",\"kind\":\"HorizontalPodAutoscaler\",\"metadata\":{\"annotations\":{},\"labels\":{\"backstage.io/kubernetes-id\":\"dice-roller\"},\"name\":\"dice-roller\",\"namespace\":\"default\"},\"spec\":{\"maxReplicas\":15,\"minReplicas\":10,\"scaleTargetRef\":{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"name\":\"dice-roller\"},\"targetCPUUtilizationPercentage\":50}}\n" - }, - "creationTimestamp": "2021-01-05T10:25:48Z", + "annotations": {}, + "creationTimestamp": "2024-02-13T20:13:52Z", "labels": { "backstage.io/kubernetes-id": "dice-roller" }, - "managedFields": [ - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - ".": {}, - "f:kubectl.kubernetes.io/last-applied-configuration": {} - }, - "f:labels": { - ".": {}, - "f:backstage.io/kubernetes-id": {} - } - }, - "f:spec": { - "f:maxReplicas": {}, - "f:minReplicas": {}, - "f:scaleTargetRef": { - "f:apiVersion": {}, - "f:kind": {}, - "f:name": {} - }, - "f:targetCPUUtilizationPercentage": {} - } - }, - "manager": "kubectl-client-side-apply", - "operation": "Update", - "time": "2021-01-05T10:25:48Z" - }, - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - "f:autoscaling.alpha.kubernetes.io/conditions": {} - } - }, - "f:status": { - "f:currentReplicas": {} - } - }, - "manager": "kube-controller-manager", - "operation": "Update", - "time": "2021-01-05T10:26:04Z" - } - ], "name": "dice-roller", "namespace": "default", - "resourceVersion": "598", - "selfLink": "/apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers/dice-roller", - "uid": "dd7c5329-567c-43c2-b159-756808d90a8e" + "resourceVersion": "6717s736", + "uid": "a34c90e1-8e8f-407f-b4c5-b4543bd56c1b" }, "spec": { - "maxReplicas": 15, - "minReplicas": 10, + "maxReplicas": 2, + "metrics": [ + { + "resource": { + "name": "cpu", + "target": { + "averageUtilization": 50, + "type": "Utilization" + } + }, + "type": "Resource" + } + ], + "minReplicas": 1, "scaleTargetRef": { "apiVersion": "apps/v1", "kind": "Deployment", "name": "dice-roller" - }, - "targetCPUUtilizationPercentage": 50 + } }, "status": { - "currentReplicas": 10, - "desiredReplicas": 0, - "currentCPUUtilizationPercentage": 30 + "conditions": [ + { + "lastTransitionTime": "2024-05-17T19:50:35Z", + "message": "recent recommendations were higher than current one, applying the highest recent recommendation", + "reason": "ScaleDownStabilized", + "status": "True", + "type": "AbleToScale" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the HPA was able to successfully calculate a replica count from cpu resource utilization (percentage of request)", + "reason": "ValidMetricFound", + "status": "True", + "type": "ScalingActive" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the desired replica count is more than the maximum replica count", + "reason": "TooManyReplicas", + "status": "True", + "type": "ScalingLimited" + } + ], + "currentMetrics": [ + { + "resource": { + "current": { + "averageUtilization": 100, + "averageValue": "50m", + "value": "100m" + }, + "name": "cpu" + }, + "type": "Resource" + } + ], + "currentReplicas": 2, + "desiredReplicas": 2, + "lastScaleTime": "2024-02-13T20:14:23Z" } } ] diff --git a/plugins/kubernetes/src/__fixtures__/1-statefulsets.json b/plugins/kubernetes/src/__fixtures__/1-statefulsets.json index 6c04774ff1..5d9b56300a 100644 --- a/plugins/kubernetes/src/__fixtures__/1-statefulsets.json +++ b/plugins/kubernetes/src/__fixtures__/1-statefulsets.json @@ -2827,85 +2827,80 @@ ], "horizontalPodAutoscalers": [ { - "apiVersion": "autoscaling/v1", + "apiVersion": "autoscaling/v2", "kind": "HorizontalPodAutoscaler", "metadata": { - "annotations": { - "autoscaling.alpha.kubernetes.io/conditions": "[{\"type\":\"AbleToScale\",\"status\":\"True\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"SucceededGetScale\",\"message\":\"the HPA controller was able to get the target's current scale\"},{\"type\":\"ScalingActive\",\"status\":\"False\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"FailedGetResourceMetric\",\"message\":\"the HPA was unable to compute the replica count: unable to get metrics for resource cpu: no metrics returned from resource metrics API\"}]", - "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"autoscaling/v1\",\"kind\":\"HorizontalPodAutoscaler\",\"metadata\":{\"annotations\":{},\"labels\":{\"backstage.io/kubernetes-id\":\"dice-roller\"},\"name\":\"dice-roller\",\"namespace\":\"default\"},\"spec\":{\"maxReplicas\":15,\"minReplicas\":10,\"scaleTargetRef\":{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"name\":\"dice-roller\"},\"targetCPUUtilizationPercentage\":50}}\n" - }, - "creationTimestamp": "2021-01-05T10:25:48Z", + "annotations": {}, + "creationTimestamp": "2024-02-13T20:13:52Z", "labels": { "backstage.io/kubernetes-id": "dice-roller" }, - "managedFields": [ - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - ".": {}, - "f:kubectl.kubernetes.io/last-applied-configuration": {} - }, - "f:labels": { - ".": {}, - "f:backstage.io/kubernetes-id": {} - } - }, - "f:spec": { - "f:maxReplicas": {}, - "f:minReplicas": {}, - "f:scaleTargetRef": { - "f:apiVersion": {}, - "f:kind": {}, - "f:name": {} - }, - "f:targetCPUUtilizationPercentage": {} - } - }, - "manager": "kubectl-client-side-apply", - "operation": "Update", - "time": "2021-01-05T10:25:48Z" - }, - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - "f:autoscaling.alpha.kubernetes.io/conditions": {} - } - }, - "f:status": { - "f:currentReplicas": {} - } - }, - "manager": "kube-controller-manager", - "operation": "Update", - "time": "2021-01-05T10:26:04Z" - } - ], "name": "dice-roller", "namespace": "default", - "resourceVersion": "598", - "selfLink": "/apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers/dice-roller", - "uid": "dd7c5329-567c-43c2-b159-756808d90a8e" + "resourceVersion": "6717s736", + "uid": "a34c90e1-8e8f-407f-b4c5-b4543bd56c1b" }, "spec": { - "maxReplicas": 15, - "minReplicas": 10, + "maxReplicas": 2, + "metrics": [ + { + "resource": { + "name": "cpu", + "target": { + "averageUtilization": 50, + "type": "Utilization" + } + }, + "type": "Resource" + } + ], + "minReplicas": 1, "scaleTargetRef": { "apiVersion": "apps/v1", "kind": "Deployment", "name": "dice-roller" - }, - "targetCPUUtilizationPercentage": 50 + } }, "status": { - "currentReplicas": 10, - "desiredReplicas": 0, - "currentCPUUtilizationPercentage": 30 + "conditions": [ + { + "lastTransitionTime": "2024-05-17T19:50:35Z", + "message": "recent recommendations were higher than current one, applying the highest recent recommendation", + "reason": "ScaleDownStabilized", + "status": "True", + "type": "AbleToScale" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the HPA was able to successfully calculate a replica count from cpu resource utilization (percentage of request)", + "reason": "ValidMetricFound", + "status": "True", + "type": "ScalingActive" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the desired replica count is more than the maximum replica count", + "reason": "TooManyReplicas", + "status": "True", + "type": "ScalingLimited" + } + ], + "currentMetrics": [ + { + "resource": { + "current": { + "averageUtilization": 100, + "averageValue": "50m", + "value": "100m" + }, + "name": "cpu" + }, + "type": "Resource" + } + ], + "currentReplicas": 2, + "desiredReplicas": 2, + "lastScaleTime": "2024-02-13T20:14:23Z" } } ] diff --git a/plugins/kubernetes/src/__fixtures__/2-deployments.json b/plugins/kubernetes/src/__fixtures__/2-deployments.json index f5efdbf1cb..c8209e9f0a 100644 --- a/plugins/kubernetes/src/__fixtures__/2-deployments.json +++ b/plugins/kubernetes/src/__fixtures__/2-deployments.json @@ -4434,85 +4434,80 @@ ], "horizontalPodAutoscalers": [ { - "apiVersion": "autoscaling/v1", + "apiVersion": "autoscaling/v2", "kind": "HorizontalPodAutoscaler", "metadata": { - "annotations": { - "autoscaling.alpha.kubernetes.io/conditions": "[{\"type\":\"AbleToScale\",\"status\":\"True\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"SucceededGetScale\",\"message\":\"the HPA controller was able to get the target's current scale\"},{\"type\":\"ScalingActive\",\"status\":\"False\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"FailedGetResourceMetric\",\"message\":\"the HPA was unable to compute the replica count: unable to get metrics for resource cpu: no metrics returned from resource metrics API\"}]", - "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"autoscaling/v1\",\"kind\":\"HorizontalPodAutoscaler\",\"metadata\":{\"annotations\":{},\"labels\":{\"backstage.io/kubernetes-id\":\"dice-roller\"},\"name\":\"dice-roller\",\"namespace\":\"default\"},\"spec\":{\"maxReplicas\":15,\"minReplicas\":10,\"scaleTargetRef\":{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"name\":\"dice-roller\"},\"targetCPUUtilizationPercentage\":50}}\n" - }, - "creationTimestamp": "2021-01-05T10:25:48Z", + "annotations": {}, + "creationTimestamp": "2024-02-13T20:13:52Z", "labels": { "backstage.io/kubernetes-id": "dice-roller" }, - "managedFields": [ - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - ".": {}, - "f:kubectl.kubernetes.io/last-applied-configuration": {} - }, - "f:labels": { - ".": {}, - "f:backstage.io/kubernetes-id": {} - } - }, - "f:spec": { - "f:maxReplicas": {}, - "f:minReplicas": {}, - "f:scaleTargetRef": { - "f:apiVersion": {}, - "f:kind": {}, - "f:name": {} - }, - "f:targetCPUUtilizationPercentage": {} - } - }, - "manager": "kubectl-client-side-apply", - "operation": "Update", - "time": "2021-01-05T10:25:48Z" - }, - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - "f:autoscaling.alpha.kubernetes.io/conditions": {} - } - }, - "f:status": { - "f:currentReplicas": {} - } - }, - "manager": "kube-controller-manager", - "operation": "Update", - "time": "2021-01-05T10:26:04Z" - } - ], "name": "dice-roller", "namespace": "default", - "resourceVersion": "598", - "selfLink": "/apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers/dice-roller", - "uid": "dd7c5329-567c-43c2-b159-756808d90a8e" + "resourceVersion": "6717s736", + "uid": "a34c90e1-8e8f-407f-b4c5-b4543bd56c1b" }, "spec": { - "maxReplicas": 15, - "minReplicas": 10, + "maxReplicas": 2, + "metrics": [ + { + "resource": { + "name": "cpu", + "target": { + "averageUtilization": 50, + "type": "Utilization" + } + }, + "type": "Resource" + } + ], + "minReplicas": 1, "scaleTargetRef": { "apiVersion": "apps/v1", "kind": "Deployment", "name": "dice-roller" - }, - "targetCPUUtilizationPercentage": 50 + } }, "status": { - "currentReplicas": 10, - "desiredReplicas": 0, - "currentCPUUtilizationPercentage": 30 + "conditions": [ + { + "lastTransitionTime": "2024-05-17T19:50:35Z", + "message": "recent recommendations were higher than current one, applying the highest recent recommendation", + "reason": "ScaleDownStabilized", + "status": "True", + "type": "AbleToScale" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the HPA was able to successfully calculate a replica count from cpu resource utilization (percentage of request)", + "reason": "ValidMetricFound", + "status": "True", + "type": "ScalingActive" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the desired replica count is more than the maximum replica count", + "reason": "TooManyReplicas", + "status": "True", + "type": "ScalingLimited" + } + ], + "currentMetrics": [ + { + "resource": { + "current": { + "averageUtilization": 100, + "averageValue": "50m", + "value": "100m" + }, + "name": "cpu" + }, + "type": "Resource" + } + ], + "currentReplicas": 2, + "desiredReplicas": 2, + "lastScaleTime": "2024-02-13T20:14:23Z" } } ] diff --git a/plugins/kubernetes/src/__fixtures__/2-statefulsets.json b/plugins/kubernetes/src/__fixtures__/2-statefulsets.json index 0a8c26c198..c45b1070d6 100644 --- a/plugins/kubernetes/src/__fixtures__/2-statefulsets.json +++ b/plugins/kubernetes/src/__fixtures__/2-statefulsets.json @@ -4436,85 +4436,80 @@ ], "horizontalPodAutoscalers": [ { - "apiVersion": "autoscaling/v1", + "apiVersion": "autoscaling/v2", "kind": "HorizontalPodAutoscaler", "metadata": { - "annotations": { - "autoscaling.alpha.kubernetes.io/conditions": "[{\"type\":\"AbleToScale\",\"status\":\"True\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"SucceededGetScale\",\"message\":\"the HPA controller was able to get the target's current scale\"},{\"type\":\"ScalingActive\",\"status\":\"False\",\"lastTransitionTime\":\"2021-01-05T10:26:04Z\",\"reason\":\"FailedGetResourceMetric\",\"message\":\"the HPA was unable to compute the replica count: unable to get metrics for resource cpu: no metrics returned from resource metrics API\"}]", - "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"autoscaling/v1\",\"kind\":\"HorizontalPodAutoscaler\",\"metadata\":{\"annotations\":{},\"labels\":{\"backstage.io/kubernetes-id\":\"dice-roller\"},\"name\":\"dice-roller\",\"namespace\":\"default\"},\"spec\":{\"maxReplicas\":15,\"minReplicas\":10,\"scaleTargetRef\":{\"apiVersion\":\"apps/v1\",\"kind\":\"Deployment\",\"name\":\"dice-roller\"},\"targetCPUUtilizationPercentage\":50}}\n" - }, - "creationTimestamp": "2021-01-05T10:25:48Z", + "annotations": {}, + "creationTimestamp": "2024-02-13T20:13:52Z", "labels": { "backstage.io/kubernetes-id": "dice-roller" }, - "managedFields": [ - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - ".": {}, - "f:kubectl.kubernetes.io/last-applied-configuration": {} - }, - "f:labels": { - ".": {}, - "f:backstage.io/kubernetes-id": {} - } - }, - "f:spec": { - "f:maxReplicas": {}, - "f:minReplicas": {}, - "f:scaleTargetRef": { - "f:apiVersion": {}, - "f:kind": {}, - "f:name": {} - }, - "f:targetCPUUtilizationPercentage": {} - } - }, - "manager": "kubectl-client-side-apply", - "operation": "Update", - "time": "2021-01-05T10:25:48Z" - }, - { - "apiVersion": "autoscaling/v1", - "fieldsType": "FieldsV1", - "fieldsV1": { - "f:metadata": { - "f:annotations": { - "f:autoscaling.alpha.kubernetes.io/conditions": {} - } - }, - "f:status": { - "f:currentReplicas": {} - } - }, - "manager": "kube-controller-manager", - "operation": "Update", - "time": "2021-01-05T10:26:04Z" - } - ], "name": "dice-roller", "namespace": "default", - "resourceVersion": "598", - "selfLink": "/apis/autoscaling/v1/namespaces/default/horizontalpodautoscalers/dice-roller", - "uid": "dd7c5329-567c-43c2-b159-756808d90a8e" + "resourceVersion": "6717s736", + "uid": "a34c90e1-8e8f-407f-b4c5-b4543bd56c1b" }, "spec": { - "maxReplicas": 15, - "minReplicas": 10, + "maxReplicas": 2, + "metrics": [ + { + "resource": { + "name": "cpu", + "target": { + "averageUtilization": 50, + "type": "Utilization" + } + }, + "type": "Resource" + } + ], + "minReplicas": 1, "scaleTargetRef": { "apiVersion": "apps/v1", "kind": "Deployment", "name": "dice-roller" - }, - "targetCPUUtilizationPercentage": 50 + } }, "status": { - "currentReplicas": 10, - "desiredReplicas": 0, - "currentCPUUtilizationPercentage": 30 + "conditions": [ + { + "lastTransitionTime": "2024-05-17T19:50:35Z", + "message": "recent recommendations were higher than current one, applying the highest recent recommendation", + "reason": "ScaleDownStabilized", + "status": "True", + "type": "AbleToScale" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the HPA was able to successfully calculate a replica count from cpu resource utilization (percentage of request)", + "reason": "ValidMetricFound", + "status": "True", + "type": "ScalingActive" + }, + { + "lastTransitionTime": "2024-05-16T06:21:01Z", + "message": "the desired replica count is more than the maximum replica count", + "reason": "TooManyReplicas", + "status": "True", + "type": "ScalingLimited" + } + ], + "currentMetrics": [ + { + "resource": { + "current": { + "averageUtilization": 100, + "averageValue": "50m", + "value": "100m" + }, + "name": "cpu" + }, + "type": "Resource" + } + ], + "currentReplicas": 2, + "desiredReplicas": 2, + "lastScaleTime": "2024-02-13T20:14:23Z" } } ]