@@ -82,7 +82,7 @@ func enablePrometheus(infra *ir.ProxyInfra) bool {
82
82
func expectedProxyContainers (infra * ir.ProxyInfra ,
83
83
containerSpec * egv1a1.KubernetesContainerSpec ,
84
84
shutdownConfig * egv1a1.ShutdownConfig , shutdownManager * egv1a1.ShutdownManager ,
85
- namespace string , dnsDomain string , gatewayNamespaceMode bool ,
85
+ egNamespace string , dnsDomain string , gatewayNamespaceMode bool ,
86
86
) ([]corev1.Container , error ) {
87
87
ports := make ([]corev1.ContainerPort , 0 , 2 )
88
88
if enablePrometheus (infra ) {
@@ -107,6 +107,9 @@ func expectedProxyContainers(infra *ir.ProxyInfra,
107
107
108
108
maxHeapSizeBytes := calculateMaxHeapSizeBytes (containerSpec .Resources )
109
109
110
+ if gatewayNamespaceMode {
111
+ egNamespace = config .DefaultNamespace
112
+ }
110
113
// Get the default Bootstrap
111
114
bootstrapConfigOptions := & bootstrap.RenderBootstrapConfigOptions {
112
115
ProxyMetrics : proxyMetrics ,
@@ -115,7 +118,7 @@ func expectedProxyContainers(infra *ir.ProxyInfra,
115
118
TrustedCA : filepath .Join ("/sds" , common .SdsCAFilename ),
116
119
},
117
120
MaxHeapSizeBytes : maxHeapSizeBytes ,
118
- XdsServerHost : ptr .To (fmt .Sprintf ("%s.%s.svc.%s" , config .EnvoyGatewayServiceName , namespace , dnsDomain )),
121
+ XdsServerHost : ptr .To (fmt .Sprintf ("%s.%s.svc.%s" , config .EnvoyGatewayServiceName , egNamespace , dnsDomain )),
119
122
}
120
123
121
124
args , err := common .BuildProxyArgs (infra , shutdownConfig , bootstrapConfigOptions , fmt .Sprintf ("$(%s)" , envoyPodEnvVar ), gatewayNamespaceMode )
@@ -130,7 +133,7 @@ func expectedProxyContainers(infra *ir.ProxyInfra,
130
133
ImagePullPolicy : corev1 .PullIfNotPresent ,
131
134
Command : []string {"envoy" },
132
135
Args : args ,
133
- Env : expectedContainerEnv (containerSpec ),
136
+ Env : expectedContainerEnv (containerSpec , egNamespace ),
134
137
Resources : * containerSpec .Resources ,
135
138
SecurityContext : expectedEnvoySecurityContext (containerSpec ),
136
139
Ports : ports ,
@@ -192,7 +195,7 @@ func expectedProxyContainers(infra *ir.ProxyInfra,
192
195
ImagePullPolicy : corev1 .PullIfNotPresent ,
193
196
Command : []string {"envoy-gateway" },
194
197
Args : expectedShutdownManagerArgs (shutdownConfig ),
195
- Env : expectedContainerEnv (nil ),
198
+ Env : expectedContainerEnv (nil , egNamespace ),
196
199
Resources : * egv1a1 .DefaultShutdownManagerContainerResourceRequirements (),
197
200
TerminationMessagePolicy : corev1 .TerminationMessageReadFile ,
198
201
TerminationMessagePath : "/dev/termination-log" ,
@@ -285,14 +288,14 @@ func expectedShutdownPreStopCommand(cfg *egv1a1.ShutdownConfig) []string {
285
288
// expectedContainerVolumeMounts returns expected proxy container volume mounts.
286
289
func expectedContainerVolumeMounts (gatewayNamespacedMode bool , containerSpec * egv1a1.KubernetesContainerSpec ) []corev1.VolumeMount {
287
290
var volumeMounts []corev1.VolumeMount
288
- if ! gatewayNamespacedMode {
289
- certsMount := corev1.VolumeMount {
290
- Name : "certs" ,
291
- MountPath : "/certs" ,
292
- ReadOnly : true ,
293
- }
294
- volumeMounts = append (volumeMounts , certsMount )
291
+
292
+ certsMount := corev1.VolumeMount {
293
+ Name : "certs" ,
294
+ MountPath : "/certs" ,
295
+ ReadOnly : true ,
295
296
}
297
+ volumeMounts = append (volumeMounts , certsMount )
298
+
296
299
sdsMount := corev1.VolumeMount {
297
300
Name : "sds" ,
298
301
MountPath : "/sds" ,
@@ -305,20 +308,39 @@ func expectedContainerVolumeMounts(gatewayNamespacedMode bool, containerSpec *eg
305
308
// expectedVolumes returns expected proxy deployment volumes.
306
309
func expectedVolumes (name string , gatewayNamespacedMode bool , pod * egv1a1.KubernetesPodSpec ) []corev1.Volume {
307
310
var volumes []corev1.Volume
311
+ certsVolume := corev1.Volume {
312
+ Name : "certs" ,
313
+ VolumeSource : corev1.VolumeSource {
314
+ Secret : & corev1.SecretVolumeSource {
315
+ SecretName : "envoy" ,
316
+ DefaultMode : ptr.To [int32 ](420 ),
317
+ },
318
+ },
319
+ }
308
320
309
- if ! gatewayNamespacedMode {
310
- certsVolume : = corev1.Volume {
321
+ if gatewayNamespacedMode {
322
+ certsVolume = corev1.Volume {
311
323
Name : "certs" ,
312
324
VolumeSource : corev1.VolumeSource {
313
- Secret : & corev1.SecretVolumeSource {
314
- SecretName : "envoy" ,
325
+ ConfigMap : & corev1.ConfigMapVolumeSource {
326
+ LocalObjectReference : corev1.LocalObjectReference {
327
+ Name : ExpectedResourceHashedName (name ),
328
+ },
329
+ Items : []corev1.KeyToPath {
330
+ {
331
+ Key : XdsTLSCaFileName ,
332
+ Path : XdsTLSCaFileName ,
333
+ },
334
+ },
315
335
DefaultMode : ptr.To [int32 ](420 ),
336
+ Optional : ptr .To (false ),
316
337
},
317
338
},
318
339
}
319
- volumes = append (volumes , certsVolume )
320
340
}
321
341
342
+ volumes = append (volumes , certsVolume )
343
+
322
344
sdsVolume := corev1.Volume {
323
345
Name : "sds" ,
324
346
VolumeSource : corev1.VolumeSource {
@@ -341,21 +363,36 @@ func expectedVolumes(name string, gatewayNamespacedMode bool, pod *egv1a1.Kubern
341
363
},
342
364
},
343
365
}
366
+ if gatewayNamespacedMode {
367
+ sdsVolume = corev1.Volume {
368
+ Name : "sds" ,
369
+ VolumeSource : corev1.VolumeSource {
370
+ ConfigMap : & corev1.ConfigMapVolumeSource {
371
+ LocalObjectReference : corev1.LocalObjectReference {
372
+ Name : ExpectedResourceHashedName (name ),
373
+ },
374
+ Items : []corev1.KeyToPath {
375
+ {
376
+ Key : common .SdsCAFilename ,
377
+ Path : common .SdsCAFilename ,
378
+ },
379
+ },
380
+ DefaultMode : ptr.To [int32 ](420 ),
381
+ Optional : ptr .To (false ),
382
+ },
383
+ },
384
+ }
385
+ }
344
386
volumes = append (volumes , sdsVolume )
345
387
return resource .ExpectedVolumes (pod , volumes )
346
388
}
347
389
348
390
// expectedContainerEnv returns expected proxy container envs.
349
- func expectedContainerEnv (containerSpec * egv1a1.KubernetesContainerSpec ) []corev1.EnvVar {
391
+ func expectedContainerEnv (containerSpec * egv1a1.KubernetesContainerSpec , egNamespace string ) []corev1.EnvVar {
350
392
env := []corev1.EnvVar {
351
393
{
352
- Name : envoyNsEnvVar ,
353
- ValueFrom : & corev1.EnvVarSource {
354
- FieldRef : & corev1.ObjectFieldSelector {
355
- APIVersion : "v1" ,
356
- FieldPath : "metadata.namespace" ,
357
- },
358
- },
394
+ Name : envoyNsEnvVar ,
395
+ Value : egNamespace ,
359
396
},
360
397
{
361
398
Name : envoyPodEnvVar ,
0 commit comments