Skip to content

Commit 6ed1030

Browse files
ReSearchITEngFxKu
andauthored
TLS - add OpenShift compatibility (zalando#885)
* solves zalando#798 (comment) Co-authored-by: Felix Kunde <felix-kunde@gmx.de>
1 parent 64d816c commit 6ed1030

File tree

3 files changed

+13
-14
lines changed

3 files changed

+13
-14
lines changed

docs/user.md

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -572,10 +572,15 @@ However, this certificate cannot be verified and thus doesn't protect from
572572
active MITM attacks. In this section we show how to specify a custom TLS
573573
certificate which is mounted in the database pods via a K8s Secret.
574574

575-
Before applying these changes, the operator must also be configured with the
576-
`spilo_fsgroup` set to the GID matching the postgres user group. If the value
577-
is not provided, the cluster will default to `103` which is the GID from the
578-
default spilo image.
575+
Before applying these changes, in k8s the operator must also be configured with
576+
the `spilo_fsgroup` set to the GID matching the postgres user group. If you
577+
don't know the value, use `103` which is the GID from the default spilo image
578+
(`spilo_fsgroup=103` in the cluster request spec).
579+
580+
OpenShift allocates the users and groups dynamically (based on scc), and their
581+
range is different in every namespace. Due to this dynamic behaviour, it's not
582+
trivial to know at deploy time the uid/gid of the user in the cluster.
583+
This way, in OpenShift, you may want to skip the spilo_fsgroup setting.
579584

580585
Upload the cert as a kubernetes secret:
581586
```sh

manifests/complete-postgres-manifest.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,3 +109,5 @@ spec:
109109
certificateFile: "tls.crt"
110110
privateKeyFile: "tls.key"
111111
caFile: "" # optionally configure Postgres with a CA certificate
112+
# When TLS is enabled, also set spiloFSGroup parameter above to the relevant value.
113+
# if unknown, set it to 103 which is the usual value in the default spilo images.

pkg/cluster/k8sres.go

Lines changed: 2 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,6 @@ const (
3737
localHost = "127.0.0.1/32"
3838
connectionPoolContainer = "connection-pool"
3939
pgPort = 5432
40-
41-
// the gid of the postgres user in the default spilo image
42-
spiloPostgresGID = 103
4340
)
4441

4542
type pgUser struct {
@@ -990,13 +987,8 @@ func (c *Cluster) generateStatefulSet(spec *acidv1.PostgresSpec) (*appsv1.Statef
990987

991988
// configure TLS with a custom secret volume
992989
if spec.TLS != nil && spec.TLS.SecretName != "" {
993-
if effectiveFSGroup == nil {
994-
c.logger.Warnf("Setting the default FSGroup to satisfy the TLS configuration")
995-
fsGroup := int64(spiloPostgresGID)
996-
effectiveFSGroup = &fsGroup
997-
}
998-
// this is combined with the FSGroup above to give read access to the
999-
// postgres user
990+
// this is combined with the FSGroup in the section above
991+
// to give read access to the postgres user
1000992
defaultMode := int32(0640)
1001993
volumes = append(volumes, v1.Volume{
1002994
Name: "tls-secret",

0 commit comments

Comments
 (0)