Created
October 20, 2020 00:00
-
-
Save JimHume/67d193d2bb86009bb5007c2da85be5b5 to your computer and use it in GitHub Desktop.
Kubernetes dashboard: get current admin token, copy it to the clipboard, port-forward the dashboard locally, then launch in a browser.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
clear | |
# Find the current cluster admin user token | |
$clusterName = $(kubectl config current-context) | |
$contextUser = $(kubectl config view -o jsonpath="{.contexts[?(@.name == '$clusterName')].context.user}") | |
$token = $(kubectl config view -o jsonpath="{.users[?(@.name == '$contextUser')].user.token}") | |
# Copy the admin token to the clipboard | |
Set-Clipboard $token | |
# Launch the dashboard and open it in a browser | |
$podName=$(kubectl get pods --namespace 'kube-system' -l k8s-app==kubernetes-dashboard -o jsonpath='{.items[].metadata.name}') | |
Start "https://localhost:10000" | |
kubectl port-forward pods/$podName 10000:8443 -n kube-system |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
boring