简体   繁体   English

kubernetes 在 queue_size 上自动缩放与运行的 pod 数量

[英]kubernetes autoscale on queue_size versus number of pods running

Is there a way I can set up autoscaling with a complete customized algorithm?有没有办法可以使用完整的自定义算法设置自动缩放?
1. I would like to autoscale my pods based on the ratio of (size of the azure storage queue) to (number of pods currently running) which means the average number of messages every pod needs to handle. 1. 我想根据(azure 存储队列的大小)与(当前运行的 pod 数量)的比率自动缩放我的 pod,这意味着每个 pod 需要处理的平均消息数。
2. Can I create metrics and scale based on the metrics freely? 2. 我可以自由地创建指标和基于指标的规模吗? Like喜欢

if 2 > metrics > 1:
     scale pods to 2
if 5 > metrics > 2:
     scale pods to 3
if 10 > metrics > 5:
     scale pods to 4

if so, where can I set up the autoscale algorithm?如果是这样,我在哪里可以设置自动缩放算法?

You can use keda with the corresponding trigger for that:您可以将 keda 与相应的触发器一起使用:

https://keda.sh/docs/1.4/scalers/azure-storage-queue/ https://keda.sh/docs/1.4/scalers/azure-storage-queue/

Here is an example from the docs for azure storage queue.这是 azure 存储队列的文档中的示例。

 apiVersion: keda.k8s.io/v1alpha1
kind: TriggerAuthentication
metadata:
  name: azure-queue-auth
spec:
  podIdentity:
    provider: azure
---
apiVersion: keda.k8s.io/v1alpha1
kind: ScaledObject
metadata:
  name: azure-queue-scaledobject
  namespace: default
spec:
  scaleTargetRef:
    deploymentName: azurequeue-function
  triggers:
  - type: azure-queue
    metadata:
      # Required
      queueName: functionsqueue
      # Required: connection OR authenticationRef that defines connection
      connection: STORAGE_CONNECTIONSTRING_ENV_NAME # Default: AzureWebJobsStorage. Reference to a connection string in deployment
      # or authenticationRef as defined below
      #
      # Optional
      queueLength: "5" # default 5
    authenticationRef:
        name: azure-queue-auth # 

All kinds of other triggers are supported as well.还支持各种其他触发器。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM