Merge pull request #47143 from ethernetdan/net_pod_use_nodename

Automatic merge from submit-queue (batch tested with PRs 47065, 47157, 47143)

Use actual hostname when creating network e2e test pod

**What this PR does / why we need it**:
This changes a e2e framework network test Pod use the actual hostname value to match the `kubernetes.io/hostname` label in it's `NodeSelector`. Currently it assumes the Node name will match that hostname label which is not true in all environments.

**Which issue this PR fixes** *(optional, in `fixes #<issue number>(, fixes #<issue_number>, ...)` format, will close that issue when PR gets merged)*: 
Fixes coreos/tectonic-installer#1018

**Release note**:

```release-note
NONE
```
This commit is contained in:
Kubernetes Submit Queue 2017-06-08 13:43:16 -07:00 committed by GitHub
commit f21cbfa309

View File

@ -308,7 +308,7 @@ func (config *NetworkingTestConfig) GetSelfURL(port int32, path string, expected
}
}
func (config *NetworkingTestConfig) createNetShellPodSpec(podName string, node string) *v1.Pod {
func (config *NetworkingTestConfig) createNetShellPodSpec(podName, hostname string) *v1.Pod {
probe := &v1.Probe{
InitialDelaySeconds: 10,
TimeoutSeconds: 30,
@ -358,7 +358,7 @@ func (config *NetworkingTestConfig) createNetShellPodSpec(podName string, node s
},
},
NodeSelector: map[string]string{
"kubernetes.io/hostname": node,
"kubernetes.io/hostname": hostname,
},
},
}
@ -539,7 +539,8 @@ func (config *NetworkingTestConfig) createNetProxyPods(podName string, selector
createdPods := make([]*v1.Pod, 0, len(nodes))
for i, n := range nodes {
podName := fmt.Sprintf("%s-%d", podName, i)
pod := config.createNetShellPodSpec(podName, n.Name)
hostname, _ := n.Labels["kubernetes.io/hostname"]
pod := config.createNetShellPodSpec(podName, hostname)
pod.ObjectMeta.Labels = selector
createdPod := config.createPod(pod)
createdPods = append(createdPods, createdPod)