Skip to content

Commit 6953f72

Browse files
authored
fix to pooler TLS support (#2219)
* fix to pooler TLS support, security context fsGroup added (#2216) * add environment variable of CA cert path in pooler pod template * additional logic for custom CA secrets and mount path * fix ca file name
1 parent d504aeb commit 6953f72

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

pkg/cluster/connection_pooler.go

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -348,20 +348,33 @@ func (c *Cluster) generateConnectionPoolerPodTemplate(role PostgresRole) (
348348
// Env vars
349349
crtFile := spec.TLS.CertificateFile
350350
keyFile := spec.TLS.PrivateKeyFile
351+
caFile := spec.TLS.CAFile
352+
mountPath := "/tls"
353+
mountPathCA := mountPath
354+
351355
if crtFile == "" {
352356
crtFile = "tls.crt"
353357
}
354358
if keyFile == "" {
355359
keyFile = "tls.key"
356360
}
361+
if caFile == "" {
362+
caFile = "ca.crt"
363+
}
364+
if spec.TLS.CASecretName != "" {
365+
mountPathCA = mountPath + "ca"
366+
}
357367

358368
envVars = append(
359369
envVars,
360370
v1.EnvVar{
361-
Name: "CONNECTION_POOLER_CLIENT_TLS_CRT", Value: filepath.Join("/tls", crtFile),
371+
Name: "CONNECTION_POOLER_CLIENT_TLS_CRT", Value: filepath.Join(mountPath, crtFile),
372+
},
373+
v1.EnvVar{
374+
Name: "CONNECTION_POOLER_CLIENT_TLS_KEY", Value: filepath.Join(mountPath, keyFile),
362375
},
363376
v1.EnvVar{
364-
Name: "CONNECTION_POOLER_CLIENT_TLS_KEY", Value: filepath.Join("/tls", keyFile),
377+
Name: "CONNECTION_POOLER_CLIENT_CA_FILE", Value: filepath.Join(mountPathCA, caFile),
365378
},
366379
)
367380

@@ -402,6 +415,12 @@ func (c *Cluster) generateConnectionPoolerPodTemplate(role PostgresRole) (
402415
},
403416
}
404417

418+
if spec.TLS != nil && spec.TLS.SecretName != "" && spec.SpiloFSGroup != nil {
419+
podTemplate.Spec.SecurityContext = &v1.PodSecurityContext{
420+
FSGroup: spec.SpiloFSGroup,
421+
}
422+
}
423+
405424
nodeAffinity := c.nodeAffinity(c.OpConfig.NodeReadinessLabel, spec.NodeAffinity)
406425
if c.OpConfig.EnablePodAntiAffinity {
407426
labelsSet := labels.Set(c.connectionPoolerLabels(role, false).MatchLabels)

0 commit comments

Comments
 (0)