Skip to content

Commit ab2ce6a

Browse files
authored
Update setup_k8s.md
1 parent c7bbe6f commit ab2ce6a

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
@@ -175,7 +175,7 @@ kubectl get pods --namespace longhorn-system --watch
175175
kubectl get storageclass
176176
```
177177

178-
### Set up k8s dashboard
178+
### Set up k8s dashboard (Optional)
179179

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

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

198227
### Completed

0 commit comments

Comments
 (0)