Skip to content

RBAC AAD access error. You must be logged in to the server (Unauthorized). AKS 1.10.3 #478

@MarkTopping

Description

@MarkTopping

After significant hours invested in trying, I'm unable to access cluster resources under my AAD account (thus as a non-admin user) when RBAC is enabled.

I've followed & re-followed the steps to create a cluster with RBAC / AAD as found here: https://github.com/Azure/acs-engine/blob/master/docs/kubernetes/aad.md

The only different path I took is I wanted to create my cluster using the Resource Templates rather than via the Azure CLI. Thus I used the "2018-03-31" template and set enableRBAC=true and provided a AADProfile section nested within properties: {...}. My cluster was created successfully with the template - using Kubernetes version 1.10.3.

Now as it stands, when I connect to my cluster (as non-admin) then I am requested to authenticate at https://microsoft.com/devicelogin and upon doing so the website confirms I have authenticated with my AAD Client (as setup as a native App Registration in my Azure AD).

However, once my cli updates itself, I'm presented with the message: "You must be logged in to the server (Unauthorized)".

It might be of interest to note that while logged in as admin, if I try kubectl get pods --as=MyUserName then the command works. And If I run kubectl auth can-i get pods --as=myUserName then it responds with a 'yes'. These repsonses very much contradict what I witness when I actually try to interact with my cluster under my own credentials.

FYI I've tried created cluster role bindings for both AAD Groups and just for a single user with the same outcome. An example binding I've applied is:

apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: sorted-react-nonprod-admins
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- apiGroup: rbac.authorization.k8s.io
  kind: User
  name: "myUserName"

I've tried both username and e-mail in the name field. Along with AD Group names with 'kind' set to 'Group'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions