Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[bitnami/postgresql-ha] Method to set postgres password with other user #2470

Closed
MikaelSmith opened this issue Apr 29, 2020 · 8 comments · Fixed by #2518
Closed

[bitnami/postgresql-ha] Method to set postgres password with other user #2470

MikaelSmith opened this issue Apr 29, 2020 · 8 comments · Fixed by #2518

Comments

@MikaelSmith
Copy link
Contributor

MikaelSmith commented Apr 29, 2020

Which chart:
postgresql-ha 3.1.1

Is your feature request related to a problem? Please describe.
I'm attempting to initialize postgres with a specific user/database, such as with

postgres:
  username: my-db
  database: my-db
  password: ****

Doing that means the postgres user does not have a password set, as noted in https://github.com/bitnami/bitnami-docker-postgresql-repmgr#creating-a-database-user-on-first-run.

My motivation for having access as the postgres user is to do database backups, and to be able to restore a backup to a new cluster. The documented methods for that use ConfigMaps, which have a limit of 1MB (because they're stored in etcd), limiting their use to re-initialize the database from a backup.

Describe the solution you'd like
I'd like to be able to set the POSTGRESQL_POSTGRES_PASSWORD setting in the container to provide a password for the postgres user when creating a separate database user.

I'd also be open to other suggestions on how to do backup/restore.

@marcosbc
Copy link
Contributor

@MikaelSmith Have you looked into the postgresqlPostgresPassword option in values.yaml?

## PostgreSQL admin password (used when `postgresqlUsername` is not `postgres`)
## ref: https://github.com/bitnami/bitnami-docker-postgresql/blob/master/README.md#creating-a-database-user-on-first-run (see note!)
# postgresqlPostgresPassword:

Let us know if you find any issues setting that option.

@MikaelSmith
Copy link
Contributor Author

That's only present in the postgresql chart, not the postgresql-ha chart.

@marcosbc
Copy link
Contributor

marcosbc commented May 1, 2020

Oh, you're totally right @MikaelSmith. The Bitnami PostgreSQL with Replication Manager Docker image does support the POSTGRESQL_POSTGRES_PASSWORD environment variable, so we would only need to modify the chart.

I have created an internal task for making the change. Unfortunately I cannot give an ETA for when we would start working on this.

If you would like to contribute the change by copying them from the Bitnami PostgreSQL chart, feel free to do so, we would be glad to review it!

@marcosbc marcosbc added the on-hold Issues or Pull Requests with this label will never be considered stale label May 1, 2020
@MikaelSmith
Copy link
Contributor Author

I have a few questions as I carry the implementation over. I'll raise them in a PR.

MikaelSmith added a commit to MikaelSmith/charts that referenced this issue May 5, 2020
When `postgresql.username` is not `postgres`, a new user is created that
only has permissions for the database created with `postgresql.database`
and the `postgres` user does not have a password and cannot be accessed
remotely.

This commit adds the `postgresql.postgresPassword` property that can be
used to specify the password for the `postgres` user when
`postgresql.username` is set to a different user.

Resolves bitnami#2470.
juan131 pushed a commit that referenced this issue May 6, 2020
* [bitnami/postgresql-ha] Add documentation for usePasswordFile option

The `postgresql.usePasswordFile` option was previously added to mount
passwords as a volume rather than in environment variables but was not
documented.

* [bitnami/postgresql-ha] Add postgresqlPassword option

When `postgresql.username` is not `postgres`, a new user is created that
only has permissions for the database created with `postgresql.database`
and the `postgres` user does not have a password and cannot be accessed
remotely.

This commit adds the `postgresql.postgresPassword` property that can be
used to specify the password for the `postgres` user when
`postgresql.username` is set to a different user.

Resolves #2470.
@jonathon2nd
Copy link
Contributor

This does not seem to be working at the moment, Key does not show up as mounted on the workload. Authentication for postgres user fails.

image
image

2020-12-03 17:15:07.967 GMT [1616] FATAL:  password authentication failed for user "postgres"
2020-12-03 17:15:07.967 GMT [1616] DETAIL:  Password does not match for user "postgres".
	Connection matched pg_hba.conf line 6: "host     all              all       0.0.0.0/0    md5"

@jonathon2nd
Copy link
Contributor

The password was not showing up because some of the vars were set with the global. prefix. After moving those and redeploying the secret is mounted on the workload, but authentication with postgres is still failing. There does not seem to be an issue with pgpool. The non admin user is working as expected.
image

@MikaelSmith
Copy link
Contributor Author

I believe it only works on initial setup, so if the database already exists changes wouldn't be applied. I don't have a ton of experience with this; I believe I had it working at one point, and just ported over what the non-HA versions were doing.

@jonathon2nd
Copy link
Contributor

jonathon2nd commented Dec 3, 2020

I just saw this #2061 (comment).
And that was exactly the problem. The initial problem was caused by using the global. prefix on the var.
Thank you for responding.

@carrodher carrodher removed the on-hold Issues or Pull Requests with this label will never be considered stale label Dec 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants