SECRET_NAME=$(kubectl get serviceaccounts default -o template --template="{{ (index .secrets 0).name }}")
kubectl get secret $SECRET_NAME -o template --template="{{.data.token}}" | base64 -d
copy result
create file ~/.kube/config
:
apiVersion: v1
clusters:
- cluster:
insecure-skip-tls-verify: true
server: https://<vagrant_box_ip>:6443
name: k8s
contexts:
- context:
cluster: k8s
user: "serviceaccount"
name: k8s
current-context: k8s
kind: Config
preferences: {}
users:
- name: serviceaccount
user:
token: <paste_token_from_previous_step_here>
- copy out and use k8s CA certificate from Vagrant box instead of
insecure-skip-tls-verify: true
http://kubernetes.io/docs/admin/authentication/ => way how we can create ca certs.