Skip to content

指标

指标配置定义由Autoscaler监视的度量类型。

设置每个修订的指标

对于每修订配置,这是使用autoscaling.knative.dev/metric注释确定的。 可以在每个版本中配置的可能的度量类型取决于您正在使用的Autoscaler实现的类型:

  • 默认的KPA Autoscaler支持concurrencyrps指标。
  • HPA Autoscaler 支持 cpu 指标。

有关KPA和HPA的更多信息,请参阅关于支持的自动缩放器类型的文档。

  • 每修订注释键: autoscaling.knative.dev/metric
  • 可能值: "concurrency", "rps", "cpu", "memory" 或任何自定义指标名称,这取决于您的Autoscaler类型. "cpu", "memory""custom"指标仅在使用HPA类的版本中支持。
  • 默认: "concurrency"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: helloworld-go
  namespace: default
spec:
  template:
    metadata:
      annotations:
        autoscaling.knative.dev/metric: "concurrency"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: helloworld-go
  namespace: default
spec:
  template:
    metadata:
      annotations:
        autoscaling.knative.dev/metric: "rps"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: helloworld-go
  namespace: default
spec:
  template:
    metadata:
      annotations:
        autoscaling.knative.dev/class: "hpa.autoscaling.knative.dev"
        autoscaling.knative.dev/metric: "cpu"
apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: helloworld-go
  namespace: default
spec:
  template:
    metadata:
      annotations:
        autoscaling.knative.dev/class: "hpa.autoscaling.knative.dev"
        autoscaling.knative.dev/metric: "memory"

您可以创建一个HPA,以根据您指定的指标来扩展修订。 HPA将被配置为在修订的所有Pods中使用度量的平均值

apiVersion: serving.knative.dev/v1
kind: Service
metadata:
  name: helloworld-go
  namespace: default
spec:
  template:
    metadata:
      annotations:
        autoscaling.knative.dev/class: "hpa.autoscaling.knative.dev"
        autoscaling.knative.dev/metric: "<metric-name>"

Where <metric-name> is your custom metric.

下一个步骤

Back to top

We use analytics and cookies to understand site traffic. Information about your use of our site is shared with Google for that purpose. Learn more.

× OK