![](/img/trans.png)
[英]Add RBAC to Azure Kubernetes ( AKS ) after the cluster has already been created
[英]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.