movetokube / postgres-operator

Postgres operator for Kubernetes
MIT License
167 stars 59 forks source link

Add support for template secrets #143

Closed reddec closed 9 months ago

reddec commented 10 months ago

Add support for template secrets.

Users can specify the structure and content of secrets based on their unique requirements using standard Go templates. This flexibility allows for a more tailored approach to meeting the specific needs of different applications.

Available context:

Variable Meaning
.Host Database host
.Role Generated user/role name
.Database Referenced database name
.Password Generated role password

Example

apiVersion: db.movetokube.com/v1alpha1
kind: PostgresUser
metadata:
  name: my-db-user
spec:
  role: username
  database: my-db
  secretName: my-secret
  privileges: OWNER
  template:
    PQ_URL: "host={{.Host}} user={{.Role}} password={{.Password}} dbname={{.Database}}"

Change is backward compatible: no need to update existing CRDs in cluster.

reddec commented 10 months ago

@hitman99 sorry for bothering you, but could you please review one more PR?

reddec commented 10 months ago

@hitman99 updated