Build K8S Clusters with Scripts(archived) - ji-it/CloudTides GitHub Wiki
Note that in order to successfully finish the following steps, you have to first:
- Generate a RSA-key pair on your own client machine and revise the authorized_key file under the /root/.ssh directory to add your public key (for root-login).
- Clone the whole CloudTides repository on your client machine.
- Execute
git clone https://github.com/vmware/pyvmomi-community-samples
and copy thetools
folder underTools
in ourPyVmomi
package.
Steps to build a cluster
- Use the template named
kube-scripts-updated
to deploy two VMs (1 for master node, 1 for worker node). The 3 scripts (kube-master-script
,kube-worker-script
andkube-worker-script-delete
) are pre-stored in the template. Get the IP address of these VMs. - On the client machine,
cd
to the directory of the fileexecute_program.py
. - For the master node, use
python execute_program.py -s (the address of vCenter, 202.121.180.3) -u (username) -p (password) -i (address of VM) -r (username of VM) -w (password of VM) -l /home/ve450/kube-master-script -f "/etc/network/interfaces > /tmp/plop" on the client machine.
- The script executed on the master node will generate a file named
add.txt
. It will be useful for worker nodes to join the cluster. - Using
scp
, send theadd.txt
file to the home directory of the VM which will be used as a worker. - For the worker node, use
python execute_program.py -s (the address of vCenter, 202.121.180.3) -u (username) -p (password) -i (address of VM) -r (username of VM) -w (password of VM) -l /home/ve450/kube-worker-script -f "/etc/network/interfaces > /tmp/plop"`
- The script will make use of
add.txt
and get the key to join the cluster. Then it will join the cluster.
Possible problems
- I have not found way so far to get the IP address of the newly created VMs automatically.
- To ensure a smooth login with
ssh
, I set StrictHostKeyChecking tono
, which may bring security issues. - (Important) When the project runs, many VMs will be deployed and then destroyed. For example, Shen Zhe once created a VM with IP
10.11.16.108
, and he deleted it after that. Yesterday I deployed a new VM and it has the same IP10.11.16.108
. Since I have oncessh
to the old VM, when I nowssh
to the new VM, the system will check theknown_hosts
file and then find that the RSA keys do not match. So there will be a login failure.