Merge pull request #40771 from apprenda/kubeadm-135-FQDN

Automatic merge from submit-queue (batch tested with PRs 40574, 40806, 40308, 40771, 39440)

kubeadm: preflight check for incorrect FQDN

**What this PR does / why we need it**: There are a variety of system configuration errors (such as cloud-init bugs when deploying on AWS) which can cause hostname and uname -n to be wrong for a given host. This will cause kubeadm setup to fail in interesting and hard-to-figure-out ways (it doesn't fail until you start trying to set up DNS on the master, for example).

This PR adds a preflight check to test whether or not the server can reach itself using that name. This does not catch the case that the FQDN belongs to a different but valid server, but it would catch some of the cases. 

**Which issue this PR fixes** : fixes https://github.com/kubernetes/kubeadm/issues/135

**Special notes for your reviewer**: /cc @luxas 

**Release note**:
```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2017-02-01 16:12:49 -08:00 committed by GitHub
commit 2ee058c2cc

View File

@ -243,6 +243,13 @@ func (hc HostnameCheck) Check() (warnings, errors []error) {
for _, msg := range validation.ValidateNodeName(hostname, false) {
errors = append(errors, fmt.Errorf("hostname \"%s\" %s", hostname, msg))
}
addr, err := net.LookupHost(hostname)
if addr == nil {
errors = append(errors, fmt.Errorf("hostname \"%s\" could not be reached", hostname))
}
if err != nil {
errors = append(errors, fmt.Errorf("hostname \"%s\" %s", hostname, err))
}
return nil, errors
}