@@ -70,7 +70,52 @@ var _ = Describe("vanilla ingress tests", func() {
7070 })
7171
7272 Context ("with basic settings" , func () {
73- It ("[ingress-class] with IngressClass configured with 'ingress.k8s.aws/alb' controller, one ALB shall be created and functional" , func () {
73+ It ("[ingress-class] in IP mode, with IngressClass configured with 'ingress.k8s.aws/alb' controller, one ALB shall be created and functional" , func () {
74+ appBuilder := manifest .NewFixedResponseServiceBuilder ()
75+ ingBuilder := manifest .NewIngressBuilder ()
76+ dp , svc := appBuilder .Build (sandboxNS .Name , "app" , tf .Options .TestImageRegistry )
77+ ingBackend := networking.IngressBackend {
78+ Service : & networking.IngressServiceBackend {
79+ Name : svc .Name ,
80+ Port : networking.ServiceBackendPort {
81+ Number : 80 ,
82+ },
83+ },
84+ }
85+ ingClass := & networking.IngressClass {
86+ ObjectMeta : metav1.ObjectMeta {
87+ Name : sandboxNS .Name ,
88+ },
89+ Spec : networking.IngressClassSpec {
90+ Controller : "ingress.k8s.aws/alb" ,
91+ },
92+ }
93+ annotation := map [string ]string {
94+ "alb.ingress.kubernetes.io/scheme" : "internet-facing" ,
95+ "alb.ingress.kubernetes.io/target-type" : "ip" ,
96+ }
97+ if tf .Options .IPFamily == "IPv6" {
98+ annotation ["alb.ingress.kubernetes.io/ip-address-type" ] = "dualstack"
99+ }
100+ ing := ingBuilder .
101+ AddHTTPRoute ("" , networking.HTTPIngressPath {Path : "/path" , PathType : & exact , Backend : ingBackend }).
102+ WithIngressClassName (ingClass .Name ).
103+ WithAnnotations (annotation ).Build (sandboxNS .Name , "ing" )
104+ resStack := fixture .NewK8SResourceStack (tf , dp , svc , ingClass , ing )
105+ err := resStack .Setup (ctx )
106+ Expect (err ).NotTo (HaveOccurred ())
107+
108+ defer resStack .TearDown (ctx )
109+
110+ lbARN , lbDNS := ExpectOneLBProvisionedForIngress (ctx , tf , ing )
111+ // test traffic
112+ ExpectLBDNSBeAvailable (ctx , tf , lbARN , lbDNS )
113+ httpExp := httpexpect .New (tf .LoggerReporter , fmt .Sprintf ("http://%v" , lbDNS ))
114+ httpExp .GET ("/path" ).Expect ().
115+ Status (http .StatusOK ).
116+ Body ().Equal ("Hello World!" )
117+ })
118+ It ("[ingress-class] in Instance mode, with IngressClass configured with 'ingress.k8s.aws/alb' controller, one ALB shall be created and functional" , func () {
74119 appBuilder := manifest .NewFixedResponseServiceBuilder ()
75120 ingBuilder := manifest .NewIngressBuilder ()
76121 dp , svc := appBuilder .Build (sandboxNS .Name , "app" , tf .Options .TestImageRegistry )
@@ -95,7 +140,6 @@ var _ = Describe("vanilla ingress tests", func() {
95140 }
96141 if tf .Options .IPFamily == "IPv6" {
97142 annotation ["alb.ingress.kubernetes.io/ip-address-type" ] = "dualstack"
98- annotation ["alb.ingress.kubernetes.io/target-type" ] = "ip"
99143 }
100144 ing := ingBuilder .
101145 AddHTTPRoute ("" , networking.HTTPIngressPath {Path : "/path" , PathType : & exact , Backend : ingBackend }).
@@ -116,7 +160,44 @@ var _ = Describe("vanilla ingress tests", func() {
116160 Body ().Equal ("Hello World!" )
117161 })
118162
119- It ("with 'kubernetes.io/ingress.class' annotation set to 'alb', one ALB shall be created and functional" , func () {
163+ It ("ingress in IP mode, with 'kubernetes.io/ingress.class' annotation set to 'alb', one ALB shall be created and functional" , func () {
164+ appBuilder := manifest .NewFixedResponseServiceBuilder ()
165+ ingBuilder := manifest .NewIngressBuilder ()
166+ dp , svc := appBuilder .Build (sandboxNS .Name , "app" , tf .Options .TestImageRegistry )
167+ ingBackend := networking.IngressBackend {
168+ Service : & networking.IngressServiceBackend {
169+ Name : svc .Name ,
170+ Port : networking.ServiceBackendPort {
171+ Number : 80 ,
172+ },
173+ },
174+ }
175+ annotation := map [string ]string {
176+ "kubernetes.io/ingress.class" : "alb" ,
177+ "alb.ingress.kubernetes.io/scheme" : "internet-facing" ,
178+ "alb.ingress.kubernetes.io/target-type" : "ip" ,
179+ }
180+ if tf .Options .IPFamily == "IPv6" {
181+ annotation ["alb.ingress.kubernetes.io/ip-address-type" ] = "dualstack"
182+ }
183+ ing := ingBuilder .
184+ AddHTTPRoute ("" , networking.HTTPIngressPath {Path : "/path" , PathType : & exact , Backend : ingBackend }).
185+ WithAnnotations (annotation ).Build (sandboxNS .Name , "ing" )
186+ resStack := fixture .NewK8SResourceStack (tf , dp , svc , ing )
187+ err := resStack .Setup (ctx )
188+ Expect (err ).NotTo (HaveOccurred ())
189+
190+ defer resStack .TearDown (ctx )
191+
192+ lbARN , lbDNS := ExpectOneLBProvisionedForIngress (ctx , tf , ing )
193+ // test traffic
194+ ExpectLBDNSBeAvailable (ctx , tf , lbARN , lbDNS )
195+ httpExp := httpexpect .New (tf .LoggerReporter , fmt .Sprintf ("http://%v" , lbDNS ))
196+ httpExp .GET ("/path" ).Expect ().
197+ Status (http .StatusOK ).
198+ Body ().Equal ("Hello World!" )
199+ })
200+ It ("ingress in Instance mode, with 'kubernetes.io/ingress.class' annotation set to 'alb', one ALB shall be created and functional" , func () {
120201 appBuilder := manifest .NewFixedResponseServiceBuilder ()
121202 ingBuilder := manifest .NewIngressBuilder ()
122203 dp , svc := appBuilder .Build (sandboxNS .Name , "app" , tf .Options .TestImageRegistry )
@@ -134,7 +215,6 @@ var _ = Describe("vanilla ingress tests", func() {
134215 }
135216 if tf .Options .IPFamily == "IPv6" {
136217 annotation ["alb.ingress.kubernetes.io/ip-address-type" ] = "dualstack"
137- annotation ["alb.ingress.kubernetes.io/target-type" ] = "ip"
138218 }
139219 ing := ingBuilder .
140220 AddHTTPRoute ("" , networking.HTTPIngressPath {Path : "/path" , PathType : & exact , Backend : ingBackend }).
0 commit comments