title: How to change Postgresql max_connections config via Kubernetes statefulset environment variable?
body: <p>In Kubernetes, environment variables from a ConfigMap do not change the max_connections property in a PostgreSql pod. How do you change Postgres max_connections configuration via environment variables in Kubernetes ?</p>
  
  <p>I've tried following parameters to configure Postgres.</p>
  
  <p>The problem is, I can use DB, USER and PASSWORD parameters and values are set as expected. But i need to change max_connections configuration. I made related research, it looks like PGOPTIONS is the right choice to send configuration changes. Even i tried PGOPTIONS and other variations, there is no impact on max_connections value. I am connecting postgresql and i am executing SHOW MAX_CONNECTIONS query, it shows 100 even i specify 1000 in the environment configuration values.  </p>
  
  <p>I am using Kubernetes 1.14 in digitalocean. </p>
  
  <h3>ConfigMap</h3>
  
  <pre><code>apiVersion: v1
  kind: ConfigMap
  metadata:
    name: postgres-config-demo
    labels:
      app: postgres
  data:
    POSTGRES_DB: demopostgresdb
    POSTGRES_USER: demopostgresadmin
    POSTGRES_PASSWORD: demopostgrespwd
    PGOPTIONS: "-c max_connections=1000  -c shared_buffers=1024MB"
    POSTGRES_OPTIONS: "-c max_connections=1000  -c shared_buffers=1024MB"
    PG_OPTIONS: "-c max_connections=1000  -c shared_buffers=1024MB"
    MAX_CONNECTIONS: "1000"
  </code></pre>
  
  <h3>Statefulset</h3>
  
  <pre><code>apiVersion: apps/v1
  kind: StatefulSet
  metadata:
    name: pgdemo
  spec:
    serviceName: "postgres"
    replicas: 2
    selector:
      matchLabels:
        app: postgres
    template:
      metadata:
        labels:
          app: postgres
      spec:
        containers:
          - name: postgres
            image: postgres:latest          
  
            envFrom:
              - configMapRef:
                  name: postgres-config-demo     
            env:         
              - name: PGOPTIONS
                value: "-c max_connections=1000  -c shared_buffers=1024MB"
              - name: "MAX_CONNECTIONS"
                value: "1000"
            ports:
              - containerPort: 5432
                name: postgredb
            volumeMounts:
              - name: postgredb
                mountPath: /var/lib/postgresql/data
                subPath: postgres              
    volumeClaimTemplates:
      - metadata:
          name: postgredb
        spec:
          accessModes: ["ReadWriteOnce"]
          storageClassName: do-block-storage
          resources:
            requests:
              storage: 3Gi
  </code></pre>
  
  <p>I am expecting to get max_connections value as 1000.
  But it looks like as default value like 100.</p>
  
  <p>There is no error in any log.</p>