Dashboard permission errors from `kubectl proxy` on K8s 1.10.3 cluster deployed from acs-engine master
Is this an ISSUE or FEATURE REQUEST?
Issue
What version of acs-engine?
Version: canary GitCommit: a1fe789 GitTreeState: dirty
(I had one change to the Makefile so that make dev works on my system with a strange net config)
Orchestrator and version (e.g. Kubernetes, DC/OS, Swarm) Kubernetes
What happened:
The dashboard at http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/overview?namespace=default doesn't seem to have any permissions for the service account it's running as.
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:
Dashboard should work, be able to show nodes, pods, and so on
How to reproduce it (as minimally and precisely as possible):
- Create a JSON file with
"orchestratorProfile": {
"orchestratorType": "Kubernetes",
"orchestratorVersion": "1.10.3"
},
-
acs-engine generate, deploy it -
Copy .kube/config from master node
-
kubectl proxy -
browse to http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/overview?namespace=default
Hmm, the role only seems to have access to heapster
$ kubectl -n kube-system describe rolebinding kubernetes-dashboard-minimal
Name: kubernetes-dashboard-minimal
Labels: addonmanager.kubernetes.io/mode=Reconcile
k8s-app=kubernetes-dashboard
kubernetes.io/cluster-service=true
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"rbac.authorization.k8s.io/v1","kind":"Role
Binding","metadata":{"annotations":{},"labels":{"addonmanager.kubernetes.io/mode":"Reconcile",...
Role:
Kind: Role
Name: kubernetes-dashboard-minimal
Subjects:
Kind Name Namespace
---- ---- ---------
ServiceAccount kubernetes-dashboard kube-system
$ kubectl -n kube-system describe role kubernetes-dashboard-minimal
Name: kubernetes-dashboard-minimal
Labels: addonmanager.kubernetes.io/mode=Reconcile
k8s-app=kubernetes-dashboard
kubernetes.io/cluster-service=true
Annotations: kubectl.kubernetes.io/last-applied-configuration={"apiVersion":"rbac.authorization.k8s.io/v1","kind":"Role
","metadata":{"annotations":{},"labels":{"addonmanager.kubernetes.io/mode":"Reconcile","k8s-ap...
PolicyRule:
Resources Non-Resource URLs Resource Names Verbs
--------- ----------------- -------------- -----
configmaps [] [] [create]
configmaps [] [kubernetes-dashboard-settings] [get update]
secrets [] [] [create]
secrets [] [kubernetes-dashboard-key-holder] [get update delete]
services [] [heapster] [proxy]
services/proxy [] [heapster] [get]
services/proxy [] [http:heapster:] [get]
services/proxy [] [https:heapster:] [get]
Applying the binding described at https://github.com/kubernetes/dashboard/wiki/Access-control#admin-privileges fixed it
Looks like #2816 added RBAC for k8s 1.8+
The config for 1.7, 1.8 adds a ClusterRoleBinding of cluster-admin to Kubernetes-dashboard. The non-versioned one used for 1.9+ does not bind cluster-admin, instead Kubernetes-dashboard-minimal.
This is so broken...
https://blogs.msdn.microsoft.com/kennethteo/2018/07/26/aks-with-aad/ hmm this shows a binding based on an AAD user. might work with acs-engine
Run kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard Everything worked for me.
Alright - I did a lot more reading here. It seems that creating a service account and using a token is the right thing to do: https://github.com/kubernetes/dashboard/wiki/Creating-sample-user
Binding kube-system:kubernetes-dashboard to the cluster-admin role means that anyone or anything that can access the dashboard has full control over the cluster.
It's not working on AKS as well. @kairok thank you for a fix!!!
This only happened to me when RBAC was enabled. Below fixed it
Run kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard Everything worked for me.
kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard
its work for me
Thank you mgwulay. This works for me.
@kairok thank you for a fix!!!
This looks fixed
It's only fixed after running the above command though.
Run kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard Everything worked for me.
Fantastic. It worked for me too... Thanks :)
@joshuataylor thank you for adding that important bit of information :) so that folks coming to this thread from older clusters have a clear path
For reference: this is (now) documented in https://github.com/kubernetes/dashboard/wiki/Access-control#admin-privileges
Run kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard Everything worked for me.
that worked for me
lol pretty disgraceful this is broken over a year later.
nothing is working for me after trying all above