How do I find the join command for kubeadm on the master?

7/1/2018

I've lost the original 'kubeadm join' command when I previously ran kubeadm init.

How can I retrieve this value again?

-- Chris Stryczynski
kubeadm
kubernetes

2 Answers

7/1/2018
kubeadm token create --print-join-command
-- Chris Stryczynski
Source: StackOverflow

3/9/2019

To create join command please run following commands:

Step 1:

openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt \
    | openssl rsa -pubin -outform der 2>/dev/null \
    | openssl dgst -sha256 -hex \
    | sed 's/^.* //'

This command will provide you public key.

Step 2:

kubeadm token list

This will you token so copy token value under TOKEN with description "The default bootstrap token generated by kubeadm init."

Step 3: Now use following syntax to create join command without creating new token:

kubeadm join \
    --token=<from Step 2> \
    --discovery-token-ca-cert-hash sh2256:<from Step 1>

kubeadm token create command creates new token without any description, so you can pick token which has DESCRIPTION as kubeadm init to not create any additional token.

-- Abhishek Jain
Source: StackOverflow