gpt4 book ai didi

azure - 事件中心触发在带有 KEDA 的 AKS 上运行的 Azure Function 无法横向扩展

转载 作者:行者123 更新时间:2023-12-02 07:53:04 29 4
gpt4 key购买 nike

我已在 AKS 上部署了用 Java 编写的事件中心触发的 Azure 函数。该功能应使用 KEDA 进行扩展。该功能已正确触发并工作,但当负载增加时它不会扩展。我在函数实现中添加了 sleep 调用,以确保它不会过快地消耗事件,并​​且应该强制扩展,但这也没有显示任何变化。

kubectl get hpa 显示以下输出

NAME                   REFERENCE                TARGETS       MINPODS   MAXPODS   REPLICAS   AGE
keda-hpa-eventlogger Deployment/eventlogger 64/64 (avg) 1 20 1 3m41s

这似乎是第一个表明某些内容不正确的指标,因为我假设目标列中的第一个数字是事件中心中未处理事件的数量。无论我向集线器注入(inject)多少事件,这都保持不变。

该函数是使用以下 Kubernetes 部署 list 部署的

data:
AzureWebJobsStorage: <removed>
FUNCTIONS_WORKER_RUNTIME: amF2YQ==
EventHubConnectionString: <removed>
apiVersion: v1
kind: Secret
metadata:
name: eventlogger
---

apiVersion: apps/v1
kind: Deployment
metadata:
name: eventlogger
labels:
app: eventlogger
spec:
selector:
matchLabels:
app: eventlogger
template:
metadata:
labels:
app: eventlogger
spec:
containers:
- name: eventlogger
image: <removed>
env:
- name: AzureFunctionsJobHost__functions__0
value: eventloggerHandler
envFrom:
- secretRef:
name: eventlogger
readinessProbe:
failureThreshold: 3
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 240
httpGet:
path: /
port: 80
scheme: HTTP
startupProbe:
failureThreshold: 3
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 240
httpGet:
path: /
port: 80
scheme: HTTP
---
apiVersion: keda.sh/v1alpha1
kind: ScaledObject
metadata:
name: eventlogger
labels:
app: eventlogger
spec:
scaleTargetRef:
name: eventlogger
pollingInterval: 5
cooldownPeriod: 5
minReplicaCount: 0
maxReplicaCount: 20
triggers:
- type: azure-eventhub
metadata:
storageConnectionFromEnv: AzureWebJobsStorage
connectionFromEnv: EventHubConnectionString
---

事件中心的连接字符串包含“EntityPath=”部分,如 KEDA Event Hub Scaler Documentation 中所述。并拥有事件中心命名空间的管理权限。

kubectl描述ScaledObject的输出是

Name:         eventlogger
Namespace: default
Labels: app=eventlogger
scaledobject.keda.sh/name=eventlogger
Annotations: <none>
API Version: keda.sh/v1alpha1
Kind: ScaledObject
Metadata:
Creation Timestamp: 2022-04-17T10:30:36Z
Finalizers:
finalizer.keda.sh
Generation: 1
Managed Fields:
API Version: keda.sh/v1alpha1
Fields Type: FieldsV1
fieldsV1:
f:metadata:
f:annotations:
.:
f:kubectl.kubernetes.io/last-applied-configuration:
f:labels:
.:
f:app:
f:spec:
.:
f:cooldownPeriod:
f:maxReplicaCount:
f:minReplicaCount:
f:pollingInterval:
f:scaleTargetRef:
.:
f:name:
f:triggers:
Manager: kubectl-client-side-apply
Operation: Update
Time: 2022-04-17T10:30:36Z
API Version: keda.sh/v1alpha1
Fields Type: FieldsV1
fieldsV1:
f:metadata:
f:finalizers:
.:
v:"finalizer.keda.sh":
f:labels:
f:scaledobject.keda.sh/name:
f:status:
.:
f:conditions:
f:externalMetricNames:
f:lastActiveTime:
f:originalReplicaCount:
f:scaleTargetGVKR:
.:
f:group:
f:kind:
f:resource:
f:version:
f:scaleTargetKind:
Manager: keda
Operation: Update
Time: 2022-04-17T10:30:37Z
Resource Version: 1775052
UID: 3b6a68c1-c3b9-4cdf-b5d5-41a9721ac661
Spec:
Cooldown Period: 5
Max Replica Count: 20
Min Replica Count: 0
Polling Interval: 5
Scale Target Ref:
Name: eventlogger
Triggers:
Metadata:
Connection From Env: EventHubConnectionString
Storage Connection From Env: AzureWebJobsStorage
Type: azure-eventhub
Status:
Conditions:
Message: ScaledObject is defined correctly and is ready for scaling
Reason: ScaledObjectReady
Status: False
Type: Ready
Message: Scaling is performed because triggers are active
Reason: ScalerActive
Status: True
Type: Active
Status: Unknown
Type: Fallback
External Metric Names:
s0-azure-eventhub-$Default
Last Active Time: 2022-04-17T10:30:47Z
Original Replica Count: 1
Scale Target GVKR:
Group: apps
Kind: Deployment
Resource: deployments
Version: v1
Scale Target Kind: apps/v1.Deployment
Events:
Type Reason Age From Message
---- ------ ---- ---- -------
Normal KEDAScalersStarted 10s keda-operator Started scalers watch
Normal ScaledObjectReady 10s keda-operator ScaledObject is ready for scaling

所以我有点困惑,因为我没有看到任何错误,但它仍然没有按预期运行。

版本:

最佳答案

能够找到问题的解决方案。

事件中心触发的 AKS 上部署的 Azure Functions 显示与应用服务上的 Azure Functions 显示的相同的缩放特征:

每个分区只能有一个消费者才能进行每个分区的排序。此特征优先于 Kubernetes 部署 list 中的 maxReplicaCount。

因此,为了解决我自己的问题:通过增加事件中心的分区,我为每个分区获得一个 Pod,并且 KEDA 按预期扩展工作负载。

关于azure - 事件中心触发在带有 KEDA 的 AKS 上运行的 Azure Function 无法横向扩展,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/71901186/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com