本文介绍了Kubernetes未知字段的“行为"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在Kubernetes中创建一个Horizo​​ntalPodAutoscaler,我需要将缩小的稳定化窗口配置为小于默认值.使用的代码和错误如下:

I'm creating a HorizontalPodAutoscaler in Kubernetes and I need to configure the downscale stabilization window to be smaller than the default. The code used and error are below:

apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
metadata:
    name: busy-autoscaler
spec:
    behavior:
        scaleDown:
            stabilizationWindowSeconds: 10
    scaleTargetRef:
        apiVersion: apps/v1
        kind: Deployment
        name: busy-worker
    minReplicas: 1
    maxReplicas: 2
    metrics:
        - type: Resource
          resource:
              name: cpu
              target:
                  type: Utilization
                  averageUtilization: 50
$ kubectl create -f some-autoscale.yaml
error validating "some-autoscale.yaml": error validating data: ValidationError(HorizontalPodAutoscaler.spec): unknown field "behavior" in io.k8s.api.autoscaling.v2beta2.HorizontalPodAutoscalerSpec

我的理解是,如文档.运行kubectl version会给出以下输出:

My understanding is that the behavior field should be supported from Kubernetes 1.17 as stated in the docs. Running kubectl version gives the following output:

Client Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.1", GitCommit:"d224476cd0730baca2b6e357d144171ed74192d6", GitTreeState:"clean", BuildDate:"2020-01-14T21:04:32Z", GoVersion:"go1.13.5", Compiler:"gc", Platform:"linux/amd64"}
Server Version: version.Info{Major:"1", Minor:"17", GitVersion:"v1.17.0", GitCommit:"70132b0f130acc0bed193d9ba59dd186f0e634cf", GitTreeState:"clean", BuildDate:"2019-12-07T21:12:17Z", GoVersion:"go1.13.4", Compiler:"gc", Platform:"linux/amd64"}

API参考没有v2beta2behavior字段,这会使情况更加混乱.

The API reference doesn't have the behavior field for v2beta2 which makes this more confusing.

我在本地运行Minikube 1.6.2.我在做什么错了?

I'm running Minikube 1.6.2 locally. What am I doing wrong?

推荐答案

因此,这似乎是一种错误文档的情况,在我提出问题后不久,该文档便得到了纠正. kubernetes/website上的 PR#18157 将以下文本添加到 Horizo​​ntal Pod自动缩放器.

So it looks like this was a case of incorrect documentation that was corrected shortly after I asked my question. PR #18157 on kubernetes/website adds the following text to the page on the Horizontal Pod Autoscaler.

PR#18965 由于behavior对象是功能定位于1.18,而不是1.17.

PR #18965 reverts the previous pull request since the behavior object is functionality targeted in 1.18, not 1.17.

目前,解决方案是使用控制器管理器上的--horizontal-pod-autoscaler-downscale-stabilization标志,如上面@ShantyMan的答案中所述,它将为每个HPA设置值.

For now, the solution is to use the --horizontal-pod-autoscaler-downscale-stabilization flag on the controller manager as mentioned in @ShantyMan's answer above which will set the value for every HPA.

这篇关于Kubernetes未知字段的“行为"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-24 21:59