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:

  1. 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).
  2. Clone the whole CloudTides repository on your client machine.
  3. Execute git clone https://github.com/vmware/pyvmomi-community-samples and copy the tools folder under Tools in our PyVmomi package.

Steps to build a cluster

  1. 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 and kube-worker-script-delete) are pre-stored in the template. Get the IP address of these VMs.
  2. On the client machine, cd to the directory of the file execute_program.py.
  3. 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.

  1. 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.
  2. Using scp, send the add.txt file to the home directory of the VM which will be used as a worker.
  3. 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"`

  1. The script will make use of add.txt and get the key to join the cluster. Then it will join the cluster.

Possible problems

  1. I have not found way so far to get the IP address of the newly created VMs automatically.
  2. To ensure a smooth login with ssh, I set StrictHostKeyChecking to no, which may bring security issues.
  3. (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 IP 10.11.16.108. Since I have once ssh to the old VM, when I now ssh to the new VM, the system will check the known_hosts file and then find that the RSA keys do not match. So there will be a login failure.