<p>I am new working with Airflow and Kubernetes. I am trying to use apache Airflow in Kubernetes.</p>
<p>To deploy it I used this chart: <a href="https://github.com/apache/airflow/tree/master/chart" rel="nofollow noreferrer">https://github.com/apache/airflow/tree/master/chart</a>.</p>
<p>When I deploy it like in the link above a PostgreSQL database is created. When I explore the value.yml file of the chart I found this:</p>
<pre class="lang-yml prettyprint-override"><code># Configuration for postgresql subchart
# Not recommended for production
postgresql:
  enabled: true
  postgresqlPassword: postgres
  postgresqlUsername: postgres
</code></pre>
<p>I cannot find why is not recommended for production.</p>
<p>and also this:</p>
<pre class="lang-yml prettyprint-override"><code>data:
  # If secret names are provided, use those secrets
  metadataSecretName: ~
  resultBackendSecretName: ~
# Otherwise pass connection values in
  metadataConnection:
    user: postgres
    pass: postgres
    host: ~
    port: 5432
    db: postgres
    sslmode: disable
  resultBackendConnection:
    user: postgres
    pass: postgres
    host: ~
    port: 5432
    db: postgres
    sslmode: disable
</code></pre>
<p>What is recommended for production? use my own PostgreSQL database outside Kubernetes? If it is correct, how can I use it instead this one? How I have to modify it to use my own postgresql?</p>

<p>The reason why it is not recommended for production is because the chart provides a very basic Postgres setup.</p>
<p>In container world containers are transient unlike processes in the VM world. So likelihood of database getting restarted or killed is high. So if we are running stateful components in K8s, someone needs to make sure that the Pod is always running with its configured storage backend.</p>
<p>The following tools help to run Postgres with High Availablity on K8s/containers and provides various other benefits:</p>
<ol>
<li><a href="https://github.com/zalando/patroni" rel="nofollow noreferrer">Patroni</a></li>
<li><a href="https://github.com/sorintlab/stolon" rel="nofollow noreferrer">Stolon</a></li>
</ol>
<p>We have used Stolon to run 80+ Postgres instances on Kubernetes in a microservices environment. These are for public facing products so services are heavily loaded as well.</p>
<p>Its very easy to setup a Stolon cluster once you understand its <a href="https://github.com/sorintlab/stolon#architecture" rel="nofollow noreferrer">architecture</a>. Apart from HA it also provides replication, standby clusters and CLI for cluster administration.</p>
<p>Also please consider <a href="https://cloud.google.com/blog/products/databases/to-run-or-not-to-run-a-database-on-kubernetes-what-to-consider" rel="nofollow noreferrer">this blog</a> as well for making your decision. It brings in the perspective of how much Ops will be involved in different solutions.</p>
