大网数据广告活动
服务器运维问答

How to enable autoscaling/v2beta2 in google cloud

· 52CE 我爱测

While following the tutorial found here I saw that I need autoscaling/v2beta2 for having custom metrics for the Horizontal Pod Autoscaler, but don't know how to enable it. Environment details: Google Cloud platform Kubernetes ver…

问题原文

原帖链接 · claudiu.decean · CC BY-SA 4.0

While following the tutorial found here I saw that I need autoscaling/v2beta2 for having custom metrics for the Horizontal Pod Autoscaler, but don't know how to enable it.

Environment details:

  • Google Cloud platform
  • Kubernetes version 1.13.7-gke.8 (latest)

What did I try:

  • Using "kubectl api-versions", I checked what API groups I have enable for autoscaling and have only the following: autoscaling/v1 autoscaling/v2beta1

  • I found the following documentation that says "Certain resources and API groups are enabled by default. They can be enabled or disabled by setting --runtime-config on apiserver. --runtime-config accepts comma separated values.". Taking a look at the kube-apiserver command documentation , I could find a way to use this command for gcloud

已采纳解答

原帖链接 · Harsh Manvar · CC BY-SA 4.0

if you are on GKE and facing issue where enabled API are

autoscaling/v1
autoscaling/v2beta1

while GKE version is around 1.12 to 1.14 you wont be able to apply manifest of autoscaling/v2beta2 however you can apply same thing something like

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

if you want based on utilization

    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

摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。

资料来源与适用范围

资料来源
Server Fault
适用范围
以原帖系统、软件版本与发布日期为准(2019-08-07)
内容语言
中文;命令、路径和错误标识保留技术原文
本地收录日期
2026-11-15
授权说明
CC BY-SA 4.0

正文与所需资源由本站本地存储。查看来源及更新记录 ↗

请按适用版本和实际日志确认原因;本站没有对每一种系统或设备逐项执行文中的操作。