<p>I created a private CloudSQL instance for a postgres db.
I followed the documentation at <a href="https://cloud.google.com/sql/docs/postgres/connect-kubernetes-engine" rel="nofollow noreferrer">https://cloud.google.com/sql/docs/postgres/connect-kubernetes-engine</a> and applied the yaml changes and restarted the deployment.
Added the below to my existing Yaml for deployment.
I was wondering if there is any way to test/check if the connection to the DB was successful.
EDIT - I didnt encounter any errors when the pod restarted, so thats the main reason I am asking this question.</p>
<pre><code>spec:
      containers:
      - name: &lt;YOUR-APPLICATION-NAME&gt;
        # ... other container configuration
        env:
        - name: DB_USER
          valueFrom:
            secretKeyRef:
              name: &lt;YOUR-DB-SECRET&gt;
              key: username
        - name: DB_PASS
          valueFrom:
            secretKeyRef:
              name: &lt;YOUR-DB-SECRET&gt;
              key: password
        - name: DB_NAME
          valueFrom:
            secretKeyRef:
              name: &lt;YOUR-DB-SECRET&gt;
              key: database
        - name: DB_HOST
          valueFrom:
            secretKeyRef:
              name: &lt;YOUR-PRIVATE-IP-SECRET&gt;
              key: db_host
</code></pre>

Jainam Shah
<p>If you just to check the connection</p>
<p>you can run one ubuntu or busybox container to check the connection with the Postgres database.</p>
<pre><code>kubectl run -i --tty busybox --image=busybox --restart=Never -- sh

$&gt; # ls 
</code></pre>
<p>Once you are in the container you can run the command from the container to Postgres database connection or run any network commands to check further.</p>
<p>Command to check the <strong>Postgres sql</strong></p>
<pre><code>psql -h &lt;REMOTE HOST&gt; -p &lt;REMOTE PORT&gt; -U &lt;DB_USER&gt; &lt;DB_NAME&gt; 
</code></pre>
