@@ -170,6 +170,12 @@ const (
170
170
// ingress / egress security rules for a given kubernetes service could be either LB or NLB
171
171
ServiceAnnotationBackendSecurityRuleManagement = "oci.oraclecloud.com/oci-backend-network-security-group"
172
172
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
+
173
179
// ServiceAnnotationIngressIpMode is a service annotation allows you to set the ".status.loadBalancer.ingress.ipMode" for a Service
174
180
// with type set to LoadBalancer.
175
181
// 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
771
777
772
778
for backendSetName , servicePort := range getBackendSetNamePortMap (svc ) {
773
779
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 {
775
782
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
+ }
776
788
}
777
789
healthChecker , err := getHealthChecker (svc )
778
790
if err != nil {
@@ -785,7 +797,7 @@ func getBackendSets(logger *zap.SugaredLogger, svc *v1.Service, provisionedNodes
785
797
Policy : & loadbalancerPolicy ,
786
798
HealthChecker : healthChecker ,
787
799
IsPreserveSource : & isPreserveSource ,
788
- SslConfiguration : getSSLConfiguration ( sslCfg , secretName , int ( servicePort . Port )) ,
800
+ SslConfiguration : sslConfiguration ,
789
801
}
790
802
791
803
if strings .Contains (backendSetName , IPv6 ) && contains (listenerBackendIpVersion , IPv6 ) {
@@ -945,18 +957,39 @@ func getHealthCheckTimeout(svc *v1.Service) (int, error) {
945
957
}
946
958
return timeoutInMillis , nil
947
959
}
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
950
967
}
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 ) {
952
970
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
+ }
954
981
}
955
- return & client.GenericSslConfigurationDetails {
982
+ genericSSLConfigurationDetails := & client.GenericSslConfigurationDetails {
956
983
CertificateName : & name ,
957
984
VerifyDepth : common .Int (0 ),
958
985
VerifyPeerCertificate : common .Bool (false ),
959
986
}
987
+ if extractCipherSuite != nil {
988
+ genericSSLConfigurationDetails .CipherSuiteName = extractCipherSuite .CipherSuiteName
989
+ genericSSLConfigurationDetails .Protocols = extractCipherSuite .Protocols
990
+ }
991
+
992
+ return genericSSLConfigurationDetails , nil
960
993
}
961
994
962
995
func getListenersOciLoadBalancer (svc * v1.Service , sslCfg * SSLConfig ) (map [string ]client.GenericListener , error ) {
@@ -1006,11 +1039,18 @@ func getListenersOciLoadBalancer(svc *v1.Service, sslCfg *SSLConfig) (map[string
1006
1039
}
1007
1040
}
1008
1041
port := int (servicePort .Port )
1042
+
1009
1043
var secretName string
1044
+ var err error
1045
+ var sslConfiguration * client.GenericSslConfigurationDetails
1010
1046
if sslCfg != nil && len (sslCfg .ListenerSSLSecretName ) != 0 {
1011
1047
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
+ }
1012
1053
}
1013
- sslConfiguration := getSSLConfiguration (sslCfg , secretName , port )
1014
1054
name := getListenerName (protocol , port )
1015
1055
1016
1056
listener := client.GenericListener {
0 commit comments