Automate SSH scripting to join nodes on Kubernetes

7/29/2020

I have a of machines to join nodes to in a Kubernetes cluster. I was able to create a script to automate the installation of Kubernetes on baremetal from scratch, but I need help to create a script to join the machines on the different nodes. I don't know how to copy and paste in a shell script.

Here's what I would like to automate (pseudo code)

log in as root
kubeadm token create --print-join-command
Results = kubeadm join <token>
Copy Results
ssh hostname1
log in as root 
(paste Results)
exit
exit
ssh hostname2
log in as root 
(paste Results)
exit
exit
...
...
...
.
-- Vinh Tran
automation
kubernetes
ssh

1 Answer

7/29/2020

use ansible for that . get join token inventory:

machine1
machine2
machine3 

and launch a playbook :

- hosts: all 
  tasks: 
  - name: script launch 
    script: ton_scrip.sh 
-- breizh5729
Source: StackOverflow