@@ -81,9 +81,10 @@ func BuildConfiguration(
8181 gateway ,
8282 serviceResolver ,
8383 g .ReferencedServices ,
84- baseHTTPConfig .IPFamily ),
84+ baseHTTPConfig .IPFamily ,
85+ ),
8586 BackendGroups : backendGroups ,
86- SSLKeyPairs : buildSSLKeyPairs (g .ReferencedSecrets , gateway . Listeners ),
87+ SSLKeyPairs : buildSSLKeyPairs (g .ReferencedSecrets , gateway ),
8788 CertBundles : buildCertBundles (
8889 buildRefCertificateBundles (g .ReferencedSecrets , g .ReferencedCaCertConfigMaps ),
8990 backendGroups ,
@@ -248,14 +249,14 @@ func buildStreamUpstreams(
248249}
249250
250251// 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.
252253func buildSSLKeyPairs (
253254 secrets map [types.NamespacedName ]* graph.Secret ,
254- listeners [] * graph.Listener ,
255+ gateway * graph.Gateway ,
255256) map [SSLKeyPairID ]SSLKeyPair {
256257 keyPairs := make (map [SSLKeyPairID ]SSLKeyPair )
257258
258- for _ , l := range listeners {
259+ for _ , l := range gateway . Listeners {
259260 if l .Valid && l .ResolvedSecret != nil {
260261 id := generateSSLKeyPairID (* l .ResolvedSecret )
261262 secret := secrets [* l .ResolvedSecret ]
@@ -268,6 +269,15 @@ func buildSSLKeyPairs(
268269 }
269270 }
270271
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+
271281 return keyPairs
272282}
273283
@@ -1019,6 +1029,10 @@ func buildBaseHTTPConfig(
10191029 NginxReadinessProbePort : DefaultNginxReadinessProbePort ,
10201030 }
10211031
1032+ if gateway .Valid && gateway .SecretRef != nil {
1033+ baseConfig .GatewaySecretID = generateSSLKeyPairID (* gateway .SecretRef )
1034+ }
1035+
10221036 // safe to access EffectiveNginxProxy since we only call this function when the Gateway is not nil.
10231037 np := gateway .EffectiveNginxProxy
10241038 if np == nil {
@@ -1042,8 +1056,20 @@ func buildBaseHTTPConfig(
10421056 }
10431057 }
10441058
1059+ if port := getNginxReadinessProbePort (np ); port != 0 {
1060+ baseConfig .NginxReadinessProbePort = port
1061+ }
1062+
10451063 baseConfig .RewriteClientIPSettings = buildRewriteClientIPConfig (np .RewriteClientIP )
10461064
1065+ baseConfig .DNSResolver = buildDNSResolverConfig (np .DNSResolver )
1066+
1067+ return baseConfig
1068+ }
1069+
1070+ func getNginxReadinessProbePort (np * graph.EffectiveNginxProxy ) int32 {
1071+ var port int32
1072+
10471073 if np .Kubernetes != nil {
10481074 var containerSpec * ngfAPIv1alpha2.ContainerSpec
10491075 if np .Kubernetes .Deployment != nil {
@@ -1052,13 +1078,10 @@ func buildBaseHTTPConfig(
10521078 containerSpec = & np .Kubernetes .DaemonSet .Container
10531079 }
10541080 if containerSpec != nil && containerSpec .ReadinessProbe != nil && containerSpec .ReadinessProbe .Port != nil {
1055- baseConfig . NginxReadinessProbePort = * containerSpec .ReadinessProbe .Port
1081+ port = * containerSpec .ReadinessProbe .Port
10561082 }
10571083 }
1058-
1059- baseConfig .DNSResolver = buildDNSResolverConfig (np .DNSResolver )
1060-
1061- return baseConfig
1084+ return port
10621085}
10631086
10641087// buildBaseStreamConfig generates the base stream context config that should be applied to all stream servers.
0 commit comments