【问题标题】:Kubernetes scaling based on network utilization or requests per second基于网络利用率或每秒请求数的 Kubernetes 扩展
【发布时间】:2018-07-20 08:38:37
【问题描述】:

有没有办法根据网络利用率而不是基于内存或 CPU 来扩展 Kubernetes 节点?

假设您正在向负载均衡器后面的几个节点发送数千个请求。 CPU 没有挣扎,也没有内存,但因为每秒有数千个请求,您需要额外的节点来提供服务。您如何在 Google Cloud Kubernetes 中做到这一点?

我一直在研究,但似乎找不到任何关于这种缩放的参考,我猜我不是唯一遇到这个问题的人。所以我想知道你们中是否有人知道任何最佳实践解决方案。

我想理想的解决方案是让每个节点有一个 pod 接收请求,并根据更多请求创建更多节点,并以此为基础扩大或缩小规模。

【问题讨论】:

  • 不依赖K8S,根据网络流量指标运行kubectl scale?
  • Horizo​​ntal Pod Autoscaler 支持custom metrics。我无法给出更详细的答案,因为我从未使用过它。
  • 集群自动缩放器基于POD allocation。我相信@svenwltr 指向了正确的方向。根据this discussion,不支持基于 HTTP 负载的自动缩放。 Horizo​​ntal Pod autoscaler 和 custom metrics 似乎是最好的方法。

标签: docker kubernetes google-cloud-platform autoscaling


【解决方案1】:

这是可能的,您必须使用 Prometheus Adaptor 来配置自定义规则以生成 Custom Metrics

link 提供了有关如何设置 prometheus、安装适配器以及使用自定义指标应用配置的更多详细信息。

【讨论】:

    【解决方案2】:

    我已经使用 this 自定义指标在我的 gke 集群上实现了这一点。

    这是我的 HPA 配置示例:

    apiVersion: autoscaling/v2beta2
    kind: HorizontalPodAutoscaler
    metadata:
      name: hpa-name
      namespace: your-namespace
      annotations:
        metric-config.external.prometheus-query.prometheus/interval: 30s
        metric-config.external.prometheus-query.prometheus/prometheus-server: http://your-prometheus-server-ip
        metric-config.external.prometheus-query.prometheus/istio-requests-total: |
          sum(rate(istio_requests_total{reporter="destination", destination_workload="deployment-name", destination_service_namespace="your-namespace"}[2m]))
    spec:
      scaleTargetRef:
        apiVersion: apps/v1
        kind: Deployment
        name: deployment-name
      minReplicas: 1
      maxReplicas: 10
      metrics:
      - type: External
        external:
          metric:
            name: prometheus-query
            selector:
              matchLabels:
                query-name: istio-requests-total
          target:
            type: AverageValue
            averageValue: 7
    

    【讨论】:

      【解决方案3】:

      我认为 HPA(Horizo​​ntal Pod Autoscaler) 和 Cluster Autoscaler 会发挥作用。

      看看这个 - https://medium.com/google-cloud/kubernetes-autoscaling-with-istio-metrics-76442253a45a

      【讨论】:

        猜你喜欢
        • 2018-05-17
        • 2018-08-02
        • 1970-01-01
        • 2019-08-21
        • 1970-01-01
        • 2020-04-10
        • 2012-01-17
        • 2018-11-03
        • 1970-01-01
        相关资源
        最近更新 更多