@@ -81,9 +81,10 @@ func BuildConfiguration(
81
81
gateway ,
82
82
serviceResolver ,
83
83
g .ReferencedServices ,
84
- baseHTTPConfig .IPFamily ),
84
+ baseHTTPConfig .IPFamily ,
85
+ ),
85
86
BackendGroups : backendGroups ,
86
- SSLKeyPairs : buildSSLKeyPairs (g .ReferencedSecrets , gateway . Listeners ),
87
+ SSLKeyPairs : buildSSLKeyPairs (g .ReferencedSecrets , gateway ),
87
88
CertBundles : buildCertBundles (
88
89
buildRefCertificateBundles (g .ReferencedSecrets , g .ReferencedCaCertConfigMaps ),
89
90
backendGroups ,
@@ -248,14 +249,14 @@ func buildStreamUpstreams(
248
249
}
249
250
250
251
// buildSSLKeyPairs builds the SSLKeyPairs from the Secrets. It will only include Secrets that are referenced by
251
- // valid listeners, so that we don't include unused Secrets in the configuration of the data plane.
252
+ // valid gateway and its listeners, so that we don't include unused Secrets in the configuration of the data plane.
252
253
func buildSSLKeyPairs (
253
254
secrets map [types.NamespacedName ]* graph.Secret ,
254
- listeners [] * graph.Listener ,
255
+ gateway * graph.Gateway ,
255
256
) map [SSLKeyPairID ]SSLKeyPair {
256
257
keyPairs := make (map [SSLKeyPairID ]SSLKeyPair )
257
258
258
- for _ , l := range listeners {
259
+ for _ , l := range gateway . Listeners {
259
260
if l .Valid && l .ResolvedSecret != nil {
260
261
id := generateSSLKeyPairID (* l .ResolvedSecret )
261
262
secret := secrets [* l .ResolvedSecret ]
@@ -268,6 +269,15 @@ func buildSSLKeyPairs(
268
269
}
269
270
}
270
271
272
+ if gateway .Valid && gateway .SecretRef != nil {
273
+ id := generateSSLKeyPairID (* gateway .SecretRef )
274
+ secret := secrets [* gateway .SecretRef ]
275
+ keyPairs [id ] = SSLKeyPair {
276
+ Cert : secret .CertBundle .Cert .TLSCert ,
277
+ Key : secret .CertBundle .Cert .TLSPrivateKey ,
278
+ }
279
+ }
280
+
271
281
return keyPairs
272
282
}
273
283
@@ -1019,6 +1029,10 @@ func buildBaseHTTPConfig(
1019
1029
NginxReadinessProbePort : DefaultNginxReadinessProbePort ,
1020
1030
}
1021
1031
1032
+ if gateway .Valid && gateway .SecretRef != nil {
1033
+ baseConfig .GatewaySecretID = generateSSLKeyPairID (* gateway .SecretRef )
1034
+ }
1035
+
1022
1036
// safe to access EffectiveNginxProxy since we only call this function when the Gateway is not nil.
1023
1037
np := gateway .EffectiveNginxProxy
1024
1038
if np == nil {
@@ -1042,8 +1056,20 @@ func buildBaseHTTPConfig(
1042
1056
}
1043
1057
}
1044
1058
1059
+ if port := getNginxReadinessProbePort (np ); port != 0 {
1060
+ baseConfig .NginxReadinessProbePort = port
1061
+ }
1062
+
1045
1063
baseConfig .RewriteClientIPSettings = buildRewriteClientIPConfig (np .RewriteClientIP )
1046
1064
1065
+ baseConfig .DNSResolver = buildDNSResolverConfig (np .DNSResolver )
1066
+
1067
+ return baseConfig
1068
+ }
1069
+
1070
+ func getNginxReadinessProbePort (np * graph.EffectiveNginxProxy ) int32 {
1071
+ var port int32
1072
+
1047
1073
if np .Kubernetes != nil {
1048
1074
var containerSpec * ngfAPIv1alpha2.ContainerSpec
1049
1075
if np .Kubernetes .Deployment != nil {
@@ -1052,13 +1078,10 @@ func buildBaseHTTPConfig(
1052
1078
containerSpec = & np .Kubernetes .DaemonSet .Container
1053
1079
}
1054
1080
if containerSpec != nil && containerSpec .ReadinessProbe != nil && containerSpec .ReadinessProbe .Port != nil {
1055
- baseConfig . NginxReadinessProbePort = * containerSpec .ReadinessProbe .Port
1081
+ port = * containerSpec .ReadinessProbe .Port
1056
1082
}
1057
1083
}
1058
-
1059
- baseConfig .DNSResolver = buildDNSResolverConfig (np .DNSResolver )
1060
-
1061
- return baseConfig
1084
+ return port
1062
1085
}
1063
1086
1064
1087
// buildBaseStreamConfig generates the base stream context config that should be applied to all stream servers.
0 commit comments