Skip to content

Instantly share code, notes, and snippets.

@JimHume
Created October 20, 2020 00:00
Show Gist options
  • Save JimHume/67d193d2bb86009bb5007c2da85be5b5 to your computer and use it in GitHub Desktop.
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.
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
@brandonwilliamsised
Copy link

boring

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment