我正在尝试使用 Event-Hub KEDA 缩放器为 Azure 容器应用程序设置自动缩放。应用程序需要使用用户管理的标识向 Azure 事件中心进行身份验证。我知道 KEDA 为此目的支持 Azure 工作负载身份,但我在正确配置它时遇到了困难,尤其是扩展规则中工作负载身份的 IdentityId。
根据我的研究和现有文档(例如 KEDA 文档、Azure 示例),我发现 Azure 支持此类场景的 Pod 身份和工作负载身份,但 Azure 容器应用程序的详细示例很少。
这是我的二头肌模板的片段,我试图在其中设置缩放规则:
resource app 'Microsoft.App/containerApps@2022-03-01' = {
identity: {
type: 'UserAssigned'
userAssignedIdentities: {
'${managedIdentity.id}': {}
}
}
properties: {
// Omitted for brevity...
template: {
// Omitted for brevity...
scale: {
rules: [
{
name: 'eh-keda-scale',
custom: {
type: 'azure-eventhub'
metadata: {
consumerGroup: containerAppName,
unprocessedEventThreshold: '64',
// Possibly needed according to the Keda event-hub docs?
eventHubNamespace: eventHubNamespace,
eventHubName: eventHubName,
// Attempt to configure workload identity
// Unsure how to properly specify `identityId` here
},
auth: [
{
secretRef: 'clientIdentitySecret',
triggerParameter: 'identityId'
// How should `identityId` be configured for workload identity?
}
]
}
}
]
}
}
}
}
这是我使用过的参考。
https://github.com/kedacore/sample-dotnet-worker-servicebus-queue/?tab=readme-ov-file https://keda.sh/docs/2.13/scalers/azure-event-hub/
不幸的是,文档并不清楚如何配置工作负载身份,特别是如何以及在何处配置identityId。这里有一些线索:
但是对于 Pod 或工作负载身份没有任何具体内容。资源类型的二头肌参考是:
显然在撰写本文时尚不支持此功能。
不支持在规模规则中使用托管身份。你还是会 需要在secretRef中包含连接字符串或密钥 缩放规则。
我将通过获取事件中心中的分区数量并将最小和最大副本扩展到此来解决这个问题。