mirror of
https://github.com/lensapp/lens.git
synced 2025-05-20 05:10:56 +00:00
Bump Horizontal Pod Autoscaler apiBase version (#6906)
* Change HPA apiBase and add fallback bases Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Add HPA Behavior types from v2 Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Linter fixes Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> * Fix whitespace differences Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com> Signed-off-by: Alex Andreev <alex.andreev.email@gmail.com>
This commit is contained in:
parent
5ba88b1400
commit
34e6cf263f
@ -72,6 +72,27 @@ export type HorizontalPodAutoscalerMetricSpec =
|
|||||||
| OptionVarient<HpaMetricType.Pods, BaseHorizontalPodAutoscalerMetricSpec, "pods">
|
| OptionVarient<HpaMetricType.Pods, BaseHorizontalPodAutoscalerMetricSpec, "pods">
|
||||||
| OptionVarient<HpaMetricType.ContainerResource, BaseHorizontalPodAutoscalerMetricSpec, "containerResource">;
|
| OptionVarient<HpaMetricType.ContainerResource, BaseHorizontalPodAutoscalerMetricSpec, "containerResource">;
|
||||||
|
|
||||||
|
interface HorizontalPodAutoscalerBehavior {
|
||||||
|
scaleUp?: HPAScalingRules;
|
||||||
|
scaleDown?: HPAScalingRules;
|
||||||
|
}
|
||||||
|
|
||||||
|
interface HPAScalingRules {
|
||||||
|
stabilizationWindowSecond?: number;
|
||||||
|
selectPolicy?: ScalingPolicySelect;
|
||||||
|
policies?: HPAScalingPolicy[];
|
||||||
|
}
|
||||||
|
|
||||||
|
type ScalingPolicySelect = string;
|
||||||
|
|
||||||
|
interface HPAScalingPolicy {
|
||||||
|
type: HPAScalingPolicyType;
|
||||||
|
value: number;
|
||||||
|
periodSeconds: number;
|
||||||
|
}
|
||||||
|
|
||||||
|
type HPAScalingPolicyType = string;
|
||||||
|
|
||||||
export interface ContainerResourceMetricStatus {
|
export interface ContainerResourceMetricStatus {
|
||||||
container: string;
|
container: string;
|
||||||
currentAverageUtilization?: number;
|
currentAverageUtilization?: number;
|
||||||
@ -132,6 +153,7 @@ export interface HorizontalPodAutoscalerSpec {
|
|||||||
minReplicas?: number;
|
minReplicas?: number;
|
||||||
maxReplicas: number;
|
maxReplicas: number;
|
||||||
metrics?: HorizontalPodAutoscalerMetricSpec[];
|
metrics?: HorizontalPodAutoscalerMetricSpec[];
|
||||||
|
behavior?: HorizontalPodAutoscalerBehavior;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface HorizontalPodAutoscalerStatus {
|
export interface HorizontalPodAutoscalerStatus {
|
||||||
@ -153,7 +175,7 @@ export class HorizontalPodAutoscaler extends KubeObject<
|
|||||||
> {
|
> {
|
||||||
static readonly kind = "HorizontalPodAutoscaler";
|
static readonly kind = "HorizontalPodAutoscaler";
|
||||||
static readonly namespaced = true;
|
static readonly namespaced = true;
|
||||||
static readonly apiBase = "/apis/autoscaling/v2beta1/horizontalpodautoscalers";
|
static readonly apiBase = "/apis/autoscaling/v2/horizontalpodautoscalers";
|
||||||
|
|
||||||
getMaxPods() {
|
getMaxPods() {
|
||||||
return this.spec.maxReplicas ?? 0;
|
return this.spec.maxReplicas ?? 0;
|
||||||
@ -204,8 +226,15 @@ export class HorizontalPodAutoscaler extends KubeObject<
|
|||||||
export class HorizontalPodAutoscalerApi extends KubeApi<HorizontalPodAutoscaler> {
|
export class HorizontalPodAutoscalerApi extends KubeApi<HorizontalPodAutoscaler> {
|
||||||
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
|
constructor(deps: KubeApiDependencies, opts?: DerivedKubeApiOptions) {
|
||||||
super(deps, {
|
super(deps, {
|
||||||
objectConstructor: HorizontalPodAutoscaler,
|
|
||||||
...opts ?? {},
|
...opts ?? {},
|
||||||
|
objectConstructor: HorizontalPodAutoscaler,
|
||||||
|
checkPreferredVersion: true,
|
||||||
|
// Kubernetes < 1.26
|
||||||
|
fallbackApiBases: [
|
||||||
|
"/apis/autoscaling/v2beta2/horizontalpodautoscalers",
|
||||||
|
"/apis/autoscaling/v2beta1/horizontalpodautoscalers",
|
||||||
|
"/apis/autoscaling/v1/horizontalpodautoscalers",
|
||||||
|
],
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user