Skip to content

Commit

Permalink
[postgrescluster] add autoCreateUserSchema feature flag option
Browse files Browse the repository at this point in the history
  • Loading branch information
jshimko committed Oct 4, 2024
1 parent 5c7f3e7 commit 2f465df
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
2 changes: 1 addition & 1 deletion charts/postgrescluster/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,5 +3,5 @@ name: postgrescluster
description: A Helm chart for deploying a PostgresCluster instance using Crunchy Postgres Operator. https://access.crunchydata.com/documentation/postgres-operator/latest
type: application
# The version below should match the version on the PostgresCluster CRD
version: 5.6.1
version: 5.6.2
appVersion: 5.6.1
4 changes: 3 additions & 1 deletion charts/postgrescluster/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,10 @@ If you haven't already installed the PGO chart in your cluster, you will need to
helm install pgo -n pgo jshimko/pgo --set features.AutoCreateUserSchema=true
```

Note that we are installing the PGO chart above with the `AutoCreateUserSchema` feature flag enabled ([more info](https://access.crunchydata.com/documentation/postgres-operator/latest/tutorials/basic-setup/user-management#automatically-creating-per-user-schemas)). This is recommended so you don't have to manually create a user schema and grant permissions for your application user. If you choose not to enable this, you will need to manually grant the necessary permissions for your application user to access the database.

To deploy a `PostgresCluster` instance:

```sh
helm install my-pg-cluster -n my-namespace -f my-values.yaml jshimko/postgrescluster
helm install my-pg-cluster -n my-namespace -f my-values.yaml jshimko/postgrescluster --set autoCreateUserSchema=true
```
5 changes: 4 additions & 1 deletion charts/postgrescluster/templates/postgres.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,11 @@ apiVersion: postgres-operator.crunchydata.com/v1beta1
kind: PostgresCluster
metadata:
name: {{ default .Release.Name .Values.name }}
{{ with .Values.annotations }}
annotations:
{{ if .Values.autoCreateUserSchema }}
postgres-operator.crunchydata.com/autoCreateUserSchema: "true"
{{ end }}
{{ with .Values.annotations }}
{{ toYaml . | indent 4 }}
{{ end }}
spec:
Expand Down
6 changes: 5 additions & 1 deletion charts/postgrescluster/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@

# PostgresCluster annotations
# annotations:
# postgres-operator.crunchydata.com/autoCreateUserSchema: "true"
# postgres-operator.crunchydata.com/someFeature: "true"

# postgresVersion sets the version to deploy. This version number needs to be
# available as one of the "RELATED_IMAGE_POSTGRES_..." images as part of the PGO
Expand Down Expand Up @@ -143,6 +143,10 @@ postgresVersion: 16
# as well as any permissions associated with the user account.
# https://access.crunchydata.com/documentation/postgres-operator/latest/references/crd/5.6.x/postgrescluster#postgresclusterspecusersindex
# users: {}
#
# optionally create a user schema and grant permissions for the application user on their configured databases.
# https://access.crunchydata.com/documentation/postgres-operator/latest/tutorials/basic-setup/user-management#automatically-creating-per-user-schemas
# autoCreateUserSchema: true

# dataSource specifies a data source for bootstrapping a Postgres cluster.
# https://access.crunchydata.com/documentation/postgres-operator/latest/references/crd/5.6.x/postgrescluster#postgresclusterspecdatasource
Expand Down

0 comments on commit 2f465df

Please sign in to comment.