heptio / aws-quickstart

AWS Kubernetes cluster via CloudFormation and kubeadm
Apache License 2.0
223 stars 134 forks source link

Hostname Enhancement for existing vpc's #171

Closed rbankston closed 6 years ago

rbankston commented 6 years ago

Currently this project relies on hostname -f to provide hostname resolution. This call can be broken based on dhcp changes. We've seen this happen when launching into an existing vpc like issues #118, and #129. This could rely on instance metadata which works regardless of dhcp settings. The change would consist of replacing:

HOSTNAME="$(hostname -f)"

with

HOSTNAME="$(curl http://169.254.169.254/latest/meta-data/local-hostname)"

the rest of the scripts behavior would remain unchanged.

timothysc commented 6 years ago

xref - https://github.com/kubernetes/kubeadm/issues/653 , as it's in a similar vein.

detiber commented 6 years ago

@rbankston I'm not sure that the metadata local-hostname is available in all cases. I think it depends on having dns configured for the vpc. Granted you need dns configured on the VPC if you want to use the cloud-provider integration, which I suspect most users would want to do if they are running the quickstart :grinning:

rbankston commented 6 years ago

@detiber Pretty sure that the local-hostname is always available based on a few docs I've read. The dhcp documentation calls out local-hostname always being set regardless of other vpc options. The bit of the docs that says it should always be available is:

By default, all instances in a nondefault VPC receive an unresolvable host name that AWS assigns (for example, ip-10-0-0-202)
krazik commented 6 years ago

simple hack fix for this.

change hostname -f to hostname -f 2>/dev/null || curl http://169.254.169.254/latest/meta-data/local-hostname

krazik commented 6 years ago

I can submit a pr if you want tho simple to change in the ~3 files

-Rylan

rbankston commented 6 years ago

Can confirm the curl to metadata on AWS works even without hostname -f available. This is thanks to testing done by @krazik. @timothysc we ok to submit a pr to fix that up for getting around hostname -f failures?

-Ralph

chuckha commented 6 years ago

Definitely submit a PR. This is the biggest issue we've run into in the last 6 months. Based on our current prios we'll get to it in the next week or two, but it'll be better to have the PR ready to go. Thanks for looking into this!

rbankston commented 6 years ago

Pull request exists as https://github.com/heptio/aws-quickstart/pull/177

chuckha commented 6 years ago

@rbankston did you know you can add "Closes #171" to your PR (either commit or PR description) and the ticket will auto close? :D