Skip to content
Permalink
Browse files

Merge pull request #79751 from aojea/e2eDownwardAPI

Add e2e test for downward API with host network
  • Loading branch information...
k8s-ci-robot committed Jul 30, 2019
2 parents 40b3179 + d20698a commit a23fc83fcd6b0602fcc6de017c97fac85251a44f
Showing with 50 additions and 0 deletions.
  1. +50 −0 test/e2e/common/downward_api.go
@@ -104,6 +104,56 @@ var _ = ginkgo.Describe("[sig-node] Downward API", func() {
testDownwardAPI(f, podName, env, expectations)
})

ginkgo.It("should provide host IP and pod IP as an env var if pod uses host network [LinuxOnly]", func() {
podName := "downward-api-" + string(uuid.NewUUID())
env := []v1.EnvVar{
{
Name: "HOST_IP",
ValueFrom: &v1.EnvVarSource{
FieldRef: &v1.ObjectFieldSelector{
APIVersion: "v1",
FieldPath: "status.hostIP",
},
},
},
{
Name: "POD_IP",
ValueFrom: &v1.EnvVarSource{
FieldRef: &v1.ObjectFieldSelector{
APIVersion: "v1",
FieldPath: "status.podIP",
},
},
},
}

expectations := []string{
fmt.Sprintf("OK"),
}

pod := &v1.Pod{
ObjectMeta: metav1.ObjectMeta{
Name: podName,
Labels: map[string]string{"name": podName},
},
Spec: v1.PodSpec{
Containers: []v1.Container{
{
Name: "dapi-container",
Image: imageutils.GetE2EImage(imageutils.BusyBox),
Command: []string{"sh", "-c", `[[ "${HOST_IP:?}" == "${POD_IP:?}" ]] && echo 'OK' || echo "HOST_IP: '${HOST_IP}' != POD_IP: '${POD_IP}'"`},
Env: env,
},
},
HostNetwork: true,
RestartPolicy: v1.RestartPolicyNever,
},
}

testDownwardAPIUsingPod(f, pod, env, expectations)

})

/*
Release : v1.9
Testname: DownwardAPI, environment for CPU and memory limits and requests

0 comments on commit a23fc83

Please sign in to comment.
You can’t perform that action at this time.