-
Notifications
You must be signed in to change notification settings - Fork 1.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[cabpk] Write "/etc/hosts" and "/etc/hostname" #1580
Comments
@akutz I'm not sure I agree that the bootstrap data should always include /etc/hosts and /etc/hostname. Shouldn't we rely on the set_hostname, update_hostname, and update_etc_hosts modules to handle this? |
In addition to what @detiber mentioned, this functionality should be offered as an opt-in behavior that only some providers should use. AWS for example already sets these values internally on boot and doesn't need further intervention. |
Some background on this:
All this was a problem on CAPV because of the fact that the host name provided to a guest may be affected by a DHCP server's advertised domain, causing the static host name to change to the transient, fully-qualified host name. This would be a problem on any cloud-init system that uses DHCP and is subject to transient host names. However It turns out all of this may have been avoided in the first place if the bug resolved by kubernetes-sigs/cluster-api-provider-vsphere#476 had not existed. It turns out that the cloud-provider was never actually resolving VMs via their UUIDs, and so the node resolution wasn't occurring against vSphere. This was a really subtle issue, and quite frankly, I'm as equally shocked that the bug wasn't caught sooner as I am that the bug was caught at all. @ykakarap is building a custom version of CAPV that reverts kubernetes-sigs/cluster-api-provider-vsphere#474. Since CAPV now includes the cloud-provider fix (kubernetes-sigs/cluster-api-provider-vsphere#476), we think the host name fix in kubernetes-sigs/cluster-api-provider-vsphere#474 is no longer going to be necessary since the kubelet will be able to resolve the node by it's UUID. I will close this issue if @ykakarap 's testing reveals the issue no longer occurs. |
Test results: By using a CAPV image that reverts kubernetes-sigs/cluster-api-provider-vsphere#474 Relevant kubelet logs:
Relevant section of
Relevant section of
Content of
Results of
|
hmm, that output leads me to believe that the hostname is initially set to the fqdn (or possibly the ds.meta_data.local-hostname value) when the kubelet bootstrapping was initially started, and at some point later changes to the hostname defined in /var/lib/cloud/data/set-hostname. @akutz @ykakarap are there possibly two processes trying to set the local hostname based on those different values? |
Hi @detiber, It's absolutely the case that |
What's interesting to me is that the instance ID is The host name changes from
to
It was never just |
@akutz based on the output of the kubelet logs, it looks like it is indeed changed to That appears to be happening after the initial change from |
Hi @detiber, I'm sorry, I meant it wasn't ever just The way the host name commands work and are invoked in the cloud-init sources do show how the host name is set multiple ways in https://github.com/cloud-init/cloud-init/blob/2f3bb764626b9065f4102c7c0a67998a9c174444/cloudinit/distros/__init__.py#L218-L347. What's happening is the hostname is set to |
I think what we actually need to do is update the vSphere cloud-init datasource here to ask cloud-init to update the hostname after DHCP is enabled to ensure the host files are updated before kubeadm is run. This ensures that calls to |
This will make sure that the hostname of the VM is always the machine name (like Or, we can make sure to update the hostname properly before kubeadm runs as suggested here
I think the choice boils down to if we want the machine's hostname to be the machine name or the FQDN. I would vote for the hostname being set to the machine name as it would be consistent with the behavior in environments like VMC. |
Hi @ykakarap,
The problem with this, and correct me if I'm wrong @detiber, is when a DHCP server sets the host name option, the client (machine), unless configured not to, will use that name. This is what is happening in the Nimbus situation.
VMC's DHCP server simply doesn't set the host name option, so it's not a VMC specific issue. It's specific to DHCP. This is once again a problem unique to the on-prem providers since the AWS instance data sets the host name to the actual name the host will have since AWS knows that in advance and includes it in the metadata for the AWS cloud-init datasource to persist as the instance data. Whereas in a true DHCP environment, CAPV won't know the host name of the machine in advance. |
I'm not sure how cloud provider integration works with CAPV, but in at least AWS and OpenStack we are limited in what the Node "Name" can be based on what is expected by the cloud provider integration to match with queries against the remote API. |
That's not the issue here. It's that the DHCP server is overriding the host name. |
@akutz can we close this? |
Trying to figure this one out, but this sentence has me a bit stumped
It sounds like the files However, if only the host knows what values need to be there, then either the host needs to exist before CABPK generates data and the user adds these files to the KubeadmConfigSpec or the user could inject a script to generate these files before kubeadm init runs. not really sure where to put this, so i'm leaving it low priority in the current milestone. Please adjust if necessary, this is a best guess. /milestone v0.3.0 |
cc @yastij We need to kick this out of the v1a3 milestone if this is no longer an issue. Yuvaraj had been previously working on this. |
/assign |
@yastij did you have any updates on this? |
@yastij Any updates? Bumping to next for now. /milestone Next |
Closing this due to lack of updates /close |
@vincepri: Closing this issue. In response to this:
Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes/test-infra repository. |
/kind feature
Describe the solution you'd like
The bootstrap data should include the files
/etc/hosts
and/etc/hostname
with the values derived from the host. This ensures these files reflect the correct values without requiring a reboot before the systemd-hostnamed service updates them.The text was updated successfully, but these errors were encountered: