Skip to content

Commit

Permalink
Merge pull request #158 from epics-containers/dashboard-serviceaccount
Browse files Browse the repository at this point in the history
Add serviceaccount instructions for k8s dashboard
  • Loading branch information
gilesknap authored Sep 2, 2024
2 parents 4f011df + ab2ce6a commit b493dab
Showing 1 changed file with 32 additions and 3 deletions.
35 changes: 32 additions & 3 deletions docs/tutorials/setup_k8s.md
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ kubectl get pods --namespace longhorn-system --watch
kubectl get storageclass
```

### Set up k8s dashboard
### Set up k8s dashboard (Optional)

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

To generate a bearer token:
To generate a bearer token in order to log in - first create a Service Account:
```
kubectl create token default
kubectl apply -f - <<EOF
apiVersion: v1
kind: ServiceAccount
metadata:
name: admin-user
namespace: kubernetes-dashboard
EOF
```

Then bind the Service Account to a role with suitable permissions:
```
kubectl apply -f - <<EOF
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: admin-user
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: cluster-admin
subjects:
- kind: ServiceAccount
name: admin-user
namespace: kubernetes-dashboard
EOF
```

Finally generate a short duration token that can be used to log in:
```
kubectl -n kubernetes-dashboard create token admin-user
```

### Completed
Expand Down

0 comments on commit b493dab

Please sign in to comment.