@@ -85,9 +85,10 @@ func BuildConfiguration(
8585 gateway ,
8686 serviceResolver ,
8787 g .ReferencedServices ,
88- baseHTTPConfig .IPFamily ),
88+ baseHTTPConfig .IPFamily ,
89+ ),
8990 BackendGroups : backendGroups ,
90- SSLKeyPairs : buildSSLKeyPairs (g .ReferencedSecrets , gateway . Listeners ),
91+ SSLKeyPairs : buildSSLKeyPairs (g .ReferencedSecrets , gateway ),
9192 CertBundles : buildCertBundles (
9293 buildRefCertificateBundles (g .ReferencedSecrets , g .ReferencedCaCertConfigMaps ),
9394 backendGroups ,
@@ -252,14 +253,14 @@ func buildStreamUpstreams(
252253}
253254
254255// buildSSLKeyPairs builds the SSLKeyPairs from the Secrets. It will only include Secrets that are referenced by
255- // valid listeners, so that we don't include unused Secrets in the configuration of the data plane.
256+ // valid gateway and its listeners, so that we don't include unused Secrets in the configuration of the data plane.
256257func buildSSLKeyPairs (
257258 secrets map [types.NamespacedName ]* graph.Secret ,
258- listeners [] * graph.Listener ,
259+ gateway * graph.Gateway ,
259260) map [SSLKeyPairID ]SSLKeyPair {
260261 keyPairs := make (map [SSLKeyPairID ]SSLKeyPair )
261262
262- for _ , l := range listeners {
263+ for _ , l := range gateway . Listeners {
263264 if l .Valid && l .ResolvedSecret != nil {
264265 id := generateSSLKeyPairID (* l .ResolvedSecret )
265266 secret := secrets [* l .ResolvedSecret ]
@@ -272,6 +273,15 @@ func buildSSLKeyPairs(
272273 }
273274 }
274275
276+ if gateway .Valid && gateway .SecretRef != nil {
277+ id := generateSSLKeyPairID (* gateway .SecretRef )
278+ secret := secrets [* gateway .SecretRef ]
279+ keyPairs [id ] = SSLKeyPair {
280+ Cert : secret .CertBundle .Cert .TLSCert ,
281+ Key : secret .CertBundle .Cert .TLSPrivateKey ,
282+ }
283+ }
284+
275285 return keyPairs
276286}
277287
@@ -1058,6 +1068,10 @@ func buildBaseHTTPConfig(
10581068 NginxReadinessProbePort : DefaultNginxReadinessProbePort ,
10591069 }
10601070
1071+ if gateway .Valid && gateway .SecretRef != nil {
1072+ baseConfig .GatewaySecretID = generateSSLKeyPairID (* gateway .SecretRef )
1073+ }
1074+
10611075 // safe to access EffectiveNginxProxy since we only call this function when the Gateway is not nil.
10621076 np := gateway .EffectiveNginxProxy
10631077 if np == nil {
@@ -1081,8 +1095,20 @@ func buildBaseHTTPConfig(
10811095 }
10821096 }
10831097
1098+ if port := getNginxReadinessProbePort (np ); port != 0 {
1099+ baseConfig .NginxReadinessProbePort = port
1100+ }
1101+
10841102 baseConfig .RewriteClientIPSettings = buildRewriteClientIPConfig (np .RewriteClientIP )
10851103
1104+ baseConfig .DNSResolver = buildDNSResolverConfig (np .DNSResolver )
1105+
1106+ return baseConfig
1107+ }
1108+
1109+ func getNginxReadinessProbePort (np * graph.EffectiveNginxProxy ) int32 {
1110+ var port int32
1111+
10861112 if np .Kubernetes != nil {
10871113 var containerSpec * ngfAPIv1alpha2.ContainerSpec
10881114 if np .Kubernetes .Deployment != nil {
@@ -1091,13 +1117,10 @@ func buildBaseHTTPConfig(
10911117 containerSpec = & np .Kubernetes .DaemonSet .Container
10921118 }
10931119 if containerSpec != nil && containerSpec .ReadinessProbe != nil && containerSpec .ReadinessProbe .Port != nil {
1094- baseConfig . NginxReadinessProbePort = * containerSpec .ReadinessProbe .Port
1120+ port = * containerSpec .ReadinessProbe .Port
10951121 }
10961122 }
1097-
1098- baseConfig .DNSResolver = buildDNSResolverConfig (np .DNSResolver )
1099-
1100- return baseConfig
1123+ return port
11011124}
11021125
11031126// buildBaseStreamConfig generates the base stream context config that should be applied to all stream servers.
0 commit comments