AKS icon indicating copy to clipboard operation
AKS copied to clipboard

Kubernetes v1.16.7 and kubernetes-dashboard v2.0.0-beta8 ClusterRoleBinding breaking change

Open matthewhartstonge opened this issue 6 years ago • 26 comments

What happened: After upgrading a cluster from Kubernetes v1.15.7 to v1.16.7 I was unable to gain unfettered access to the Kubernetes Dashboard with an admin cluster role binding using:

az aks browse --resource-group my-resource-group --name my-cluster-name

Or kubectl proxy

I noticed the dashboard had been upgraded, and it doesn't seem like it respects the Cluster Role for kubernetes-dashboard anymore. Refer: https://docs.microsoft.com/en-us/azure/aks/kubernetes-dashboard

I also tried using the development cluster role due to [email protected] being beta as documented here, but that didn't resolve the issue either: https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/README.md#admin-privileges

What you expected to happen:

The dashboard still respects the config for Cluster Admin.

How to reproduce it (as minimally and precisely as possible):

  • Add cluster role for kubernetes dashboard as kube-dashboard.rbac.yaml:
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: kubernetes-dashboard
  labels:
    k8s-app: kubernetes-dashboard
roleRef:
  kind: ClusterRole
  apiGroup: rbac.authorization.k8s.io
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: kubernetes-dashboard
  namespace: kube-system
  • run kubectl apply -f kube-dashboard.rbac.yaml
  • Upgrade from 1.15.7 to 1.16.7
  • Run az aks browse --resource-group my-resource-group --name my-cluster-name
  • Get stuck at login page.

image

Anything else we need to know?:

  • The work around is to make a service account and bind that into the dashboard, extract said service token and pass it around all our devs, but that's makes our developers sad.. 😢

Environment:

  • Kubernetes version (use kubectl version):
Client Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.7", GitCommit:"be3d344ed06bff7a4fc60656200a93c74f31f9a4", GitTreeState:"clean", BuildDate:"2020-02-11T19:34:02Z", GoVersion:"go1.13.6", Compiler:"gc", Platform:"windows/amd64"}
Server Version: version.Info{Major:"1", Minor:"16", GitVersion:"v1.16.7", GitCommit:"20c697423de11d4d5d08c6832a513217ca11a6aa", GitTreeState:"clean", BuildDate:"2020-02-21T10:47:45Z", GoVersion:"go1.13.6", Compiler:"gc", Platform:"linux/amd64"}
  • Size of cluster (how many worker nodes are in the cluster?): 3
  • General description of workloads in the cluster: HTTP microservices
  • Others:

Service Account: image

Cluster Role Binding: image

matthewhartstonge avatar Mar 31 '20 00:03 matthewhartstonge

I experience the same issue - and the most interesting thing is, in Kubernetes project, they have already moved the kubernete-dashboard into its own namespace. Now the dashboard that comes with the AKS have all the default configurations (service principals, clusterrolebindings etc.) that points to kubernete-dashboard namespace, which does NOT exist. I even tried to create a kubernete-dashboard namespace upfront to see if AKS would put the correct configurations there - but no, it did not. In my view this is a bug, and AKS team would need to communicate to all the AKS users - are they going to stick to their own way of handling the dashboard in the kube-system namespace in future AKS versions? or are they planning to correct it soon?

mullerlele avatar Apr 02 '20 13:04 mullerlele

We have the same issue, but our cluster does not have RBAC enabled. It occured after upgrading to 1.16.7. Creating ClusterRoleBindings does not help. because do not have RBAC enabled. Are there maybe any other workarounds to this issue?

kahoona77 avatar Apr 23 '20 09:04 kahoona77

I'm also experiencing this issue. Basically, the dashboard is no longer accessible since I upgraded the AKS cluster. I would appreciate either a fix or a workaround to restore the lost access.

nmehlei avatar Apr 28 '20 19:04 nmehlei

Hi, I've upgraded cluster from 1.14.8 to 1.15.10 and then to 1.16.7 recently. After upgrade to 1.16.7 I get this error Error trying to reach service: 'dial tcp 10.220.17.113:8443: connect: connection refused Checked deployment and service yaml configs and everything seems in order.

Just for testing purposes, I've created another cluster with 1.14.8 and upgraded it in the same way and there dashboard worked as expected.

Any suggestions?

@kahoona77 @nmehlei as a workaround I use octant https://github.com/vmware-tanzu/octant

yarko686 avatar May 02 '20 20:05 yarko686

same issue as above after upgrade from 1.15 to 1.16.7

jellebens avatar May 11 '20 08:05 jellebens

same issue too

cosmos0703 avatar May 11 '20 08:05 cosmos0703

Anybody has a workaround for this issue?

MXClyde avatar May 16 '20 09:05 MXClyde

We have the same issue with our staging cluster. We upgraded from 1.15.10 to 1.16.7. Any workaround? Glad we upgraded staging before doing the live cluster.

lilbaek avatar May 18 '20 08:05 lilbaek

As a workaround, and waiting for a solution (if that is possible) because this is the new default option for the Dashboard v2, and because the AKS recreates those "kubernetes-dashboard" objects (if you have the addon enabled), follow these steps:

Create a new ServiceAccount and ClusterRoleBinding linked to the cluster-admin role, but bind it to kube-system namespace:

apiVersion: v1
kind: ServiceAccount
metadata:
  name: admin-user
  namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  name: admin-user
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: cluster-admin
subjects:
- kind: ServiceAccount
  name: admin-user
  namespace: kube-system

Then you can grab your token and put on the login screen.

kubectl -n kube-system describe secret $(kubectl -n kube-system get secret | sls admin-user | ForEach-Object { $_ -Split '\s+' } | Select -First 1)

You can find more info on this k8s link:

https://github.com/kubernetes/dashboard/blob/master/docs/user/access-control/creating-sample-user.md

Another workaround would be to not install the dashboard addon and install the v2 Dashboard yourself on the kubernetes-dashboard namespace.

kubectl apply -f https://raw.githubusercontent.com/kubernetes/dashboard/v2.0.0/aio/deploy/recommended.yaml

Is not a perfect solution because you will have to get the token when it expires and it neither bypasses the login screen but better than nothing...

Hope it helps.

ghost avatar May 19 '20 23:05 ghost

it already creates a user in the dashboard minimal group that u can use

jellebens avatar May 20 '20 08:05 jellebens

@jellebens Yes it does, but it is non usable at all for day to day working basis, since its limited permisions.

ghost avatar May 20 '20 09:05 ghost

I run into the same issue but is this really broken or is it by design?

mvvveen avatar Jun 04 '20 07:06 mvvveen

As far I understand it's by design, a security level issue.

ghost avatar Jun 04 '20 08:06 ghost

Don't think its by design, the az brows command merges the token in your kubeconfig if I understood correctly, but k8s user gets the wrong rights and does not have sufficient rights to do everything, I guess because its a major update, the api's have changed and so the current implementation does not work as intended anymore (there is a lot I assume and I think in there ;))

jellebens avatar Jun 04 '20 12:06 jellebens

Yes that's right @jellebens, the real thing is related to the service account...Currently the "default" service account has not enough permissions, maybe they could link a Role with enough permissions, when you get the credentials via azure cli, but I suppouse that is measure to limit security issues...Even is a good practice like it is mentioned here to limit the dashboard...

https://www.stackrox.com/post/2020/03/azure-kubernetes-aks-security-best-practices-part-4-of-4/

And is a "breaking change" regarding the use of the Dashboard v2.0 vs v1.0 which needs always that login screen, and not regarding a breaking change on the k8s API...

But yeah...is a pain on the a**... ;-)

ghost avatar Jun 04 '20 12:06 ghost

Currently version 2 of the dashboard only supports token login as per the docs:

"Currently, Dashboard only supports logging in with a Bearer Token" - https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/#accessing-the-dashboard-ui

As a note for everyone, I saw mention in the AKS change log that it looks like Azure/AKS are deprecating/deciding to stop supporting/managing the dashboard as an add-on >= k8s 1.18

As a request to the Azure team: can you send AKS service updates via the portal/Azure/AKS, rather than having to discover updates by happening upon the changelog within a github repo for AKS issues?

Even if a link to the AKS changelog was added to the 'upgrade' menu in AKS, that would be a win and to know/display the AKS version the region currently has installed.

matthewhartstonge avatar Jun 04 '20 12:06 matthewhartstonge

a workaround you can use the kube config approach (you can get it by using visual studio code or azure cli) the its located in c:\users<your user>.kube\config

jellebens avatar Jun 07 '20 11:06 jellebens

@jellebens I tried using the Kubeconfig login. But after providing my config file and pressing the Sign-in button, the page doesn't seem to move. I think that's because of what @matthewhartstonge says:

"Currently, Dashboard only supports logging in with a Bearer Token" - https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/#accessing-the-dashboard-ui

So I don't think the Kubeconfig login can work

jochenhebbrecht avatar Jun 15 '20 11:06 jochenhebbrecht

I have similar issue. After upgrading to k8s version 1.16.7 i can see cluster-admins can login and see the dashboards. But when i try to login as a normal user (having permissions over the namespaces), it throws the following error

{ "jweToken": "", "errors": [ { "ErrStatus": { "metadata": {}, "status": "Failure", "message": "MSG_LOGIN_UNAUTHORIZED_ERROR", "reason": "Unauthorized", "code": 401 } } ] }

qaiserali avatar Jul 09 '20 09:07 qaiserali

Action required from @Azure/aks-pm

ghost avatar Aug 08 '20 16:08 ghost