az aks browse kubernetes dashboard doesn't work anymore
What happened: after creating aks service i get the following errors when using the kubernetes dashboard (az aks browse --name xxx --resource-group xxx). This happens with version 1.11.1. Last time this worked was version 1.9.6)
warning configmaps is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list configmaps in the namespace "default" close warning persistentvolumeclaims is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list persistentvolumeclaims in the namespace "default" close warning secrets is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list secrets in the namespace "default" close warning services is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list services in the namespace "default" close warning ingresses.extensions is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list ingresses.extensions in the namespace "default" close warning daemonsets.apps is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list daemonsets.apps in the namespace "default" close warning pods is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list pods in the namespace "default" close warning events is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list events in the namespace "default" close warning deployments.apps is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list deployments.apps in the namespace "default" close warning replicasets.apps is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list replicasets.apps in the namespace "default" close warning jobs.batch is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list jobs.batch in the namespace "default" close warning cronjobs.batch is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list cronjobs.batch in the namespace "default" close warning replicationcontrollers is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list replicationcontrollers in the namespace "default" close warning statefulsets.apps is forbidden: User "system:serviceaccount:kube-system:kubernetes-dashboard" cannot list statefulsets.apps in the namespace "default"
What you expected to happen: an kubernetes interface without errors
How to reproduce it (as minimally and precisely as possible): in ubuntu 18.04 (also seen this issue on mac) azure-cli (2.0.43). Create kubernetes service: az aks create --resource-group xxx --name xxx --node-count 3 --generate-ssh-keys --kubernetes-version 1.11.1 Then use kubernetes dashboard: az aks browse --name xxx --resource-group xxx and see the errors.
Anything else we need to know?:
Environment:
-
Kubernetes version (use
kubectl version): Client Version: version.Info{Major:"1", Minor:"10", GitVersion:"v1.10.4", GitCommit:"5ca598b4ba5abb89bb773071ce452e33fb66339d", GitTreeState:"clean", BuildDate:"2018-06-06T08:13:03Z", GoVersion:"go1.9.3", Compiler:"gc", Platform:"linux/amd64"} Server Version: version.Info{Major:"1", Minor:"11", GitVersion:"v1.11.1", GitCommit:"b1b29978270dc22fecc592ac55d903350454310a", GitTreeState:"clean", BuildDate:"2018-07-17T18:43:26Z", GoVersion:"go1.10.3", Compiler:"gc", Platform:"linux/amd64"} -
Size of cluster (how many worker nodes are in the cluster?): 3
-
General description of workloads in the cluster (e.g. HTTP microservices, Java app, Ruby on Rails, machine learning, etc.) : Just testing the kubernetes dashboard.
-
Others:
Rbac is enabled by default now. You have to create a dashboard user and use it to login. (You have to browse to /login manually too).
Just an example one I use....
kubectl apply this
apiVersion: v1
kind: ServiceAccount
metadata:
name: aks-dashboard-admin
namespace: kube-system
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: aks-dashboard-admin
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: aks-dashboard-admin
namespace: kube-system
Then in powershell to get the token for login.
$data = kubectl get secret --namespace=kube-system $(kubectl get serviceaccount --namespace=kube-system aks-dashboard-admin -o jsonpath="{.secrets[0].name}") -o jsonpath="{.data.token}"
[System.Text.Encoding]::ASCII.GetString([System.Convert]::FromBase64String($data))
Then you go to http://127.0.0.1:8001/#!/login manually once you start az browse and paste in the token.
Instructions are here. We are working on adding this to the formal documentation.
cc: @sauryadas @iainfoulds
Updated documentation is available here: https://docs.microsoft.com/en-us/azure/aks/kubernetes-dashboard
If you aren't keen on doling out cluster-admin, create your own clusterrole, or use the view clusterrole; this allows dashboard users to view every resource except for secrets and cluster-wide resources (nodes, PVCs, roles), and prevents changes via the dashboard.
The cluster role binding manifest for view:
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: kubernetes-dashboard-viewer
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: view
subjects:
- kind: ServiceAccount
name: kubernetes-dashboard
namespace: kube-system
I faced same issue. You need to run this command kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard
@sshakhtour i have it already running but still can't see the issue.
vagrant@k8s-master:~$ kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard
Error from server (AlreadyExists): clusterrolebindings.rbac.authorization.k8s.io "kubernetes-dashboard" already exists
vagrant@k8s-master:~$
You have an idea about what should i do?
I run into this as well
i simply had to delete the ClusterRoleBinding:
kubectl delete ClusterRoleBinding kubernetes-dashboard
and then I recreated it
kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard
I run into this as well i simply had to delete the ClusterRoleBinding:
kubectl delete ClusterRoleBinding kubernetes-dashboardand then I recreated it
kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard
Thanks a lot! It worked for me
kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard
This command is worked for me. After this we should browse aks again to connect.
Getting the same error, "Already exists".
Commands did not work for me. Still getting many dashboard errors.