@@ -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
@@ -1054,6 +1064,10 @@ func buildBaseHTTPConfig(
10541064 NginxReadinessProbePort : DefaultNginxReadinessProbePort ,
10551065 }
10561066
1067+ if gateway .Valid && gateway .SecretRef != nil {
1068+ baseConfig .GatewaySecretID = generateSSLKeyPairID (* gateway .SecretRef )
1069+ }
1070+
10571071 // safe to access EffectiveNginxProxy since we only call this function when the Gateway is not nil.
10581072 np := gateway .EffectiveNginxProxy
10591073 if np == nil {
@@ -1077,8 +1091,20 @@ func buildBaseHTTPConfig(
10771091 }
10781092 }
10791093
1094+ if port := getNginxReadinessProbePort (np ); port != 0 {
1095+ baseConfig .NginxReadinessProbePort = port
1096+ }
1097+
10801098 baseConfig .RewriteClientIPSettings = buildRewriteClientIPConfig (np .RewriteClientIP )
10811099
1100+ baseConfig .DNSResolver = buildDNSResolverConfig (np .DNSResolver )
1101+
1102+ return baseConfig
1103+ }
1104+
1105+ func getNginxReadinessProbePort (np * graph.EffectiveNginxProxy ) int32 {
1106+ var port int32
1107+
10821108 if np .Kubernetes != nil {
10831109 var containerSpec * ngfAPIv1alpha2.ContainerSpec
10841110 if np .Kubernetes .Deployment != nil {
@@ -1087,13 +1113,10 @@ func buildBaseHTTPConfig(
10871113 containerSpec = & np .Kubernetes .DaemonSet .Container
10881114 }
10891115 if containerSpec != nil && containerSpec .ReadinessProbe != nil && containerSpec .ReadinessProbe .Port != nil {
1090- baseConfig . NginxReadinessProbePort = * containerSpec .ReadinessProbe .Port
1116+ port = * containerSpec .ReadinessProbe .Port
10911117 }
10921118 }
1093-
1094- baseConfig .DNSResolver = buildDNSResolverConfig (np .DNSResolver )
1095-
1096- return baseConfig
1119+ return port
10971120}
10981121
10991122// buildBaseStreamConfig generates the base stream context config that should be applied to all stream servers.
0 commit comments