When i run kubeadm init
it shows a token that I should use from the other hosts to connect to this host. Where is that token stored? I'm trying to figure out more ways to automate this by adding kubeadm inside of Terraform.
Thanks for any help!
Try to create new as per below command as initial token is valid only 24 hours.
kubeadm token create --ttl=0
Here ttl=0 means, generated token will never expire.
Then join node as per below command:
kubeadm join <generated_token>
If you get any error for verifying ca hash, then join as per below:
kubeadm join <generated_token> --discovery-token-unsafe-skip-ca-verification
The instruction for Kubernetes 1.9.x (and above) can be found here.
The commands I used are:
kubeadm token generate
kubeadm token create <generated-token> --print-join-command --ttl=0
Run this command in the master node to get the token
kubeadm token list
--token
By default, kubeadm init automatically generates the token used to initialise each new node. If you would like to manually specify this token, you can use the --token flag. The token must be of the format ‘<6 character string>.<16 character string>’.
you can see token value on master node using command:
cat /etc/kubernetes/pki/tokens.csv
Best way to avoid creating new token is -
kubeadm token list
kubeadm token create <copied token from previous command output>** --print-join-command
you will get JOIN command to run on any physical/vitual machine to join kubernetes cluster....
kubectl -n kube-system get secret clusterinfo -o yaml | grep token-map | awk '{print $2}' | base64 -d | sed "s|{||g;s|}||g;s|:|.|g;s/\"//g;" | xargs echo
Use this command : $ sudo kubeadm token list
Still, if you did not get, use following commands
$ sudo kubeadm reset
$ sudo kubeadm init