aks-engine icon indicating copy to clipboard operation
aks-engine copied to clipboard

Dashboard permission errors from `kubectl proxy` on K8s 1.10.3 cluster deployed from acs-engine master

Open PatrickLang opened this issue 8 years ago • 27 comments

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):

  1. Create a JSON file with
"orchestratorProfile": {
      "orchestratorType": "Kubernetes",
      "orchestratorVersion": "1.10.3"
    },
  1. acs-engine generate, deploy it

  2. Copy .kube/config from master node

  3. kubectl proxy

  4. browse to http://localhost:8001/api/v1/namespaces/kube-system/services/https:kubernetes-dashboard:/proxy/#!/overview?namespace=default

PatrickLang avatar May 31 '18 20:05 PatrickLang

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]

PatrickLang avatar May 31 '18 21:05 PatrickLang

Applying the binding described at https://github.com/kubernetes/dashboard/wiki/Access-control#admin-privileges fixed it

PatrickLang avatar May 31 '18 21:05 PatrickLang

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.

PatrickLang avatar May 31 '18 23:05 PatrickLang

This is so broken...

Cloudmersive avatar Jul 01 '18 22:07 Cloudmersive

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

PatrickLang avatar Aug 08 '18 21:08 PatrickLang

Run kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard Everything worked for me.

kairok avatar Aug 25 '18 03:08 kairok

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.

PatrickLang avatar Aug 31 '18 01:08 PatrickLang

It's not working on AKS as well. @kairok thank you for a fix!!!

SychevIgor avatar Sep 12 '18 13:09 SychevIgor

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.

ccit-spence avatar Oct 12 '18 07:10 ccit-spence

kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard

its work for me

mgwulay avatar Nov 09 '18 17:11 mgwulay

Thank you mgwulay. This works for me.

JMagerram avatar Feb 16 '19 06:02 JMagerram

@kairok thank you for a fix!!!

sklrsn avatar Mar 01 '19 22:03 sklrsn

This looks fixed

jackfrancis avatar Mar 21 '19 19:03 jackfrancis

It's only fixed after running the above command though.

joshuataylor avatar May 06 '19 03:05 joshuataylor

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 :)

sujyot avatar May 27 '19 04:05 sujyot

@joshuataylor thank you for adding that important bit of information :) so that folks coming to this thread from older clusters have a clear path

jackfrancis avatar May 28 '19 16:05 jackfrancis

For reference: this is (now) documented in https://github.com/kubernetes/dashboard/wiki/Access-control#admin-privileges

Rick-Jongbloed avatar Jun 22 '19 20:06 Rick-Jongbloed

Run kubectl create clusterrolebinding kubernetes-dashboard --clusterrole=cluster-admin --serviceaccount=kube-system:kubernetes-dashboard Everything worked for me.

that worked for me

glglak avatar Aug 04 '19 14:08 glglak

lol pretty disgraceful this is broken over a year later.

KyleSanderson avatar Sep 07 '19 00:09 KyleSanderson

nothing is working for me after trying all above

alkadevops avatar Oct 24 '19 17:10 alkadevops