<p>I got a task, to create a helm-chart and use a kubernetes database operator that creates automatically credentials for the database.</p>
<p>I don't really understand how is this possible.<br />
I found this operator in Operator hub: <a href="https://operatorhub.io/operator/postgresql-operator-dev4devs-com" rel="nofollow noreferrer">https://operatorhub.io/operator/postgresql-operator-dev4devs-com</a></p>
<p>This is an operator for postgreSQL. It is mentioned that :</p>
<ul>
<li>Allow you setup the operator to get the values required for its enviroment variables (user, password and database name) in an ConfigMap applied in the cluster already. <em>NOTE: It is very useful to centralize and share this information accross the cluster for your solutions. Also, you are able to configure each configMap keys that contains each EnvVar</em> required for the PostgreSQL database image.</li>
</ul>
<p>If someone has experience with kubernetes operators, could I get a hint, which one should I use? (easiest, it doesn't have to be Postgres)</p>

Oliver Domokos
<p>i am not much fan of operators not writing unless required or keeping it as the last option.</p>
<p>To understand it easily consider it like there are different types of operator</p>
<ul>
<li>Helm-based operator</li>
<li>Ansible operator</li>
<li>Go, python other language-based operators</li>
</ul>
<p>Which use the framework to <a href="https://github.com/operator-framework" rel="nofollow noreferrer">Operator framework</a></p>
<p>You have to create one Helm-based Operator which keep watch on a secret if removed or does not exist it will create the new one for the Database.</p>
<p>Steps :</p>
<ol>
<li>Install the Operator SDK first</li>
<li><code>operator-sdk new db-operator --api-version=harsh.com/v1alpha1 --kind=DbSecret --type=helm --helm-chart=db-secret --helm-chart-repo=&lt;repo url&gt;</code></li>
<li>Add/Edit the helm chart YAML with DB secret creation as you are planning</li>
<li>Consider <strong>kind:DbSecret</strong> as values.yaml in helm</li>
<li>Build and deploy the Operator (operator-sdk build) it will watch for configmap/secret if not there it will create it</li>
</ol>
<p>you might have to create the necessary service account, role, and role binding.</p>
<p>Ref document to create the helm operator : <a href="https://sdk.operatorframework.io/docs/building-operators/helm/tutorial/" rel="nofollow noreferrer">https://sdk.operatorframework.io/docs/building-operators/helm/tutorial/</a></p>
