title: Create or update existing postgres db container through kubernetes job
body: <p>I have a Postgres DB container which is running in a Kubernetes cluster. I need to write a Kubernetes job to connect to the Postgres DB container and run the scripts from SQL file. I need to understand two things here</p>
  
  <ol>
  <li>commands to run SQL script </li>
  <li>how to load SQL file in Job.yaml file </li>
  </ol>
  
  <p>Here is my sample yaml file for Kubernetes job</p>
  
  <pre><code>apiVersion: batch/v1
  kind: Job
  metadata:
    name: init-db
  spec:
    template:
      metadata:
        name:  init-db
        labels:
          app: init-postgresdb
      spec:
        containers:
        - image: "docker.io/bitnami/postgresql:11.5.0-debian-9-r60"
          name: init-db
          command:
          - psql -U postgres 
          env:
            - name: DB_HOST
              value: "knotted-iguana-postgresql"
            - name: DB_DATABASE
              value: "postgres"
        restartPolicy: OnFailure  
  </code></pre>