<p>I'm trying to understand how to manage a Postgres database deployed on a Kubernetes cluster.
So far, I can deploy a pod with the Postgres image. I'm also able to create persistent volume and persistent volume claims, but there is something that still I can't understand.</p>
<p>If I have a production database and at some point, I need to patch the database, what is the way to proceed?
Is there a way to execute a SQL instruction to update schema and data?</p>

Salvatore Calla'
<p>The easiest approach would be to connect to your database via port-forwarding, e.g.:</p>
<pre><code>while true; do kubectl port-forward &quot;$path&quot; -n &quot;$namespace&quot; &quot;$ports&quot;; done
</code></pre>
<p>Better stop all downstream Pods that connect to this database. Then do what you need to do with a Postgres client of your choice.</p>
<p>More robustly, introduce a tool like <a href="https://flywaydb.org/" rel="nofollow noreferrer">Flyway</a> or <a href="https://www.liquibase.org/" rel="nofollow noreferrer">Liquibase</a> for schema changes, which would get executed from inside the cluster and allow to version and track your DB changes.</p>
