<p>I have hosted pgpool on a container and given the container config for kubernetes deployment -</p>
<p>Mountpaths -</p>
<pre><code>- name: cgroup
    mountPath: /sys/fs/cgroup:ro
- name: var-run
    mountPath: /run
</code></pre>
<p>And Volumes for mountpath for the cgroups are mentioned as below -</p>
<pre><code>- name: cgroup
    hostPath:
      path: /sys/fs/cgroup
      type: Directory
- name: var-run
  emptyDir:
      medium: Memory
</code></pre>
<p>Also in kubernetes deployment I have passed -</p>
<pre><code> securityContext:
    privileged: true
</code></pre>
<p>But when I open the pod and exec inside it to check the pgpool status I get the below issue -</p>
<pre><code>[root@app-pg-6448dfb58d-vzk67 /]# journalctl -xeu pgpool
-- Logs begin at Sat 2020-07-04 16:28:41 UTC, end at Sat 2020-07-04 16:29:13 UTC. --
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 systemd[1]: Started Pgpool-II.
-- Subject: Unit pgpool.service has finished start-up
-- Defined-By: systemd
-- Support: http://lists.freedesktop.org/mailman/listinfo/systemd-devel
-- 
-- Unit pgpool.service has finished starting up.
-- 
-- The start-up result is done.
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 pgpool[34]: [1-1] 2020-07-04 16:28:41: pid 34: INFO:  unrecognized configuration parameter &quot;stateme
nt_level_load_balance&quot;
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 pgpool[34]: 2020-07-04 16:28:41: pid 34: INFO:  unrecognized configuration parameter &quot;statement_lev
el_load_balance&quot;
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 pgpool[34]: 2020-07-04 16:28:41: pid 34: INFO:  unrecognized configuration parameter &quot;auto_failback
&quot;
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 pgpool[34]: 2020-07-04 16:28:41: pid 34: INFO:  unrecognized configuration parameter &quot;auto_failback
_interval&quot;
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 pgpool[34]: 2020-07-04 16:28:41: pid 34: INFO:  unrecognized configuration parameter &quot;enable_consen
sus_with_half_votes&quot;
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 pgpool[34]: 2020-07-04 16:28:41: pid 34: INFO:  unrecognized configuration parameter &quot;enable_shared
_relcache&quot;
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 pgpool[34]: 2020-07-04 16:28:41: pid 34: INFO:  unrecognized configuration parameter &quot;relcache_quer
y_target&quot;
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 pgpool[34]: 2020-07-04 16:28:41: pid 34: FATAL:  could not open pid file as /var/run/pgpool-II-11/p
gpool.pid. reason: No such file or directory
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 systemd[1]: pgpool.service: main process exited, code=exited, status=3/NOTIMPLEMENTED
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 systemd[1]: Unit pgpool.service entered failed state.
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 systemd[1]: pgpool.service failed.
</code></pre>
<p>Systemctl status pgpool inside the pod container -</p>
<pre><code>➜  app-app kubectl exec -it app-pg-6448dfb58d-vzk67  -- bash
[root@app-pg-6448dfb58d-vzk67 /]# systemctl status pgpool
● pgpool.service - Pgpool-II
   Loaded: loaded (/usr/lib/systemd/system/pgpool.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Sat 2020-07-04 16:28:41 UTC; 1h 39min ago
  Process: 34 ExecStart=/usr/bin/pgpool -f /etc/pgpool-II/pgpool.conf $OPTS (code=exited, status=3)
 Main PID: 34 (code=exited, status=3)

Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 pgpool[34]: 2020-07-04 16:28:41: pid 34: INFO:  unrecognized configuration parameter &quot;stat...lance&quot;
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 pgpool[34]: 2020-07-04 16:28:41: pid 34: INFO:  unrecognized configuration parameter &quot;auto...lback&quot;
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 pgpool[34]: 2020-07-04 16:28:41: pid 34: INFO:  unrecognized configuration parameter &quot;auto...erval&quot;
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 pgpool[34]: 2020-07-04 16:28:41: pid 34: INFO:  unrecognized configuration parameter &quot;enab...votes&quot;
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 pgpool[34]: 2020-07-04 16:28:41: pid 34: INFO:  unrecognized configuration parameter &quot;enab...cache&quot;
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 pgpool[34]: 2020-07-04 16:28:41: pid 34: INFO:  unrecognized configuration parameter &quot;relc...arget&quot;
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 pgpool[34]: 2020-07-04 16:28:41: pid 34: FATAL:  could not open pid file as /var/run/pgpoo...ectory
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 systemd[1]: pgpool.service: main process exited, code=exited, status=3/NOTIMPLEMENTED
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 systemd[1]: Unit pgpool.service entered failed state.
Jul 04 16:28:41 app-pg-6448dfb58d-vzk67 systemd[1]: pgpool.service failed.
Hint: Some lines were ellipsized, use -l to show in full.
</code></pre>
<p>If required this is the whole deployment sample -</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: app-pg
  labels:
    helm.sh/chart: app-pgpool-1.0.0
    app.kubernetes.io/name: app-pgpool
    app.kubernetes.io/instance: app-service
    app.kubernetes.io/version: &quot;1.0.3&quot;
    app.kubernetes.io/managed-by: Helm
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: app-pgpool
      app.kubernetes.io/instance: app-service
  template:
    metadata:
      labels:
        app.kubernetes.io/name: app-pgpool
        app.kubernetes.io/instance: app-service
    spec:
      volumes:
        - name: &quot;pgpool-config&quot;
          persistentVolumeClaim:
            claimName: &quot;pgpool-pvc&quot;
        - name: cgroup
          hostPath:
            path: /sys/fs/cgroup
            type: Directory
        - name: var-run
          emptyDir:
            # Tmpfs needed for systemd.
            medium: Memory
      # volumes:
      #   - name: pgpool-config
      #     configMap:
      #       name: pgpool-config
      # - name: pgpool-config
      #   azureFile:
      #     secretName: azure-fileshare-secret
      #     shareName: pgpool
      #     readOnly: false
      imagePullSecrets:
        - name: app-secret
      serviceAccountName: app-pg
      securityContext:
        {}
      containers:
        - name: app-pgpool
          securityContext:
            {}
          image: &quot;appacr.azurecr.io/pgpool:1.0.3&quot;
          imagePullPolicy: IfNotPresent
          securityContext:
            privileged: true
          stdin: true
          tty: true
          ports:
            - name: http
              containerPort: 9999
              protocol: TCP
          # livenessProbe:
          #   httpGet:
          #     path: /
          #     port: http
          # readinessProbe:
          #   httpGet:
          #     path: /
          #     port: http
          resources:
            {}
          volumeMounts:
            - name: &quot;pgpool-config&quot;
              mountPath: /etc/pgpool-II
            - name: cgroup
              mountPath: /sys/fs/cgroup:ro
            - name: var-run
              mountPath: /run
</code></pre>
<p>UPDATE -</p>
<p>Running this same setup on dockerfile runs perfectly good no issues at all -</p>
<pre><code>version: '2'
services:

  pgpool:
    container_name: pgpool
    image: appacr.azurecr.io/pgpool:1.0.3
    logging:
      options:
        max-size: 100m
    ports:
      - &quot;9999:9999&quot;
    networks:
      vpcbr:
        ipv4_address: 10.5.0.2
    restart: unless-stopped
    volumes:
     - /sys/fs/cgroup:/sys/fs/cgroup:ro
     - $HOME/Documents/app/docker-compose/pgpool.conf:/etc/pgpool-II/pgpool.conf
     - $HOME/Documents/app/docker-compose/pool_passwd:/etc/pgpool-II/pool_passwd
    privileged: true
    stdin_open: true
    tty: true
</code></pre>
<p>I dont know what am I doing wrong I am not able to start this pgpool anyway and not able to pinpoint the issue. What permission are we missing here or whether cgroups is the culprit ? or not ?</p>
<p>Some direction would be appreciated .</p>

Joy
<p>while this might not be a direct answer to your question, I have seen some very cryptic errors when trying to run any postgresql product from raw manifest, my recommandations would be to try leveraging the chart from Bitnami, they have put a lot of effort in ensuring that all of the security / permission culpits are taken care of properly.</p>
<p><a href="https://github.com/bitnami/charts/tree/master/bitnami/postgresql-ha" rel="nofollow noreferrer">https://github.com/bitnami/charts/tree/master/bitnami/postgresql-ha</a></p>
<p>Hopefully, this help.</p>
<p>Also, if you do not want to use Helm, you can run the <code>help template</code> command</p>
<p><a href="https://helm.sh/docs/helm/helm_template/" rel="nofollow noreferrer">https://helm.sh/docs/helm/helm_template/</a></p>
<p>this will generate manifest out of the chart's template file based on the provided values.yaml</p>
