Charmed PostgreSQL K8s

  • By Canonical Data Platform
Channel Revision Published Runs on
latest/stable 20 20 Sep 2022
Ubuntu 20.04
14/stable 73 18 Apr 2023
Ubuntu 22.04
14/candidate 73 18 Apr 2023
14/beta 73 18 Apr 2023
14/edge 92 Yesterday
juju deploy postgresql-k8s --channel 14/stable
Show information

Platform:

Manage Passwords

This is part of the Charmed PostgreSQL Tutorial. Please refer to this page for more information and the overview of the content.

Passwords

When we accessed PostgreSQL earlier in this tutorial, we needed to use a password manually. Passwords help to secure our database and are essential for security. Over time it is a good practice to change the password frequently. Here we will go through setting and changing the password for the admin user.

Retrieve the password

As previously mentioned, the operator’s password can be retrieved by running the get-password action on the Charmed PostgreSQL K8s application:

juju run-action postgresql-k8s/leader get-password --wait

Running the command should output:

unit-postgresql-k8s-0:
  UnitId: postgresql-k8s/0
  id: "6"
  results:
    password: SYhCduijXTAfg9mU
  status: completed
  timing:
    completed: 2023-03-20 11:10:33 +0000 UTC
    enqueued: 2023-03-20 11:10:32 +0000 UTC
    started: 2023-03-20 11:10:33 +0000 UTC

Rotate the password

You can change the operator’s password to a new random password by entering:

juju run-action postgresql-k8s/leader set-password --wait

Running the command should output:

unit-postgresql-k8s-0:
  UnitId: postgresql-k8s/0
  id: "8"
  results:
    password: 7CYrRiBrC4du3ToX
  status: completed
  timing:
    completed: 2023-03-20 11:10:47 +0000 UTC
    enqueued: 2023-03-20 11:10:46 +0000 UTC
    started: 2023-03-20 11:10:47 +0000 UTC

Please notice the status: completed above which means the password has been successfully updated. The password should be different from the previous password.

Set the new password

You can change the password to a specific password by entering:

juju run-action postgresql-k8s/leader set-password password=my-password --wait

Running the command should output:

unit-postgresql-k8s-0:
  UnitId: postgresql-k8s/0
  id: "10"
  results:
    password: my-password
  status: completed
  timing:
    completed: 2023-03-20 11:11:06 +0000 UTC
    enqueued: 2023-03-20 11:11:02 +0000 UTC
    started: 2023-03-20 11:11:05 +0000 UTC

The password should match whatever you passed in when you entered the command.


Help us improve this documentation

Most of this documentation can be collaboratively discussed and changed on the respective topic in the doc category of the Charmhub forum. See the documentation guidelines if you’d like to contribute.

Last updated a month ago. Help improve this document in the forum.