Skip to content

Instantly share code, notes, and snippets.

@vgribok
Created September 10, 2020 20:51
Show Gist options
  • Save vgribok/a4cd751ed06223d50fd39e99572988f7 to your computer and use it in GitHub Desktop.
Save vgribok/a4cd751ed06223d50fd39e99572988f7 to your computer and use it in GitHub Desktop.
PowerShell script opening Kuberntes dashboard on local computer and copying auth token to the clipboard for easy login
<#
Opens K8s Dashboard installed on EKS with `kubectl proxy`,
and copies authentication token to the clipboard for the easy of login.
Assumes current kubectl cluster is where the dashboard is.
To run, execute following PowerShell commands:
curl -o $env:TMP/open-K8s-dashbord-locally.ps1 https://gist.githubusercontent.com/vgribok/a4cd751ed06223d50fd39e99572988f7/raw/84b6539c734eeb8746ab3afb6bc38fceebb4606e/open-K8s-dashbord-locally.ps1
. $env:TMP/open-K8s-dashbord-locally.ps1
Pre-requisites:
- kubectl CLI
#>
start kubectl proxy
[string] $SecretName = kubectl -n kube-system get secret -o custom-columns=":metadata.name" | Select-String -pattern eks-admin-token
[string] $kdtoken = kubectl -n kube-system get secret $SecretName -o=jsonpath='{.data.token}'
[System.Text.Encoding]::UTF8.GetString([System.Convert]::FromBase64String($kdtoken)) | Set-Clipboard
start http://localhost:8001/api/v1/namespaces/kubernetes-dashboard/services/https:kubernetes-dashboard:/proxy/
Write-Host "Authentication token is copied to the clipboard.`nPlease *paste* it into the `"Enter Token`" textbox when prompted to login."
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment