Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save terashim/66a04d06ea5abf29e557fb12a2d9a8ef to your computer and use it in GitHub Desktop.
Save terashim/66a04d06ea5abf29e557fb12a2d9a8ef to your computer and use it in GitHub Desktop.
k8s で default-token を取得するワンライナー
#!/bin/bash
# 応用例
# Docker Desktopのk8sのconfigにdefault-tokenを設定する
kubectl config set-credentials docker-desktop --token="$(kubectl -n kube-system get secret | grep default-token | awk '{print $1}' | xargs -IXXX kubectl -n kube-system get secret XXX -o jsonpath='{.data.token}' | base64 --decode)"
kubectl -n kube-system get secret | grep default-token | awk '{print $1}' | xargs -IXXX kubectl -n kube-system get secret XXX -o jsonpath='{.data.token}' | base64 --decode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment