<p>I am deploying pgadmin and postgres on kubernetes. When i look at deployments I see that 2 deployments are not ready. When I look at logs of Pgadmin, I see that it gives error as it can not connect to postgres. I use configmap to connect pgadmin to postgres. When I look at logs of postgres I see error.</p>
<p>Logs:</p>
<pre><code>The files belonging to this database system will be owned by user &quot;postgres&quot;.
This user must also own the server process.

The database cluster will be initialized with locale &quot;en_US.utf8&quot;.
The default database encoding has accordingly been set to &quot;UTF8&quot;.
The default text search configuration will be set to &quot;english&quot;.

Data page checksums are disabled.

fixing permissions on existing directory /var/lib/postgresql/data ... ok
creating subdirectories ... ok
selecting dynamic shared memory implementation ... posix
selecting default max_connections ... 20
selecting default shared_buffers ... 400kB
selecting default time zone ... Etc/UTC
creating configuration files ... ok
Bus error (core dumped)
child process exited with exit code 135
initdb: removing contents of data directory &quot;/var/lib/postgresql/data&quot;
running bootstrap script ...
</code></pre>
<p>yaml file:</p>
<pre><code>#configmap
apiVersion: v1
kind: ConfigMap
metadata:
  name: postgres-configmap
data:
  db_url: postgres-service
---
#postgres
apiVersion: apps/v1
kind: Deployment
metadata:
  name: postgres-deployment
  labels:
    app: postgres
spec:
  replicas: 1
  selector:
    matchLabels:
      app: postgres
  template:
    metadata:
      labels:
        app: postgres
    spec:
      containers:
      - name: postgres
        image: postgres:13.3
        ports:
        - containerPort: 5432
        env:
        - name: POSTGRES_PASSWORD
          valueFrom:
            secretKeyRef:
              name: postgres-secret
              key: postgres-password 
---
apiVersion: v1
kind: Service
metadata:
  name: postgres-service
spec:
  selector:
    app: postgres
  ports:
    - protocol: TCP
      port: 5432
      targetPort: 5432
---
#pgadmin
apiVersion: apps/v1
kind: Deployment
metadata:
  name: pgadmin-deployment
  labels:
    app: pgadmin
spec:
  replicas: 1
  selector:
    matchLabels:
      app: pgadmin
  template:
    metadata:
      labels:
        app: pgadmin
    spec:
      containers:
      - name: pgadmin
        image: dpage/pgadmin4
        ports:
        - containerPort: 49762
        env:
        - name: PGADMIN_DEFAULT_EMAIL
          value: email@email.com
        - name: PGADMIN_DEFAULT_PASSWORD
          value: password
        - name: PGADMIN_LISTEN_ADDRESS
          valueFrom:
            configMapKeyRef:
              name: postgres-configmap
              key: db_url
---
apiVersion: v1
kind: Service
metadata:
  name: pgadmin-service
spec:
  selector:
    app: pgadmin
  type: LoadBalancer
  ports:
    - protocol: TCP
      port: 49762
      targetPort: 49762
      nodePort: 30001
</code></pre>

<p>After analysing the comments it looks like below resources have been helpful to solve this problem:</p>
<ol>
<li><a href="https://stackoverflow.com/questions/30848670/how-to-customize-the-configuration-file-of-the-official-postgresql-docker-image">How to customize the configuration file of the official PostgreSQL Docker image?</a></li>
<li><a href="https://github.com/docker-library/postgres/issues/451#issuecomment-447472044" rel="nofollow noreferrer">https://github.com/docker-library/postgres/issues/451#issuecomment-447472044</a></li>
</ol>
<p>To sum up, editing <code>/usr/share/postgresql/postgresql.conf.sample</code> file while postgres runs inside a container can be done by putting a custom <code>postgresql.conf</code> in a temporary file inside the container and overwriting the default configuration at runtime as described <a href="https://github.com/docker-library/postgres/issues/451#issuecomment-447472044" rel="nofollow noreferrer">here</a>. Also, keeping a dummy entry point script using &quot;play with kubernetes&quot; <a href="https://www.google.com/search?q=play%20with%20kubernetes&amp;rlz=1CAZVTZ_enPL954PL954&amp;ei=pd_VYKWEBeiOrwTs8JjwDg&amp;oq=play%20with%20kubernetes&amp;gs_lcp=Cgdnd3Mtd2l6EAMyBAgAEEMyAggAMgIIADICCAAyAggAMgIIADICCAAyAggAOgcIABBHELADSgQIQRgAULv6OVi7-jlgwvs5aAJwAngAgAFziAHTAZIBAzEuMZgBAKABAaoBB2d3cy13aXrIAQjAAQE&amp;sclient=gws-wiz&amp;ved=0ahUKEwjl6rKe97LxAhVox4sKHWw4Bu4Q4dUDCA4&amp;uact=5" rel="nofollow noreferrer">websites</a> and then spinning up the container or trying to copy the file to the container might be useful.</p>
