Skip to content

Instantly share code, notes, and snippets.

@srhopkins
Created February 6, 2018 19:48
Show Gist options
  • Save srhopkins/1dc1e3d8330871d197da2b6d723cad9e to your computer and use it in GitHub Desktop.
Save srhopkins/1dc1e3d8330871d197da2b6d723cad9e to your computer and use it in GitHub Desktop.
Get kubernetes token for api one-liner access
~ kubectl get secrets --namespace=int # check secrets for namespace
NAME TYPE DATA AGE
default-token-skzsj kubernetes.io/service-account-token 3 6d
example-app-int kubernetes.io/tls 2 6d
~ export TOKEN=`kubectl get secret default-token-skzsj --namespace=int -o jsonpath={.data.token} | base64 -D` # `-D` for mac `-d` for linux
~ docker run --rm lachlanevenson/k8s-kubectl:v1.9.2 --namespace=int --server=https://api.example.com --token=${TOKEN} --insecure-skip-tls-verify=true get pods
NAME READY STATUS RESTARTS AGE
example-app-5866987b76-n2phz 1/1 Running 0 5d
example-app-5866987b76-tqtw2 1/1 Running 0 5d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment