<p>I have set up my master nodes using <code>kubeadm</code>.</p>

<p>Now I want to run the <code>join</code> command on my nodes so that the later join the cluster.</p>

<p>All I have to do is run </p>

<pre><code>kubeadm join --token &lt;token&gt; --discovery-token-ca-cert-hash &lt;sha256&gt;
</code></pre>

<p>where <code>&lt;token&gt;</code> and  are values previously returned by the command below:</p>

<pre><code>kubeadm init 
</code></pre>

<p>I am also trying to script the above process and I see that parsing the actual tokens from the last command is kinda difficult;</p>

<p>So I was wandering whether there is a way to explicitly specify the <code>&lt;token&gt;</code> and the <code>&lt;sha256&gt;</code> during cluster initialization, to avoid having to perform hacky parsing of the <code>init</code> command.</p>

pkaramol
<p>I was trying to make a script for it as well. </p>

<p>In order to get the values needed I am using these commands: </p>

<pre><code>TOKEN=$(sshpass -p $PASSWORD ssh  -o StrictHostKeyChecking=no root@$MASTER_IP sudo kubeadm token list | tail -1 | cut -f 1 -d " ") 


HASH=$(sshpass -p $PASSWORD ssh  -o StrictHostKeyChecking=no  root@$MASTER_IP  openssl x509 -pubkey -in /etc/kubernetes/pki/ca.crt | openssl rsa -pubin -outform der 2&gt;/dev/null | openssl dgst -sha256 -hex | sed 's/^.* //' )
</code></pre>

<p>Basically I use this commands to ssh on master and get this values. </p>

<p>I have not found a easier way to achieve this. </p>
