From 0cef5651c43f51856cfcbbda6e4baa8cedcb3a46 Mon Sep 17 00:00:00 2001 From: Jacob Cody Wimer Date: Tue, 12 Feb 2019 09:24:12 -0500 Subject: [PATCH] Added script to get kubernetes dashboard user key --- supporting-scripts/dashboard-nodeport-user.sh | 21 +++++++++++++++++++ 1 file changed, 21 insertions(+) create mode 100644 supporting-scripts/dashboard-nodeport-user.sh diff --git a/supporting-scripts/dashboard-nodeport-user.sh b/supporting-scripts/dashboard-nodeport-user.sh new file mode 100644 index 0000000..bdf955c --- /dev/null +++ b/supporting-scripts/dashboard-nodeport-user.sh @@ -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'}