Home > Mobile >  Kubernetes database operator that automatically creates credentials
Kubernetes database operator that automatically creates credentials

Time:12-12

I got a task, to create a helm-chart and use a kubernetes database operator that creates automatically credentials for the database.

I don't really understand how is this possible.
I found this operator in Operator hub: https://operatorhub.io/operator/postgresql-operator-dev4devs-com

This is an operator for postgreSQL. It is mentioned that :

  • 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. 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 required for the PostgreSQL database image.

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)

CodePudding user response:

i am not much fan of operators not writing unless required or keeping it as the last option.

To understand it easily consider it like there are different types of operator

  • Helm-based operator
  • Ansible operator
  • Go, python other language-based operators

Which use the framework to Operator framework

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.

Steps :

  1. Install the Operator SDK first
  2. operator-sdk new db-operator --api-version=harsh.com/v1alpha1 --kind=DbSecret --type=helm --helm-chart=db-secret --helm-chart-repo=<repo url>
  3. Add/Edit the helm chart YAML with DB secret creation as you are planning
  4. Consider kind:DbSecret as values.yaml in helm
  5. Build and deploy the Operator (operator-sdk build) it will watch for configmap/secret if not there it will create it

you might have to create the necessary service account, role, and role binding.

Ref document to create the helm operator : https://sdk.operatorframework.io/docs/building-operators/helm/tutorial/

  • Related