@@ -93,26 +93,59 @@ var _ = g.Describe("[sig-cloud-provider][Feature:OpenShiftCloudControllerManager
9393 )))
9494 })
9595
96- g .It ("Cluster scoped load balancer healthcheck port and path should be 10256/healthz" , func () {
96+ g .It ("Load balancer healthcheck port and path should be 10256/healthz" , func () {
9797 exutil .SkipIfNotPlatform (oc , "AWS" )
9898 if strings .HasPrefix (exutil .GetClusterRegion (oc ), "us-iso" ) {
9999 g .Skip ("Skipped: There is no public subnet on AWS C2S/SC2S disconnected clusters!" )
100100 }
101101
102- g .By ("Create a cluster scope load balancer" )
102+ infra , err := oc .WithoutNamespace ().AdminConfigClient ().ConfigV1 ().Infrastructures ().Get (context .Background (), "cluster" , metav1.GetOptions {})
103+ o .Expect (err ).NotTo (o .HaveOccurred ())
104+ o .Expect (infra .Status .PlatformStatus ).NotTo (o .BeNil (), "infrastructure platformStatus is required" )
105+
106+ isIPv6Primary := infra .Status .PlatformStatus .AWS != nil &&
107+ infra .Status .PlatformStatus .AWS .IPFamily == configv1 .DualStackIPv6Primary
108+
109+ g .By ("Creating a service with type=load balancer" )
110+ oc .SetNamespace (cloudControllerNamespace )
103111 svcName := "test-lb"
104- defer oc .WithoutNamespace ().AsAdmin ().Run ("delete" ).Args ("-n" , oc .Namespace (), "service" , "loadbalancer" , svcName , "--ignore-not-found" ).Execute ()
105- out , err := oc .AsAdmin ().WithoutNamespace ().Run ("create" ).Args ("-n" , oc .Namespace (), "service" , "loadbalancer" , svcName , "--tcp=80:8080" ).Output ()
106- o .Expect (err ).NotTo (o .HaveOccurred (), "failed to create lb service" )
107- o .Expect (out ).To (o .ContainSubstring ("service/" + svcName + " created" ))
112+ defer oc .AsAdmin ().Run ("delete" ).Args ("service" , svcName , "--ignore-not-found" ).Execute ()
113+ if isIPv6Primary {
114+ // IPv6 cannot be single stack on AWS, but kube will default an empty spec.ipFamilyPolicy to SingleStack.
115+ // Therefore, we must make sure that the ipFamilyPolicy field is set to PreferDualStack or RequireDualStack
116+ // the stricter RequireDualStack enforces that all Kube components have both IP families.
117+ // It must also be a Network Load Balancer; not specifying will create a Classic Elastic Load Balancer, which does not support IPv6
118+ svcYAML := fmt .Sprintf (`apiVersion: v1
119+ kind: Service
120+ metadata:
121+ name: %s
122+ namespace: %s
123+ annotations:
124+ service.beta.kubernetes.io/aws-load-balancer-type: nlb
125+ spec:
126+ type: LoadBalancer
127+ ipFamilyPolicy: RequireDualStack
128+ ports:
129+ - port: 80
130+ targetPort: 8080
131+ protocol: TCP
132+ ` , svcName , cloudControllerNamespace )
133+ err = oc .AsAdmin ().Run ("create" ).Args ("-f" , "-" ).InputString (svcYAML ).Execute ()
134+ o .Expect (err ).NotTo (o .HaveOccurred (), "failed to create lb service" )
135+ } else {
136+ // single stack or IPv4 primary
137+ out , err := oc .AsAdmin ().Run ("create" ).Args ("service" , "loadbalancer" , svcName , "--tcp=80:8080" ).Output ()
138+ o .Expect (err ).NotTo (o .HaveOccurred (), "failed to create lb service" )
139+ o .Expect (out ).To (o .ContainSubstring ("service/" + svcName + " created" ))
140+ }
108141
109- g .By ("Check External- IP assigned" )
142+ g .By ("Checking External IP assigned" )
110143 svcExternalIP := getLoadBalancerExternalIP (oc , oc .Namespace (), svcName )
111144 e2e .Logf ("External IP assigned: %s" , svcExternalIP )
112145 o .Expect (svcExternalIP ).NotTo (o .BeEmpty (), "externalIP should not be empty" )
113146 lbName := strings .Split (svcExternalIP , "-" )[0 ]
114147
115- g .By ("Check healthcheck port and path should be 10256/healthz" )
148+ g .By ("Checking healthcheck port and path should be 10256/healthz" )
116149 healthCheckPort := "10256"
117150 healthCheckPath := "/healthz"
118151 exutil .GetAwsCredentialFromCluster (oc )
0 commit comments