@@ -17,7 +17,7 @@ import (
1717 "k8s.io/apimachinery/pkg/util/intstr"
1818)
1919
20- var _ = Describe ("CloudControllerManager " , func () {
20+ var _ = Describe ("e2e tests " , func () {
2121 var (
2222 err error
2323 f * framework.Invocation
@@ -82,6 +82,11 @@ var _ = Describe("CloudControllerManager", func() {
8282 Expect (err ).NotTo (HaveOccurred ())
8383 }
8484
85+ var updateServiceWithAnnotations = func (labels map [string ]string , annotations map [string ]string , ports []core.ServicePort , isSessionAffinityClientIP bool ) {
86+ err = f .LoadBalancer .UpdateService (labels , annotations , ports , isSessionAffinityClientIP )
87+ Expect (err ).NotTo (HaveOccurred ())
88+ }
89+
8590 var deleteNodeBalancer = func (id int ) {
8691 err = getLinodeClient ().DeleteNodeBalancer (context .Background (), id )
8792 Expect (err ).NotTo (HaveOccurred ())
@@ -453,6 +458,101 @@ var _ = Describe("CloudControllerManager", func() {
453458 })
454459 })
455460
461+ Context ("With HTTP updating to have HTTPS" , func () {
462+ var (
463+ pods []string
464+ labels map [string ]string
465+ annotations map [string ]string
466+ secretName string
467+ )
468+ BeforeEach (func () {
469+ pods = []string {"tls-pod" }
470+ secretName = "tls-secret-1"
471+ labels = map [string ]string {
472+ "app" : "test-loadbalancer" ,
473+ }
474+ annotations = map [string ]string {
475+ annLinodeDefaultProtocol : "https" ,
476+ annLinodePortConfigPrefix + "80" : `{"protocol": "http"}` ,
477+ }
478+ ports := []core.ContainerPort {
479+ {
480+ Name : "alpha" ,
481+ ContainerPort : 8080 ,
482+ },
483+ }
484+ servicePorts := []core.ServicePort {
485+ {
486+ Name : "http" ,
487+ Port : 80 ,
488+ TargetPort : intstr .FromInt (8080 ),
489+ Protocol : "TCP" ,
490+ },
491+ }
492+
493+ By ("Creating Pod" )
494+ createPodWithLabel (pods , ports , framework .TestServerImage , labels , false )
495+
496+ By ("Creating Service" )
497+ createServiceWithAnnotations (labels , annotations , servicePorts , false )
498+
499+ By ("Creating Secret" )
500+ err = f .LoadBalancer .CreateTLSSecret (secretName )
501+ Expect (err ).NotTo (HaveOccurred ())
502+
503+ By ("Updating the Service" )
504+ updateAnnotations := map [string ]string {
505+ annLinodeDefaultProtocol : "https" ,
506+ annLinodePortConfigPrefix + "80" : `{"protocol": "http"}` ,
507+ annLinodePortConfigPrefix + "443" : `{"tls-secret-name": "` + secretName + `", "protocol": "https"}` ,
508+ }
509+ updateServicePorts := []core.ServicePort {
510+ {
511+ Name : "http" ,
512+ Port : 80 ,
513+ TargetPort : intstr .FromInt (8080 ),
514+ Protocol : "TCP" ,
515+ },
516+ {
517+ Name : "https" ,
518+ Port : 443 ,
519+ TargetPort : intstr .FromInt (8080 ),
520+ Protocol : "TCP" ,
521+ },
522+ }
523+ updateServiceWithAnnotations (labels , updateAnnotations , updateServicePorts , false )
524+ })
525+
526+ AfterEach (func () {
527+ By ("Deleting the Secrets" )
528+ deletePods (pods )
529+
530+ By ("Deleting the Service" )
531+ deleteService ()
532+
533+ By ("Deleting the Secret" )
534+ deleteSecret (secretName )
535+ })
536+
537+ It ("should reach the pods" , func () {
538+ By ("Checking TCP Response" )
539+ eps , err := f .LoadBalancer .GetHTTPEndpoints ()
540+ Expect (err ).NotTo (HaveOccurred ())
541+ Expect (len (eps )).Should (BeNumerically ("==" , 2 ))
542+
543+ // in order of the spec
544+ http80 , https443 := eps [0 ], eps [1 ]
545+
546+ waitForResponse := func (endpoint string , fn func (string , string ) error ) {
547+ By ("Waiting for Response from the LoadBalancer url: " + endpoint )
548+ err := fn (endpoint , pods [0 ])
549+ Expect (err ).NotTo (HaveOccurred ())
550+ }
551+ waitForResponse (http80 , framework .WaitForHTTPResponse )
552+ waitForResponse (https443 , framework .WaitForHTTPSResponse )
553+ })
554+ })
555+
456556 Context ("With SessionAffinity" , func () {
457557 var (
458558 pods []string
0 commit comments