From 7158a2b291fe91ebaec1d9b869c1afb774a5cb65 Mon Sep 17 00:00:00 2001 From: Jim Ehrismann Date: Fri, 27 Jan 2023 16:37:27 -0500 Subject: [PATCH] address review comments, added vpa endpoint to endpoints export list Signed-off-by: Jim Ehrismann --- .../horizontal-pod-autoscaler.api.ts | 7 +-- .../src/common/k8s-api/endpoints/index.ts | 1 + .../types/cross-version-object-reference.ts | 11 ++++ .../common/k8s-api/endpoints/types/index.ts | 1 + .../endpoints/vertical-pod-autoscaler.api.ts | 54 +++++++++++-------- .../+config-vertical-pod-autoscalers/vpa.tsx | 1 - 6 files changed, 46 insertions(+), 29 deletions(-) create mode 100644 packages/core/src/common/k8s-api/endpoints/types/cross-version-object-reference.ts diff --git a/packages/core/src/common/k8s-api/endpoints/horizontal-pod-autoscaler.api.ts b/packages/core/src/common/k8s-api/endpoints/horizontal-pod-autoscaler.api.ts index 12ef92165c..f0bc5d14bc 100644 --- a/packages/core/src/common/k8s-api/endpoints/horizontal-pod-autoscaler.api.ts +++ b/packages/core/src/common/k8s-api/endpoints/horizontal-pod-autoscaler.api.ts @@ -8,6 +8,7 @@ import type { DerivedKubeApiOptions, KubeApiDependencies } from "../kube-api"; import { KubeApi } from "../kube-api"; import type { BaseKubeObjectCondition, LabelSelector, NamespaceScopedMetadata } from "../kube-object"; import { KubeObject } from "../kube-object"; +import type { CrossVersionObjectReference } from "./types/cross-version-object-reference"; export enum HpaMetricType { Resource = "Resource", @@ -299,12 +300,6 @@ export type HorizontalPodAutoscalerMetricStatus = | OptionVarient | OptionVarient; -export interface CrossVersionObjectReference { - kind: string; - name: string; - apiVersion: string; -} - export interface HorizontalPodAutoscalerSpec { scaleTargetRef: CrossVersionObjectReference; minReplicas?: number; diff --git a/packages/core/src/common/k8s-api/endpoints/index.ts b/packages/core/src/common/k8s-api/endpoints/index.ts index 9d3fa94815..0314c6b282 100644 --- a/packages/core/src/common/k8s-api/endpoints/index.ts +++ b/packages/core/src/common/k8s-api/endpoints/index.ts @@ -44,3 +44,4 @@ export * from "./service-account.api"; export * from "./stateful-set.api"; export * from "./storage-class.api"; export * from "./types"; +export * from "./vertical-pod-autoscaler.api"; diff --git a/packages/core/src/common/k8s-api/endpoints/types/cross-version-object-reference.ts b/packages/core/src/common/k8s-api/endpoints/types/cross-version-object-reference.ts new file mode 100644 index 0000000000..b75369bb9b --- /dev/null +++ b/packages/core/src/common/k8s-api/endpoints/types/cross-version-object-reference.ts @@ -0,0 +1,11 @@ +/** + * Copyright (c) OpenLens Authors. All rights reserved. + * Licensed under MIT License. See LICENSE in root directory for more information. + */ + +export interface CrossVersionObjectReference { + kind: string; + name: string; + apiVersion: string; +} + diff --git a/packages/core/src/common/k8s-api/endpoints/types/index.ts b/packages/core/src/common/k8s-api/endpoints/types/index.ts index 6fb52e7403..3214e74f50 100644 --- a/packages/core/src/common/k8s-api/endpoints/types/index.ts +++ b/packages/core/src/common/k8s-api/endpoints/types/index.ts @@ -7,6 +7,7 @@ export * from "./aggregation-rule"; export * from "./capabilities"; export * from "./container"; export * from "./container-port"; +export * from "./cross-version-object-reference"; export * from "./env-from-source"; export * from "./env-source"; export * from "./env-var-key-selector"; diff --git a/packages/core/src/common/k8s-api/endpoints/vertical-pod-autoscaler.api.ts b/packages/core/src/common/k8s-api/endpoints/vertical-pod-autoscaler.api.ts index 2db71b544b..4d8ebb43c1 100644 --- a/packages/core/src/common/k8s-api/endpoints/vertical-pod-autoscaler.api.ts +++ b/packages/core/src/common/k8s-api/endpoints/vertical-pod-autoscaler.api.ts @@ -7,12 +7,7 @@ import type { BaseKubeObjectCondition, NamespaceScopedMetadata } from "../kube-o import { KubeObject } from "../kube-object"; import type { DerivedKubeApiOptions, KubeApiDependencies } from "../kube-api"; import { KubeApi } from "../kube-api"; - -export interface CrossVersionObjectReference { - kind: string; - name: string; - apiVersion?: string; -} +import type { CrossVersionObjectReference } from "./types/cross-version-object-reference"; export enum ResourceName { ResourceCPU = "cpu", @@ -52,7 +47,10 @@ export enum ControlledValues { ControlledValueRequestsOnly = "RequestsOnly", } -// ContainerResourcePolicy controls how autoscaler computes the recommended resources for a specific container. +/** + * ContainerResourcePolicy controls how autoscaler computes the recommended resources for + * a specific container. + */ export interface ContainerResourcePolicy { containerName?: string; mode?: ContainerScalingMode; @@ -62,29 +60,41 @@ export interface ContainerResourcePolicy { controlledValues?: ControlledValues; } -// Controls how the autoscaler computes recommended resources. -// The resource policy may be used to set constraints on the recommendations for individual containers. -// If not specified, the autoscaler computes recommended resources for all containers in the pod, without additional constraints. +/** + * Controls how the autoscaler computes recommended resources. + * The resource policy may be used to set constraints on the recommendations for individual + * containers. + * If not specified, the autoscaler computes recommended resources for all containers in the + * pod, without additional constraints. + */ export interface PodResourcePolicy { containerPolicies?: ContainerResourcePolicy[]; // Per-container resource policies. } export enum UpdateMode { - // UpdateModeOff means that autoscaler never changes Pod resources. - // The recommender still sets the recommended resources in the - // VerticalPodAutoscaler object. This can be used for a "dry run". + /** + * UpdateModeOff means that autoscaler never changes Pod resources. + * The recommender still sets the recommended resources in the + * VerticalPodAutoscaler object. This can be used for a "dry run". + */ UpdateModeOff = "Off", - // UpdateModeInitial means that autoscaler only assigns resources on pod - // creation and does not change them during the lifetime of the pod. + /** + * UpdateModeInitial means that autoscaler only assigns resources on pod + * creation and does not change them during the lifetime of the pod. + */ UpdateModeInitial = "Initial", - // UpdateModeRecreate means that autoscaler assigns resources on pod - // creation and additionally can update them during the lifetime of the - // pod by deleting and recreating the pod. + /** + * UpdateModeRecreate means that autoscaler assigns resources on pod + * creation and additionally can update them during the lifetime of the + * pod by deleting and recreating the pod. + */ UpdateModeRecreate = "Recreate", - // UpdateModeAuto means that autoscaler assigns resources on pod creation - // and additionally can update them during the lifetime of the pod, - // using any available update method. Currently this is equivalent to - // Recreate, which is the only available update method. + /** + * UpdateModeAuto means that autoscaler assigns resources on pod creation + * and additionally can update them during the lifetime of the pod, + * using any available update method. Currently this is equivalent to + * Recreate, which is the only available update method. + */ UpdateModeAuto = "Auto", } export interface PodUpdatePolicy { diff --git a/packages/core/src/renderer/components/+config-vertical-pod-autoscalers/vpa.tsx b/packages/core/src/renderer/components/+config-vertical-pod-autoscalers/vpa.tsx index f2657cbf50..b2bdb4d249 100644 --- a/packages/core/src/renderer/components/+config-vertical-pod-autoscalers/vpa.tsx +++ b/packages/core/src/renderer/components/+config-vertical-pod-autoscalers/vpa.tsx @@ -8,7 +8,6 @@ import "./vpa.scss"; import React from "react"; import { observer } from "mobx-react"; import { KubeObjectListLayout } from "../kube-object-list-layout"; -// import type { VerticalPodAutoscaler } from "../../../common/k8s-api/endpoints/vertical-pod-autoscaler.api"; import { Badge } from "../badge"; import { cssNames, prevDefault } from "../../utils"; import { KubeObjectStatusIcon } from "../kube-object-status-icon";