Created
January 7, 2020 09:20
-
-
Save kalostoykov/b47ee2850fb740a724911a07204baa28 to your computer and use it in GitHub Desktop.
This file contains hidden or 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
# your server name goes here | |
server=https://localhost:8443 | |
# the name of the secret containing the service account token goes here | |
name=default-token-sg96k | |
ca=$(kubectl get secret/$name -o jsonpath='{.data.ca\.crt}') | |
token=$(kubectl get secret/$name -o jsonpath='{.data.token}' | base64 --decode) | |
namespace=$(kubectl get secret/$name -o jsonpath='{.data.namespace}' | base64 --decode) | |
echo " | |
apiVersion: v1 | |
kind: Config | |
clusters: | |
- name: default-cluster | |
cluster: | |
certificate-authority-data: ${ca} | |
server: ${server} | |
contexts: | |
- name: default-context | |
context: | |
cluster: default-cluster | |
namespace: default | |
user: default-user | |
current-context: default-context | |
users: | |
- name: default-user | |
user: | |
token: ${token} | |
" > sa.kubeconfig |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment