Add postgres pod securityContext setting. #2059
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Previously, it was not possible to set the pod-level securityContext, which makes it impossible to solve a
persistent volume
permissions issue on a kubernetes cluster with enforced nonRoot containers.Fixes #1770 and similar postgres "Permission denied" issues.
SUMMARY
By default, persistent volume is create with
root:root 0755
permissions.In order to run postgres in the non-root container, the filesystem ownership must be changed.
The existing workaroud is to run a
chown
command in an init container.Unfortunately, this is not possible to run a root init container on security-hardened kubernetes clusters, such as those which prohibit root containers with the help of a ValidatingAdmissionPolicy.
The kubernetes native solution to this problem is the
fsGroup
setting. When enabled, it enforces recursive group-write permission before the container startup.The
awxs
CRD claims that thepostgres_security_context_settings
configures the pod-level securityContext, when in fact it configures the container-level one.This PR introduces the pod spec securityContext setting and fixes the relevant documentation.
ISSUE TYPE
ADDITIONAL INFORMATION
This PR can be tested with the following settings: