【问题标题】:Where are the possible metrics for kubernetes autoscaling definedKubernetes 自动扩展的可能指标在哪里定义
【发布时间】:2019-12-11 07:52:59
【问题描述】:

我正在尝试使用自动缩放场景(目前使用 microk8s 单节点个人集群)。

基本的 CPU 缩放工作正常。

对于更复杂的场景,我正在尝试遵循https://kubernetes.io/docs/tasks/run-application/horizontal-pod-autoscale-walkthrough/#autoscaling-on-multiple-metrics-and-custom-metrics 的指南,但我无法弄清楚可能的 pod 指标/对象指标是如何/在何处定义/记录的。例如,.. "packets-per-second" 记录在哪里。

我可以通过 kubectl 导航或手动执行 REST API,但必须有更好的方法。

谢谢

apiVersion: autoscaling/v2beta1
kind: HorizontalPodAutoscaler
metadata:
  name: php-apache
  namespace: default
spec:
  scaleTargetRef:
    apiVersion: apps/v1
    kind: Deployment
    name: php-apache
  minReplicas: 1
  maxReplicas: 10
  metrics:
  - type: Resource
    resource:
      name: cpu
      target:
        type: AverageUtilization
        averageUtilization: 50
  - type: Pods
    pods:
      metric:
        name: packets-per-second ====> where is this name defined/documented ?
      targetAverageValue: 1k
  - type: Object
    object:
      metric:
        name: requests-per-second ====> where is this name defined/documented ?
      describedObject:
        apiVersion: networking.k8s.io/v1beta1
        kind: Ingress
        name: main-route
      target:
        kind: Value
        value: 10k

【问题讨论】:

标签: kubernetes scalability autoscaling kubernetes-pod


【解决方案1】:

ResourceMetric 中的 CPU 或内存使用情况为 provided by kubelet 并由 metric-server 收集

但是对于packets-per-secondrequests-per-second,没有官方提供者,所以这个字段实际上可以是任何值,取决于你部署的非官方自定义指标API。

https://github.com/kubernetes/metrics/blob/master/IMPLEMENTATIONS.md 列出了一些流行的自定义指标 API

【讨论】:

  • 谢谢..我通过文档发现了同样的情况。确实应该更明确地提及。也许我会尝试改进 k8s 的自动缩放文档部分
【解决方案2】:

下面的 GitHub 项目提供了大量有关使用 Prometheus 提供的自定义指标在 Kubernetes 中自动扩展 Pod 的信息。

https://github.com/stefanprodan/k8s-prom-hpa

【讨论】:

    猜你喜欢
    • 2011-03-21
    • 2021-07-08
    • 2020-10-15
    • 1970-01-01
    • 2016-10-17
    • 1970-01-01
    • 2022-06-14
    • 2020-04-07
    • 2017-12-09
    相关资源
    最近更新 更多