<p>I am using bitnami PostgreSQL image to deploy StatfulSet inside my cluster node. I am not sure how to initiate schema for the PostgreSQL pod without building on top of bitnami image. I have looked around on the internet and someone said to use init containers but I am also not sure how exactly I would do that.</p>

Ashish
<p>From the <a href="https://github.com/bitnami/bitnami-docker-postgresql" rel="nofollow noreferrer">Github Readme</a> of the Bitnami Docker image:</p>
<blockquote>
<p>When the container is executed for the first time, it will execute the
files with extensions <code>.sh</code>, <code>.sql</code> and <code>.sql.gz</code> located at
<code>/docker-entrypoint-initdb.d</code>.</p>
<p>In order to have your custom files inside the docker image you can
mount them as a volume.</p>
</blockquote>
<p>You can just mount such scripts under that directory using a ConfigMap volume. An example could be the following:</p>
<p>First, create the ConfigMap with the scripts, for example:</p>
<pre><code>apiVersion: v1
kind: ConfigMap
metadata:
  name: p-init-sql
  labels:
    app: the-app-name
data:
  01_init_db.sql: |-
    # content of the script goes here
  02_second_init_db.sql: |-
    # more content for another script goes here
</code></pre>
<p>Second, under <code>spec.template.spec.volumes</code>, you can add:</p>
<pre><code>volumes:
  - configMap:
      name: p-init-sql
</code></pre>
<p>Then, under <code>spec.template.spec.containers[0].volumeMounts</code>, you can mount this volume with:</p>
<pre><code>volumeMounts:
  - mountPath: /docker-entrypoint-initdb.d
    name: p-init-sql
</code></pre>
<hr />
<p>With this said, you may find out that it is more easy to use <a href="https://helm.sh/" rel="nofollow noreferrer">HELM</a> Charts.</p>
<p>Bitnami provides HELM Charts for all its images which simplify the usage of such images by a lot (as everything is ready to be installed and configured from a simple <code>values.yaml</code> file)</p>
<p>For example, there is such a chart for postgresql which you can find <a href="https://github.com/bitnami/charts/tree/master/bitnami/postgresql/" rel="nofollow noreferrer">here</a> and that can be of inspiration in how to configure the docker image even if you decide to write your own Kubernetes resources around that image.</p>
