Skip to content

Add securityContext to values.yaml#3

Open
theninj4 wants to merge 2 commits intoNeptuneHub:mainfrom
theninj4:postgres-security-context
Open

Add securityContext to values.yaml#3
theninj4 wants to merge 2 commits intoNeptuneHub:mainfrom
theninj4:postgres-security-context

Conversation

@theninj4
Copy link

👋 I've added securityContext to the postgres section of values.yaml so I can get persistence working. The core issue is how postgres needs to chown its data directory on boot, however not all Kubernetes storage adapters allow the changing of permissions on mounted volumes - I'm using an NFS storage adapter with this limitation - the solution is to start the container with the userID matching the attached volume. This is quite a niche feature, so I've left it out of the default values, and I've tested both with and without any values present.

Preview of the changes:

$ helm template my-audiomuse . | grep -A 4 securityContext
...
--
      securityContext:
        fsGroup: 100
        runAsGroup: 100
        runAsUser: 1024
$ helm template my-audiomuse . | kubectl apply --dry-run=client -f - 
secret/my-audiomuse-audiomuse-ai-jellyfin created (dry run)
secret/my-audiomuse-audiomuse-ai-postgres created (dry run)
secret/my-audiomuse-audiomuse-ai-gemini created (dry run)
secret/my-audiomuse-audiomuse-ai-mistral created (dry run)
secret/my-audiomuse-audiomuse-ai-ai-chat-db created (dry run)
secret/my-audiomuse-audiomuse-ai-navidrome created (dry run)
secret/my-audiomuse-audiomuse-ai-lyrion created (dry run)
configmap/my-audiomuse-audiomuse-ai-env-vars created (dry run)
persistentvolumeclaim/my-audiomuse-audiomuse-ai-postgres-pvc created (dry run)
service/my-audiomuse-audiomuse-ai-flask-service created (dry run)
service/my-audiomuse-audiomuse-ai-postgres created (dry run)
service/my-audiomuse-audiomuse-ai-redis created (dry run)
deployment.apps/my-audiomuse-audiomuse-ai-flask created (dry run)
deployment.apps/my-audiomuse-audiomuse-ai-postgres created (dry run)
deployment.apps/my-audiomuse-audiomuse-ai-redis created (dry run)
deployment.apps/my-audiomuse-audiomuse-ai-worker created (dry run)
$ helm template my-audiomuse . | kubectl apply --dry-run=server -f - 
secret/my-audiomuse-audiomuse-ai-jellyfin created (server dry run)
secret/my-audiomuse-audiomuse-ai-postgres created (server dry run)
secret/my-audiomuse-audiomuse-ai-gemini created (server dry run)
secret/my-audiomuse-audiomuse-ai-mistral created (server dry run)
secret/my-audiomuse-audiomuse-ai-ai-chat-db created (server dry run)
secret/my-audiomuse-audiomuse-ai-navidrome created (server dry run)
secret/my-audiomuse-audiomuse-ai-lyrion created (server dry run)
configmap/my-audiomuse-audiomuse-ai-env-vars created (server dry run)
persistentvolumeclaim/my-audiomuse-audiomuse-ai-postgres-pvc created (server dry run)
service/my-audiomuse-audiomuse-ai-flask-service created (server dry run)
service/my-audiomuse-audiomuse-ai-postgres created (server dry run)
service/my-audiomuse-audiomuse-ai-redis created (server dry run)
deployment.apps/my-audiomuse-audiomuse-ai-flask created (server dry run)
deployment.apps/my-audiomuse-audiomuse-ai-postgres created (server dry run)
deployment.apps/my-audiomuse-audiomuse-ai-redis created (server dry run)
deployment.apps/my-audiomuse-audiomuse-ai-worker created (server dry run)

@theninj4 theninj4 marked this pull request as draft January 14, 2026 18:54
@theninj4 theninj4 marked this pull request as ready for review January 14, 2026 19:00
Copy link
Owner

@NeptuneHub NeptuneHub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi @theninj4, thanks for this. A couple of things needed:

Conditional guard: Same as PR #2, please use {{- with }} instead of unconditional rendering to avoid securityContext: null when not set.

Apply to all deployments, not just postgres: Please add configurable securityContext to flask, worker, and redis as well, for consistency.

Defaults for flask and worker: The application till now was always run as root (in future I'll doublecheck if this is stricty required or can be changed), so values.yaml must include safe defaults for flask and worker:

flask:
securityContext:
runAsUser: 0
runAsGroup: 0
fsGroup: 0

worker:
securityContext:
runAsUser: 0
runAsGroup: 0
fsGroup: 0

This way the current behavior is preserved out of the box, but users can override it if their setup requires it (like your NFS case for postgres). For postgres and redis you can leave the defaults empty so they only apply when explicitly configured.

Copy link
Owner

@NeptuneHub NeptuneHub left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please resolve the conflict with the main branch (I basically merged your other PR). Thanks.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants