I’m trying to create a vSphere Kubernetes cluster in Rancher so that I can leverage the self-healing features using a preconfigured node template.
When Rancher creates the nodes, I need them to have unique hostnames and IP’s.
The problem is that the nodes are provisioned simultaneously from the template in vSphere and at first power-on, they have the same hostname and IP configuration as the template.
Assuming that the template is configured for DHCP, that (template) hostname is used when receiving an IP address from the DHCP server and every node ends up with the same hostname and the same IP from the DHCP server, which means that VM Tools reports the same IP back to the Rancher server before the SSH connection is initiated to the nodes.
I need the nodes to be configured with unique hostnames and IP’s.
How do I address this issue? Is there a way to somehow configure a new hostname and possibly a unique IP immediately after the node is powered-on the first time?
checkout the following, the whole thing is helpful, especially around 1hr and 15min in
Thanks, I have watched that video but it doesn’t answer the question that I’ve asked.
When you make a VM template the contents on the disk need to be sanitized properly so that the VMs created from it are independent. For example the /etc/machine-id is the default identifier sent to the DHCP server in recent Ubuntus, which would cause them to be the “same” machine and get back the same IP from the server.
I have managed to resolve the issue with DHCP by clearing the machine-id and now my nodes do get a unique IP address.
I am still having an issue with the hostnames inside the nodes being the same name that was assigned to the template that was used to provision the nodes.
I did also run “cloud-init clean -s -l” to reset cloud-init before I shut down the template VM and converted to template in vCenter.
When I create the cluster, it gets to the point where it indicates “waiting for SSH” and eventually fails with a timeout.
My nodes are provisioned from an Ubuntu 20.04 template and I’ve confirmed that there is an ISO file that is automatically mounted to the nodes when Rancher creates the cluster but it seems like the SSH user and keys are not being passed through properly.
Assistance would be greatly appreciated.
Hi Byte_76,
I had the same struggle until I found packer to generate our goldens. It’s pretty straight forward, took me a few tries to get it right. TBH, I have no idea what it does differently, but they deploy perfectly now. The links that I used are below to create mine.
GitHub - David-VTUK/Rancher-Packer: Packer Templates for Rancher
How To Install and use Packer on Ubuntu 20.04/18.04/16.04 | ComputingForGeeks
Thank you, I knew about Packer but didn’t realize that it does something different.
I’ll give it a try!