Merge pull request #27441 from derekwaynecarr/downward_api_node_defaults
Automatic merge from submit-queue Revert revert of downward api node defaults Reverts the revert of https://github.com/kubernetes/kubernetes/pull/27439 Fixes #27062 @dchen1107 - who at Google can help debug why this caused issues with GKE infrastructure but not GCE merge queue? /cc @wojtek-t @piosz @fgrzadkowski @eparis @pmorie
This commit is contained in:
@@ -128,6 +128,50 @@ var _ = framework.KubeDescribe("Downward API", func() {
|
||||
testDownwardAPI(f, podName, env, expectations)
|
||||
})
|
||||
|
||||
It("should provide default limits.cpu/memory from node capacity", func() {
|
||||
podName := "downward-api-" + string(util.NewUUID())
|
||||
env := []api.EnvVar{
|
||||
{
|
||||
Name: "CPU_LIMIT",
|
||||
ValueFrom: &api.EnvVarSource{
|
||||
ResourceFieldRef: &api.ResourceFieldSelector{
|
||||
Resource: "limits.cpu",
|
||||
},
|
||||
},
|
||||
},
|
||||
{
|
||||
Name: "MEMORY_LIMIT",
|
||||
ValueFrom: &api.EnvVarSource{
|
||||
ResourceFieldRef: &api.ResourceFieldSelector{
|
||||
Resource: "limits.memory",
|
||||
},
|
||||
},
|
||||
},
|
||||
}
|
||||
expectations := []string{
|
||||
fmt.Sprintf("CPU_LIMIT=[1-9]"),
|
||||
fmt.Sprintf("MEMORY_LIMIT=[1-9]"),
|
||||
}
|
||||
pod := &api.Pod{
|
||||
ObjectMeta: api.ObjectMeta{
|
||||
Name: podName,
|
||||
Labels: map[string]string{"name": podName},
|
||||
},
|
||||
Spec: api.PodSpec{
|
||||
Containers: []api.Container{
|
||||
{
|
||||
Name: "dapi-container",
|
||||
Image: "gcr.io/google_containers/busybox:1.24",
|
||||
Command: []string{"sh", "-c", "env"},
|
||||
Env: env,
|
||||
},
|
||||
},
|
||||
RestartPolicy: api.RestartPolicyNever,
|
||||
},
|
||||
}
|
||||
|
||||
testDownwardAPIUsingPod(f, pod, env, expectations)
|
||||
})
|
||||
})
|
||||
|
||||
func testDownwardAPI(f *framework.Framework, podName string, env []api.EnvVar, expectations []string) {
|
||||
@@ -159,5 +203,9 @@ func testDownwardAPI(f *framework.Framework, podName string, env []api.EnvVar, e
|
||||
},
|
||||
}
|
||||
|
||||
testDownwardAPIUsingPod(f, pod, env, expectations)
|
||||
}
|
||||
|
||||
func testDownwardAPIUsingPod(f *framework.Framework, pod *api.Pod, env []api.EnvVar, expectations []string) {
|
||||
f.TestContainerOutputRegexp("downward api env vars", pod, 0, expectations)
|
||||
}
|
||||
|
Reference in New Issue
Block a user