Skip to content

Commit b493dab

Browse files
authored
Merge pull request #158 from epics-containers/dashboard-serviceaccount
Add serviceaccount instructions for k8s dashboard
2 parents 4f011df + ab2ce6a commit b493dab

File tree

1 file changed

+32
-3
lines changed

1 file changed

+32
-3
lines changed

docs/tutorials/setup_k8s.md

Lines changed: 32 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@ kubectl get pods --namespace longhorn-system --watch
174174
kubectl get storageclass
175175
```
176176

177-
### Set up k8s dashboard
177+
### Set up k8s dashboard (Optional)
178178

179179
The Kubernetes dashboard is a web-based Kubernetes user interface.
180180
As per <https://kubernetes.io/docs/tasks/access-application-cluster/web-ui-dashboard/> it can be installed into the cluster as follows:
@@ -189,9 +189,38 @@ To access the gui through a browser on `https://localhost:8080/`:
189189
kubectl -n kubernetes-dashboard port-forward svc/kubernetes-dashboard-kong-proxy 8080:443
190190
```
191191

192-
To generate a bearer token:
192+
To generate a bearer token in order to log in - first create a Service Account:
193193
```
194-
kubectl create token default
194+
kubectl apply -f - <<EOF
195+
apiVersion: v1
196+
kind: ServiceAccount
197+
metadata:
198+
name: admin-user
199+
namespace: kubernetes-dashboard
200+
EOF
201+
```
202+
203+
Then bind the Service Account to a role with suitable permissions:
204+
```
205+
kubectl apply -f - <<EOF
206+
apiVersion: rbac.authorization.k8s.io/v1
207+
kind: ClusterRoleBinding
208+
metadata:
209+
name: admin-user
210+
roleRef:
211+
apiGroup: rbac.authorization.k8s.io
212+
kind: ClusterRole
213+
name: cluster-admin
214+
subjects:
215+
- kind: ServiceAccount
216+
name: admin-user
217+
namespace: kubernetes-dashboard
218+
EOF
219+
```
220+
221+
Finally generate a short duration token that can be used to log in:
222+
```
223+
kubectl -n kubernetes-dashboard create token admin-user
195224
```
196225

197226
### Completed

0 commit comments

Comments
 (0)