@@ -42,6 +42,49 @@ const (
42
42
webhookName = "vpa.k8s.io"
43
43
)
44
44
45
+ var _ = AdmissionControllerE2eDescribe ("Admission-controller" , ginkgo .Label ("FG:InPlaceOrRecreate" ), func () {
46
+ f := framework .NewDefaultFramework ("vertical-pod-autoscaling" )
47
+ f .NamespacePodSecurityEnforceLevel = podsecurity .LevelBaseline
48
+
49
+ ginkgo .BeforeEach (func () {
50
+ checkInPlaceOrRecreateTestsEnabled (f , true , false )
51
+ waitForVpaWebhookRegistration (f )
52
+ })
53
+
54
+ ginkgo .It ("starts pods with new recommended request with InPlaceOrRecreate mode" , func () {
55
+ d := NewHamsterDeploymentWithResources (f , ParseQuantityOrDie ("100m" ) /*cpu*/ , ParseQuantityOrDie ("100Mi" ) /*memory*/ )
56
+
57
+ ginkgo .By ("Setting up a VPA CRD" )
58
+ containerName := GetHamsterContainerNameByIndex (0 )
59
+ vpaCRD := test .VerticalPodAutoscaler ().
60
+ WithName ("hamster-vpa" ).
61
+ WithNamespace (f .Namespace .Name ).
62
+ WithTargetRef (hamsterTargetRef ).
63
+ WithContainer (containerName ).
64
+ WithUpdateMode (vpa_types .UpdateModeInPlaceOrRecreate ).
65
+ AppendRecommendation (
66
+ test .Recommendation ().
67
+ WithContainer (containerName ).
68
+ WithTarget ("250m" , "200Mi" ).
69
+ WithLowerBound ("250m" , "200Mi" ).
70
+ WithUpperBound ("250m" , "200Mi" ).
71
+ GetContainerResources ()).
72
+ Get ()
73
+
74
+ InstallVPA (f , vpaCRD )
75
+
76
+ ginkgo .By ("Setting up a hamster deployment" )
77
+ podList := startDeploymentPods (f , d )
78
+
79
+ // Originally Pods had 100m CPU, 100Mi of memory, but admission controller
80
+ // should change it to recommended 250m CPU and 200Mi of memory.
81
+ for _ , pod := range podList .Items {
82
+ gomega .Expect (pod .Spec .Containers [0 ].Resources .Requests [apiv1 .ResourceCPU ]).To (gomega .Equal (ParseQuantityOrDie ("250m" )))
83
+ gomega .Expect (pod .Spec .Containers [0 ].Resources .Requests [apiv1 .ResourceMemory ]).To (gomega .Equal (ParseQuantityOrDie ("200Mi" )))
84
+ }
85
+ })
86
+ })
87
+
45
88
var _ = AdmissionControllerE2eDescribe ("Admission-controller" , func () {
46
89
f := framework .NewDefaultFramework ("vertical-pod-autoscaling" )
47
90
f .NamespacePodSecurityEnforceLevel = podsecurity .LevelBaseline
@@ -916,41 +959,6 @@ var _ = AdmissionControllerE2eDescribe("Admission-controller", func() {
916
959
gomega .Expect (err ).To (gomega .HaveOccurred (), "Invalid VPA object accepted" )
917
960
gomega .Expect (err .Error ()).To (gomega .MatchRegexp (`.*admission webhook .*vpa.* denied the request: .*` ), "Admission controller did not inspect the object" )
918
961
})
919
-
920
- ginkgo .It ("starts pods with new recommended request with InPlaceOrRecreate mode" , func () {
921
- checkInPlaceOrRecreateTestsEnabled (f , true , false )
922
-
923
- d := NewHamsterDeploymentWithResources (f , ParseQuantityOrDie ("100m" ) /*cpu*/ , ParseQuantityOrDie ("100Mi" ) /*memory*/ )
924
-
925
- ginkgo .By ("Setting up a VPA CRD" )
926
- containerName := GetHamsterContainerNameByIndex (0 )
927
- vpaCRD := test .VerticalPodAutoscaler ().
928
- WithName ("hamster-vpa" ).
929
- WithNamespace (f .Namespace .Name ).
930
- WithTargetRef (hamsterTargetRef ).
931
- WithContainer (containerName ).
932
- WithUpdateMode (vpa_types .UpdateModeInPlaceOrRecreate ).
933
- AppendRecommendation (
934
- test .Recommendation ().
935
- WithContainer (containerName ).
936
- WithTarget ("250m" , "200Mi" ).
937
- WithLowerBound ("250m" , "200Mi" ).
938
- WithUpperBound ("250m" , "200Mi" ).
939
- GetContainerResources ()).
940
- Get ()
941
-
942
- InstallVPA (f , vpaCRD )
943
-
944
- ginkgo .By ("Setting up a hamster deployment" )
945
- podList := startDeploymentPods (f , d )
946
-
947
- // Originally Pods had 100m CPU, 100Mi of memory, but admission controller
948
- // should change it to recommended 250m CPU and 200Mi of memory.
949
- for _ , pod := range podList .Items {
950
- gomega .Expect (pod .Spec .Containers [0 ].Resources .Requests [apiv1 .ResourceCPU ]).To (gomega .Equal (ParseQuantityOrDie ("250m" )))
951
- gomega .Expect (pod .Spec .Containers [0 ].Resources .Requests [apiv1 .ResourceMemory ]).To (gomega .Equal (ParseQuantityOrDie ("200Mi" )))
952
- }
953
- })
954
962
})
955
963
956
964
func startDeploymentPods (f * framework.Framework , deployment * appsv1.Deployment ) * apiv1.PodList {
0 commit comments