@@ -170,6 +170,12 @@ const (
170170 // ingress / egress security rules for a given kubernetes service could be either LB or NLB
171171 ServiceAnnotationBackendSecurityRuleManagement = "oci.oraclecloud.com/oci-backend-network-security-group"
172172
173+ // ServiceAnnotationLoadbalancerListenerSSLConfig is a service annotation allows you to set the cipher suite on the listener
174+ ServiceAnnotationLoadbalancerListenerSSLConfig = "oci.oraclecloud.com/oci-load-balancer-listener-ssl-config"
175+
176+ // ServiceAnnotationLoadbalancerBackendSetSSLConfig is a service annotation allows you to set the cipher suite on the backendSet
177+ ServiceAnnotationLoadbalancerBackendSetSSLConfig = "oci.oraclecloud.com/oci-load-balancer-backendset-ssl-config"
178+
173179 // ServiceAnnotationIngressIpMode is a service annotation allows you to set the ".status.loadBalancer.ingress.ipMode" for a Service
174180 // with type set to LoadBalancer.
175181 // https://kubernetes.io/docs/concepts/services-networking/service/#load-balancer-ip-mode:~:text=Specifying%20IPMode%20of%20load%20balancer%20status
@@ -771,8 +777,14 @@ func getBackendSets(logger *zap.SugaredLogger, svc *v1.Service, provisionedNodes
771777
772778 for backendSetName , servicePort := range getBackendSetNamePortMap (svc ) {
773779 var secretName string
774- if sslCfg != nil && len (sslCfg .BackendSetSSLSecretName ) != 0 {
780+ var sslConfiguration * client.GenericSslConfigurationDetails
781+ if sslCfg != nil && len (sslCfg .BackendSetSSLSecretName ) != 0 && getLoadBalancerType (svc ) == LB {
775782 secretName = sslCfg .BackendSetSSLSecretName
783+ backendSetSSLConfig , _ := svc .Annotations [ServiceAnnotationLoadbalancerBackendSetSSLConfig ]
784+ sslConfiguration , err = getSSLConfiguration (sslCfg , secretName , int (servicePort .Port ), backendSetSSLConfig )
785+ if err != nil {
786+ return nil , err
787+ }
776788 }
777789 healthChecker , err := getHealthChecker (svc )
778790 if err != nil {
@@ -785,7 +797,7 @@ func getBackendSets(logger *zap.SugaredLogger, svc *v1.Service, provisionedNodes
785797 Policy : & loadbalancerPolicy ,
786798 HealthChecker : healthChecker ,
787799 IsPreserveSource : & isPreserveSource ,
788- SslConfiguration : getSSLConfiguration ( sslCfg , secretName , int ( servicePort . Port )) ,
800+ SslConfiguration : sslConfiguration ,
789801 }
790802
791803 if strings .Contains (backendSetName , IPv6 ) && contains (listenerBackendIpVersion , IPv6 ) {
@@ -945,18 +957,39 @@ func getHealthCheckTimeout(svc *v1.Service) (int, error) {
945957 }
946958 return timeoutInMillis , nil
947959}
948- func GetSSLConfiguration (cfg * SSLConfig , name string , port int ) * client.GenericSslConfigurationDetails {
949- return getSSLConfiguration (cfg , name , port )
960+
961+ func GetSSLConfiguration (cfg * SSLConfig , name string , port int , sslConfigAnnotation string ) (* client.GenericSslConfigurationDetails , error ) {
962+ sslConfig , err := getSSLConfiguration (cfg , name , port , sslConfigAnnotation )
963+ if err != nil {
964+ return nil , err
965+ }
966+ return sslConfig , nil
950967}
951- func getSSLConfiguration (cfg * SSLConfig , name string , port int ) * client.GenericSslConfigurationDetails {
968+
969+ func getSSLConfiguration (cfg * SSLConfig , name string , port int , lbSslConfigurationAnnotation string ) (* client.GenericSslConfigurationDetails , error ) {
952970 if cfg == nil || ! cfg .Ports .Has (port ) || len (name ) == 0 {
953- return nil
971+ return nil , nil
972+ }
973+ // TODO: fast-follow to pass the sslconfiguration object directly to loadbalancer
974+ var extractCipherSuite * client.GenericSslConfigurationDetails
975+
976+ if lbSslConfigurationAnnotation != "" {
977+ err := json .Unmarshal ([]byte (lbSslConfigurationAnnotation ), & extractCipherSuite )
978+ if err != nil {
979+ return nil , errors .Wrap (err , "failed to parse SSL Configuration annotation" )
980+ }
954981 }
955- return & client.GenericSslConfigurationDetails {
982+ genericSSLConfigurationDetails := & client.GenericSslConfigurationDetails {
956983 CertificateName : & name ,
957984 VerifyDepth : common .Int (0 ),
958985 VerifyPeerCertificate : common .Bool (false ),
959986 }
987+ if extractCipherSuite != nil {
988+ genericSSLConfigurationDetails .CipherSuiteName = extractCipherSuite .CipherSuiteName
989+ genericSSLConfigurationDetails .Protocols = extractCipherSuite .Protocols
990+ }
991+
992+ return genericSSLConfigurationDetails , nil
960993}
961994
962995func getListenersOciLoadBalancer (svc * v1.Service , sslCfg * SSLConfig ) (map [string ]client.GenericListener , error ) {
@@ -1006,11 +1039,18 @@ func getListenersOciLoadBalancer(svc *v1.Service, sslCfg *SSLConfig) (map[string
10061039 }
10071040 }
10081041 port := int (servicePort .Port )
1042+
10091043 var secretName string
1044+ var err error
1045+ var sslConfiguration * client.GenericSslConfigurationDetails
10101046 if sslCfg != nil && len (sslCfg .ListenerSSLSecretName ) != 0 {
10111047 secretName = sslCfg .ListenerSSLSecretName
1048+ listenerCipherSuiteAnnotation , _ := svc .Annotations [ServiceAnnotationLoadbalancerListenerSSLConfig ]
1049+ sslConfiguration , err = getSSLConfiguration (sslCfg , secretName , port , listenerCipherSuiteAnnotation )
1050+ if err != nil {
1051+ return nil , err
1052+ }
10121053 }
1013- sslConfiguration := getSSLConfiguration (sslCfg , secretName , port )
10141054 name := getListenerName (protocol , port )
10151055
10161056 listener := client.GenericListener {
0 commit comments