gpt4 book ai didi

azure - Terraform Azure AKS - 如何将 UAMI 设置为 AKS 集群的 kubelet_identity

转载 作者:行者123 更新时间:2023-12-02 06:05:07 26 4
gpt4 key购买 nike

查看地形 documentation我无法确定如何将 UAMI 分配为 kubelet_identity对于aks集群。

identity { ... }按照描述设置 controlPlane UAMI 的 block here不是我要找的。

问题是 - 除了 identity {..} 中的 UAMI 之外,是否有一种 terraform 方式可以分配额外的 UAMI阻止并使用它来访问 ACR?

我想设置一个单独的 UAMI 作为 kubelet 身份,如 here 中所述

最佳答案

is there a terraform way I can assign additional UAMI apart from theone in identity {..} block and use it to access ACR?

根据您提供的详细信息,您可以创建一个额外的 UAMI 并将其与 AKS 集群 kubelet 身份关联,然后将角色分配给 UAMI,示例代码如下:资源“azurerm_kubernetes_cluster”“示例”{名称 =“示例-aks1”位置 = azurerm_resource_group.example.location资源组名称 = azurerm_resource_group.example.namedns_prefix =“exampleaks1”

  default_node_pool {
name = "default"
node_count = 1
vm_size = "Standard_D2_v2"
}

identity {
type = "SystemAssigned"
}

kubelet_identity {
client-id = azurerm_user_assigned_identity.kubelet.client_id
object-id = azurerm_user_assigned_identity.kubelet.principal_id
user_assigned_identity_id = azurerm_user_assigned_identity.kubelet.id
}
...
}

resource "azurerm_role_assignment" "acr_for_kubelet" {
principal_id = azurerm_user_assigned_identity.kubelet.client_id
scope = azurerm_container_registry.container_registry.id
role_definition_name = "AcrPull"
}

更新:

实际上,当您创建 AKS 并启用系统分配的托管标识时,它将为 AKS 集群创建两个用户分配的标识,一个用于访问其他资源,一个用于管理 AKS 集群本身这就是 kubelet 身份。

分配 kubelet 身份权限来访问 ACR 是没有意义的。您需要做的是分配 AKS 身份权限以访问 ACR。或者使用 Kubernetes 内部的 key 和服务帐户来访问 ACR。

关于azure - Terraform Azure AKS - 如何将 UAMI 设置为 AKS 集群的 kubelet_identity,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/67676483/

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