Open twavv opened 4 years ago
For my own use case, I was able to hack around this by adding to the Helm chart:
{{ if eq .name "yb-tservers" }}
initContainers:
- name: "chmod-pgdata"
image: busybox@sha256:d366a4665ab44f0648d7a00ae3fae139d55e32f9712c67accd604bb55df9d05a
imagePullPolicy: IfNotPresent
command:
- sh
- -c
- >
chmod 700 /mnt/disk*/pg_data;
echo done;
{{ if not $root.Values.storage.ephemeral }}
volumeMounts:
{{- range $index := until (int ($storageInfo.count)) }}
- name: datadir{{ $index }}
mountPath: /mnt/disk{{ $index }}
{{- end }}
{{- end }}
{{ end }}
This works because Kubernetes only applies the permissions when creating the pod and before attaching it to any specific container.
Should be fixed when #6131 lands. The workaround in this GH issue should be useful until then.
This sounds like a bug in Kubernetes - And you've provided a PR indicating that Kubernetes thinks that it's a bug.
I took some time to look into how postgres solves this problem - since we simply take this behavior from postgres.
I'm not the most familiar with K8s, but I found this which appears a similar issue and it seems kubernetes has specified a specific group for this problem...
I found this design document as well - https://github.com/kubernetes/community/blob/master/contributors/design-proposals/storage/volume-ownership-management.md
Known issues with current externalized design
The ownership management is currently repeatedly applied, which breaks packages that require special permissions in order to work correctly
This all points to the problem being with Kubernetes, not our (that is, postgres's) design.
tl;dr: sometimes, Kubernetes likes to add group-write permissions to mounted volumes. This causes Postgres to explode:
Gory Details
fsGroup
, volumes are "modified to be owned and writable by the GID specified infsGroup
."https://github.com/yugabyte/yugabyte-db/blob/cb4bd4c6490e7ed7921a6f241a4e2c6f841a4580/src/postgres/src/backend/utils/init/miscinit.c#L154-L159