Skip to content

Feature Request: Add Helm values for PgBouncer directory permissions customization #3066

@nbucking

Description

@nbucking

Feature Request: Add Helm values for PgBouncer directory permissions customization

Problem Statement

When using the Zalando Postgres Operator with Iron Bank hardened container images (or other custom base images), PgBouncer pods can fail due to permission issues on /etc/pgbouncer, /var/log/pgbouncer, and /var/run/pgbouncer directories.

The operator's pooler-connection-sidecar container runs as the same UID as the PgBouncer container (UID 100) and writes TLS certificates to /etc/pgbouncer at runtime. If the base image has these directories configured as read-only or with incompatible permissions, PgBouncer fails with CrashLoopBackOff.

Current Workaround

Users must build custom PgBouncer images with modified permissions:

FROM registry1.dso.mil/ironbank/opensource/pgbouncer/pgbouncer:1.24.0

# Make directories writable by pgbouncer user (UID 100, GID 101)
RUN chown -R 100:101 /etc/pgbouncer /var/log/pgbouncer /var/run/pgbouncer \
    && chmod 0750 /etc/pgbouncer /var/log/pgbouncer /var/run/pgbouncer

USER 100:101

Proposed Solution

Add Helm values similar to Spilo's pod environment variable support to allow customizing PgBouncer directory permissions without requiring custom images.

For example:

connectionPooler:
  podEnvironmentConfigMap: pgbouncer-config
  podEnvironmentSecret: pgbouncer-secrets
  initContainers:
    - name: fix-permissions
      image: busybox:latest
      command: ['sh', '-c', 'chown -R 100:101 /etc/pgbouncer /var/log/pgbouncer /var/run/pgbouncer && chmod 0750 /etc/pgbouncer /var/log/pgbouncer /var/run/pgbouncer']
      volumeMounts:
        - name: pgbouncer-config
          mountPath: /etc/pgbouncer
        - name: pgbouncer-logs
          mountPath: /var/log/pgbouncer
        - name: pgbouncer-run
          mountPath: /var/run/pgbouncer

Or add specific Helm values:

connectionPooler:
  directoryPermissions:
    enabled: true
    uid: 100
    gid: 101
    mode: "0750"
    paths:
      - /etc/pgbouncer
      - /var/log/pgbouncer
      - /var/run/pgbouncer

Benefits

  1. Iron Bank Compliance: Supports hardened container images without custom builds
  2. Flexibility: Users can adapt to different base image security policies
  3. Consistency: Matches existing Spilo customization patterns in the operator
  4. Maintainability: Eliminates need for maintaining custom image builds

Environment

  • Zalando Postgres Operator: v1.15.0
  • Base Image: Iron Bank PgBouncer 1.24.0
  • Kubernetes: 1.31

Related Issues

This is similar to how Spilo supports podEnvironmentConfigMap and podEnvironmentSecret for customization without requiring custom images.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions