Merge pull request #12595 from smarterclayton/add_pod_status_ip

Add status.podIP as a valid downward API target
This commit is contained in:
Brendan Burns
2015-08-14 20:29:50 -07:00
8 changed files with 30 additions and 5 deletions

View File

@@ -1051,7 +1051,10 @@ func (kl *Kubelet) podFieldSelectorRuntimeValue(fs *api.ObjectFieldSelector, pod
if err != nil {
return "", err
}
switch internalFieldPath {
case "status.podIP":
return pod.Status.PodIP, nil
}
return fieldpath.ExtractFieldPathAsString(pod, internalFieldPath)
}

View File

@@ -1187,6 +1187,15 @@ func TestMakeEnvironmentVariables(t *testing.T) {
},
},
},
{
Name: "POD_IP",
ValueFrom: &api.EnvVarSource{
FieldRef: &api.ObjectFieldSelector{
APIVersion: testapi.Version(),
FieldPath: "status.podIP",
},
},
},
},
},
masterServiceNs: "nothing",
@@ -1194,6 +1203,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
expectedEnvs: []kubecontainer.EnvVar{
{Name: "POD_NAME", Value: "dapi-test-pod-name"},
{Name: "POD_NAMESPACE", Value: "downward-api"},
{Name: "POD_IP", Value: "1.2.3.4"},
},
},
{
@@ -1345,6 +1355,7 @@ func TestMakeEnvironmentVariables(t *testing.T) {
Name: "dapi-test-pod-name",
},
}
testPod.Status.PodIP = "1.2.3.4"
result, err := kl.makeEnvironmentVariables(testPod, tc.container)
if err != nil {