@@ -311,7 +311,6 @@ var _ = Describe("End to end TLS", func() {
311
311
ns := f .Namespace .Name
312
312
313
313
jig := framework .NewServiceTestJig (f .ClientSet , serviceName )
314
- //nodeIP := framework.PickNodeIP(jig.Client) // for later
315
314
316
315
sslSecretName := "ssl-certificate-secret"
317
316
_ , err := f .ClientSet .CoreV1 ().Secrets (ns ).Create (& v1.Secret {
@@ -327,7 +326,6 @@ var _ = Describe("End to end TLS", func() {
327
326
},
328
327
})
329
328
framework .ExpectNoError (err )
330
- //loadBalancerLagTimeout := framework.LoadBalancerLagTimeoutDefault
331
329
loadBalancerCreateTimeout := framework .LoadBalancerCreateTimeoutDefault
332
330
if nodes := framework .GetReadySchedulableNodesOrDie (f .ClientSet ); len (nodes .Items ) > framework .LargeClusterMinNodesNumber {
333
331
loadBalancerCreateTimeout = framework .LoadBalancerCreateTimeoutLarge
@@ -370,11 +368,87 @@ var _ = Describe("End to end TLS", func() {
370
368
tcpIngressIP := framework .GetIngressPoint (& tcpService .Status .LoadBalancer .Ingress [0 ])
371
369
framework .Logf ("TCP load balancer: %s" , tcpIngressIP )
372
370
373
- // By("hitting the TCP service's NodePort")
374
- // jig.TestReachableHTTP(true, nodeIP, tcpNodePort, framework.KubeProxyLagTimeout)
371
+ By ("changing TCP service back to type=ClusterIP" )
372
+ tcpService = jig .UpdateServiceOrFail (ns , tcpService .Name , func (s * v1.Service ) {
373
+ s .Spec .Type = v1 .ServiceTypeClusterIP
374
+ s .Spec .Ports [0 ].NodePort = 0
375
+ s .Spec .Ports [1 ].NodePort = 0
376
+ })
377
+
378
+ // Wait for the load balancer to be destroyed asynchronously
379
+ tcpService = jig .WaitForLoadBalancerDestroyOrFail (ns , tcpService .Name , tcpIngressIP , svcPort , loadBalancerCreateTimeout )
380
+ jig .SanityCheckService (tcpService , v1 .ServiceTypeClusterIP )
381
+
382
+ err = f .ClientSet .CoreV1 ().Secrets (ns ).Delete (sslSecretName , nil )
383
+ framework .ExpectNoError (err )
384
+ })
385
+ })
386
+
387
+ var _ = Describe ("End to end TLS" , func () {
388
+ f := framework .NewDefaultFramework ("service" )
389
+
390
+ It ("should be possible to create and mutate a Service type:LoadBalancer [Canary]" , func () {
391
+ serviceName := "e2e-tls-lb-test"
392
+ ns := f .Namespace .Name
375
393
376
- // By("hitting the TCP service's LoadBalancer")
377
- // jig.TestReachableHTTP(true, tcpIngressIP, svcPort, loadBalancerLagTimeout)
394
+ jig := framework .NewServiceTestJig (f .ClientSet , serviceName )
395
+ //nodeIP := framework.PickNodeIP(jig.Client) // for later
396
+
397
+ sslSecretName := "ssl-certificate-secret"
398
+ _ , err := f .ClientSet .CoreV1 ().Secrets (ns ).Create (& v1.Secret {
399
+ ObjectMeta : metav1.ObjectMeta {
400
+ Namespace : ns ,
401
+ Name : sslSecretName ,
402
+ },
403
+ Data : map [string ][]byte {
404
+ cloudprovider .SSLCAFileName : []byte (framework .SSLCAData ),
405
+ cloudprovider .SSLCertificateFileName : []byte (framework .SSLCertificateData ),
406
+ cloudprovider .SSLPrivateKeyFileName : []byte (framework .SSLPrivateData ),
407
+ cloudprovider .SSLPassphrase : []byte (framework .SSLPassphrase ),
408
+ },
409
+ })
410
+ framework .ExpectNoError (err )
411
+ //loadBalancerLagTimeout := framework.LoadBalancerLagTimeoutDefault
412
+ loadBalancerCreateTimeout := framework .LoadBalancerCreateTimeoutDefault
413
+ if nodes := framework .GetReadySchedulableNodesOrDie (f .ClientSet ); len (nodes .Items ) > framework .LargeClusterMinNodesNumber {
414
+ loadBalancerCreateTimeout = framework .LoadBalancerCreateTimeoutLarge
415
+ }
416
+
417
+ // TODO(apryde): Test that LoadBalancers can receive static IP addresses
418
+ // (in a provider agnostic manner?). OCI does not currently
419
+ // support this.
420
+ requestedIP := ""
421
+
422
+ tcpService := jig .CreateTCPServiceOrFail (ns , func (s * v1.Service ) {
423
+ s .Spec .Type = v1 .ServiceTypeLoadBalancer
424
+ s .Spec .LoadBalancerIP = requestedIP
425
+ s .Spec .Ports = []v1.ServicePort {v1.ServicePort {Name : "http" , Port : 80 , TargetPort : intstr .FromInt (80 )},
426
+ v1.ServicePort {Name : "https" , Port : 443 , TargetPort : intstr .FromInt (80 )}}
427
+ s .ObjectMeta .Annotations = map [string ]string {cloudprovider .ServiceAnnotationLoadBalancerSSLPorts : "443" ,
428
+ cloudprovider .ServiceAnnotationLoadBalancerBackendSetSecret : sslSecretName }
429
+
430
+ })
431
+
432
+ svcPort := int (tcpService .Spec .Ports [0 ].Port )
433
+
434
+ By ("creating a pod to be part of the TCP service " + serviceName )
435
+ jig .RunOrFail (ns , nil )
436
+
437
+ // TODO(apryde): Test UDP service. OCI does not currently support this.
438
+
439
+ By ("waiting for the TCP service to have a load balancer" )
440
+ // Wait for the load balancer to be created asynchronously
441
+ tcpService = jig .WaitForLoadBalancerOrFail (ns , tcpService .Name , loadBalancerCreateTimeout )
442
+ jig .SanityCheckService (tcpService , v1 .ServiceTypeLoadBalancer )
443
+
444
+ tcpNodePort := int (tcpService .Spec .Ports [0 ].NodePort )
445
+ framework .Logf ("TCP node port: %d" , tcpNodePort )
446
+
447
+ if requestedIP != "" && framework .GetIngressPoint (& tcpService .Status .LoadBalancer .Ingress [0 ]) != requestedIP {
448
+ framework .Failf ("unexpected TCP Status.LoadBalancer.Ingress (expected %s, got %s)" , requestedIP , framework .GetIngressPoint (& tcpService .Status .LoadBalancer .Ingress [0 ]))
449
+ }
450
+ tcpIngressIP := framework .GetIngressPoint (& tcpService .Status .LoadBalancer .Ingress [0 ])
451
+ framework .Logf ("TCP load balancer: %s" , tcpIngressIP )
378
452
379
453
By ("changing TCP service back to type=ClusterIP" )
380
454
tcpService = jig .UpdateServiceOrFail (ns , tcpService .Name , func (s * v1.Service ) {
@@ -387,11 +461,6 @@ var _ = Describe("End to end TLS", func() {
387
461
tcpService = jig .WaitForLoadBalancerDestroyOrFail (ns , tcpService .Name , tcpIngressIP , svcPort , loadBalancerCreateTimeout )
388
462
jig .SanityCheckService (tcpService , v1 .ServiceTypeClusterIP )
389
463
390
- // By("checking the TCP NodePort is closed")
391
- // jig.TestNotReachableHTTP(nodeIP, tcpNodePort, framework.KubeProxyLagTimeout)
392
-
393
- // By("checking the TCP LoadBalancer is closed")
394
- // jig.TestNotReachableHTTP(tcpIngressIP, svcPort, loadBalancerLagTimeout)
395
464
err = f .ClientSet .CoreV1 ().Secrets (ns ).Delete (sslSecretName , nil )
396
465
framework .ExpectNoError (err )
397
466
})
0 commit comments