问题描述
apiVersion: autoscaling/v2beta2
kind: HorizontalPodAutoscaler
Metadata:
name: test
spec:
behavior:
scaleDown:
stabilizationWindowSeconds: 0
policies:
- type: Percent
value: 10
periodSeconds: 15
scaleUp:
stabilizationWindowSeconds: 0
policies:
#-type: Percent
#value: 100
#periodSeconds: 15
- type: Pods
value: 5
periodSeconds: 15
maxReplicas: 30
minReplicas: 2
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: test
metrics:
- type: Resource
resource:
name: cpu
target:
type: utilization
averageutilization: 50
根据Kubernetes官方文档,HPA行为可用于Kubernetes v1.18版,但GKE具有自己的版本控制。还具有api版本“ autoscaling / v2beta2”,但不支持该行为。
GKE版本: 1.16.13-gke.1
我是唯一遇到此问题的人吗?
解决方法
是的,您是正确的。 GKE拥有自己的版本控制。您可以找到更多详细信息here。
注意:Kubernetes API与Kubernetes本身是分开版本的。有关Kubernetes API版本控制的信息,请参阅Kubernetes API文档。
不幸的是,GKE不支持behavior
中的apiVersion: autoscaling/v2beta2
参数。
error: error validating "hpa.yaml": error validating data: ValidationError(HorizontalPodAutoscaler.spec): unknown field "behavior" in io.k8s.api.autoscaling.v2beta2.HorizontalPodAutoscalerSpec; if you choose to ignore these errors,turn validation off with --validate=false
但是,它可以免费与Kubernetes 1.18+一起在Kubeadm和Minikube中使用。
已经有一个与此问题相关的Public Issue Tracker。您可以在此PIT
中将自己添加到抄送中,以获取与此问题相关的新更新。
如果您使用的是GKE,并且遇到启用API的问题
autoscaling/v1
autoscaling/v2beta1
当GKE版本在1.12 to 1.14
左右时,您将无法应用autoscaling/v2beta2
的清单,但是您可以应用类似的东西
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: core-deployment
namespace: default
spec:
maxReplicas: 9
minReplicas: 5
scaleTargetRef:
apiVersion: extensions/v1beta1
kind: Deployment
name: core-deployment
metrics:
- type: Resource
resource:
name: cpu
targetAverageValue: 500m
如果您希望基于利用率
apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
name: core-deployment
namespace: default
spec:
maxReplicas: 9
minReplicas: 5
scaleTargetRef:
apiVersion: extensions/v1beta1
kind: Deployment
name: core-deployment
metrics:
- type: Resource
resource:
name: cpu
targetAverageUtilization: 80