https://rancher.com/ logo
Title
e

early-engineer-43393

02/02/2023, 7:51 PM
Hi all, what’s the easiest way to update the hosts file on each node in the cluster so as it can be resolved. Currently if we try to resolve a node by name it doesn’t resolve, we can get around this by updating the hosts file, but I would like to think there is an automated way of doing this on provisioning?
c

creamy-pencil-82913

02/02/2023, 7:55 PM
what is “it” that you are trying to resolve?
Ideally if you’re referencing something using a hostname, that hostname would be in DNS.
Editing hosts files should be a temporary workaround while you get DNS set up. It’s not something I would architect as a long-term solution.
e

early-engineer-43393

02/02/2023, 8:02 PM
We need to resolve the node name in the cluster, we have a security product which grabs the host name of the node, and as it doesn’t resolve to anything fails to run, we got a temporary fix by updating the host entry, we do have DNS but how do we get the random name of nodes to resolve to the IP dynamically?
c

creamy-pencil-82913

02/02/2023, 8:09 PM
I’m not sure what your environment looks like, but having working DNS is part of a basic network environment. Whatever’s allocating IPs and setting hostnames also creates a DNS entry for the host, either manually or based on the DHCP lease. On most cloud providers, the hostname is set to something that also resolves in the cloud provider’s DNS.
are the names truly “random” or are they determined by your provider?
e

early-engineer-43393

02/02/2023, 8:14 PM
When we resolve the IP on a node it returns the vsphere cloud provider service that’s runs on the cluster, the names of the nodes are based on our machine pool names followed by random string. Maybe there is something in our machine template which is wrong but we did get this signed off by a rancher resource as we are paying customers. Maybe better to open a ticket?
c

creamy-pencil-82913

02/02/2023, 8:16 PM
yeah, if you have support then I would engage them… but they might bounce it back to your network folks to figure out how to get DNS working properly in your env. You definitely need resolvable hostnames.
e

early-engineer-43393

02/02/2023, 8:17 PM
Thanks Brandon, will do that tomorrow morning 😀
s

square-policeman-85866

02/02/2023, 8:22 PM
We are provisioning via the rancher UI. The host name gets set as <cluster name-machinepool-random guid>. Is that rancher setting the host name then?
The workaround entails us updating the local host in the hosts file to look like 127.0.0.1 <host name> localhost
r

rough-farmer-49135

02/02/2023, 11:59 PM
It sounds like you guys are talking about the node name that Rancher gives each node rather than the node's hostname. Is that what you're asking?
e

early-engineer-43393

02/03/2023, 8:53 AM
Yeah that’s correct, in saying that our node name matches the host name
r

rough-farmer-49135

02/07/2023, 2:31 PM
There was a way to label hosts with their hostname when adding to Rancher so it'd show up on the page but I never got the node names matching myself.
s

square-policeman-85866

02/09/2023, 10:30 AM
Think we figured it out. In the rancher UI if we add ‘manage_etc_hosts: true’ to the cloud config section, then it seems to use a template in etc/cloud/templates/host.suse.tmpl which then sets the host name for us :)