Desired Outcome: I want to set up a CSV file with userids and passwords and access Kubernetes Dashboard as a full admin, preferably from anywhere with a browser. I am just learning kubernetes and want to experiment with cluster management, deployments, etc. This is just for learning and is not a Production Setup. I am using Kubernetes version 1.9.2 and created a 3-machine cluster (master and 2 workers)
Background/What I've done so far:
I read the Dashboard README and I created an admin-user and admin-role-binding with the files shown below. I can then use the kubectl describe secret
command to get the admin user's token. I run kubectl proxy
on the cluster master and authenticate to the Dashboard with that token using a browser running on the cluster master. All of this works.
admin-user.yaml:
apiVersion: v1 kind: ServiceAccount metadata: name: admin-user namespace: kube-system
admin-role-binding.yaml:
apiVersion: rbac.authorization.k8s.io/v1beta1 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
I can login to the dashboard as admin IF:
- I run kubectl proxy
- I access the dashboard with a browser where I ran command (1)
- I use the "token" option to login and paste the admin user's token which I get using the
kubectl describe secret
command.
What I'd like to do:
- Set up a CSV file with userids/passwords
- Login as admin with userid/password
- Be able to login from anywhere
To that end, I created a CSV file, e.g. /home/chris/myusers.txt
:
mypasswd,admin,42
I did not know what value to use for id so I just punted with 42.
I then edited the file:/etc/kubernetes/manifests/kube-apiserver.yaml
and adding this line:--basic-auth-file=/home/chris/myusers.txt
and then restarting kubelet:sudo systemctl restart kubelet
However when I did that, my cluster stopped working and I couldn't access the Dashboard so I reverted back where I still use the admin user's token.
My questions are:
- Is it possible to do what I'm trying to do here?
- What id values do I use in the user CSV file? What groups would I specify?
- What other changes do I need to make to get all of this to work? If I modify the apiserver manifest to use a file with userids/passwords, does that mess up the rest of the configuration for my cluster?