Properly parse hostname from metadata #19
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Properly parse hostname from metadata
This change splits the hostname supplied by the metadata service using dot as a delimiter instead of a single space. This API should return a single FQDN on most clouds.
Sample output from fetching the hostname from the AWS metadata service can be seen here:
https://docs.aws.amazon.com/AWSEC2/latest/UserGuide/instancedata-data-retrieval.html
OpenStack has the same kind of output.
We also make sure that the resulting hostname is no longer than 63 characters long.
This will ensure that
/etc/hostname
will contain a proper short form hostname instead of a FQDN.How to use
Build and then run:
on any VM spun up on a cloud with an ec2 compatible metadata service.
Testing done
Build a flatcar image using this commit and spun up a k8s cluster using kops. Hostname was properly set to the short form, not the FQDN.
Addresses the following issue: kubernetes/kops#15385
changelog/
directory (user-facing change, bug fix, security fix, update)/boot
and/usr
size, packages, list files for any missing binaries, kernel modules, config files, kernel modules, etc.