mirror of
https://github.com/jcwimer/kubernetes-ansible
synced 2026-03-25 00:54:44 +00:00
Added script to get kubernetes dashboard user key
This commit is contained in:
21
supporting-scripts/dashboard-nodeport-user.sh
Normal file
21
supporting-scripts/dashboard-nodeport-user.sh
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
# https://blog.heptio.com/on-securing-the-kubernetes-dashboard-16b09b1b7aca
|
||||||
|
# kubectl -n kube-system edit service kubernetes-dashboard
|
||||||
|
|
||||||
|
# Change dashboard to node port
|
||||||
|
kubectl -n kube-system get service kubernetes-dashboard -o yaml | \
|
||||||
|
sed 's/type: ClusterIP/type: NodePort/g' | \
|
||||||
|
kubectl apply -f -
|
||||||
|
|
||||||
|
# Create the service account in the current namespace
|
||||||
|
# (we assume default)
|
||||||
|
kubectl create serviceaccount my-dashboard-sa
|
||||||
|
|
||||||
|
# Give that service account root on the cluster
|
||||||
|
kubectl create clusterrolebinding my-dashboard-sa \
|
||||||
|
--clusterrole=cluster-admin \
|
||||||
|
--serviceaccount=default:my-dashboard-sa
|
||||||
|
|
||||||
|
# Get secret token
|
||||||
|
kubectl describe secret $(kubectl get secret | grep my-dashboard-sa | awk '{print $1}') | grep 'token:' | awk {'print $2'}
|
||||||
Reference in New Issue
Block a user