簡體   English   中英

AKS RBAC - 角色綁定無效

[英]AKS RBAC - Rolebinding has no effect

我正在按照此處的說明與 Azure AD 集成的 AKS 群集中設置 RBAC。 我在我的 AAD 租戶中創建了一個 AD 組,向其中添加了一個用戶。 然后,按照說明在 AKS 群集中為該組分配“群集用戶角色”。 創建了一個角色和角色綁定,如下所示:

角色:

apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
  namespace: development
  name: restricted-role
rules:
- apiGroups: [""] 
  resources: ["pods"]
  verbs: ["get", "watch", "list"]

角色綁定:

apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
  name: read-pods
  namespace: development
subjects:
- kind: Group
  name: 308f50cb-e05a-4340-99d4-xxxxxxxb 
  apiGroup: rbac.authorization.k8s.io
  namespace: development
roleRef:
  kind: Role 
  name: restricted-role 
  apiGroup: rbac.authorization.k8s.io

然后我嘗試使用新用戶憑據登錄:

az login --username kubeuser@xxx.onmicrosoft.com --password xxxx

az aks get-credentials --name mycluster --resource-group myrg --overwrite-existing

根據文檔,我應該只被允許在開發命名空間上執行 kubectl get pods。 但是,使用這個新用戶憑據,我發現我可以執行 kubectl get pods --all-namespaces、kubectl get svc --all-namespaces 等操作並查看結果,就好像 Rolebinding 根本沒有任何影響一樣。 我還通過檢查我的集群是否有驗證

“啟用RBAC”:真

有人可以告訴我這個配置有什么問題嗎?

使用命令:

az aks show -g <rg> -n <clusterName> --query aadProfile

您可以確認集群是否啟用了 AAD。 如果啟用,您從以下位置獲得的kubeconfig文件:

az aks get-credentials -g <rg_name> -n <aks_name>

應該看起來像:

user:
  auth-provider:
    config:
      apiserver-id: <appserverid>
      client-id: <clientid>
      environment: AzurePublicCloud
      tenant-id: <tenant>
    name: azure

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM