<p>How can I distribute the kube config file on worker nodes?</p>
<p>Only my master node has it (file under <code>~/.kube/config</code>), and I'm not sure what's the proper way to programmatically copy the file over to the worker nodes, so that I can use <code>kubectl</code> on all nodes.</p>

Michele Piccolini
<p>It is not recommended that you have ~/.kube/config on the worker nodes. If a worker node is compromised due to a vulnerable pod, it could compromise the cluster using this config.</p>
<p>Thats why it is recommended to use a bastion host and use kube context.</p>
<p>However, for non-prod environments,</p>
<p>you can do something like this</p>
<pre><code>kubectl get no --no-headers | egrep -v &quot;master|controlplane&quot; |  awk '{print $1}' | while read line; do 
    scp -pr ~/.kube/ ${line}:~/.kube; 
done 
</code></pre>
<p>scp -pr will create the .kube  directory if it doesn't exist on the  worker nodes</p>
