Charmed PostgreSQL K8s
- Canonical
- Databases
Channel | Revision | Published | Runs on |
---|---|---|---|
latest/stable | 20 | 20 Sep 2022 | |
14/stable | 445 | 12 Nov 2024 | |
14/stable | 444 | 12 Nov 2024 | |
14/candidate | 463 | 19 Nov 2024 | |
14/candidate | 462 | 19 Nov 2024 | |
14/beta | 463 | 19 Nov 2024 | |
14/beta | 462 | 19 Nov 2024 | |
14/edge | 465 | 20 Nov 2024 | |
14/edge | 464 | 20 Nov 2024 |
juju deploy postgresql-k8s --channel 14/stable
Deploy Kubernetes operators easily with Juju, the Universal Operator Lifecycle Manager. Need a Kubernetes cluster? Install MicroK8s to create a full CNCF-certified Kubernetes system in under 60 seconds.
Platform:
charms.postgresql_k8s.v0.postgresql
-
- Last updated 15 Nov 2024
- Revision Library version 0.39
PostgreSQL helper class.
The postgresql
module provides methods for interacting with the PostgreSQL instance.
Any charm using this library should import the psycopg2
or psycopg2-binary
dependency.
Index
class PostgreSQLCreateDatabaseError
Description
Exception raised when creating a database fails. None
class PostgreSQLCreateUserError
Description
Exception raised when creating a user fails. None
Methods
PostgreSQLCreateUserError. __init__( self , message: str )
class PostgreSQLDatabasesSetupError
Description
Exception raised when the databases setup fails. None
class PostgreSQLDeleteUserError
Description
Exception raised when deleting a user fails. None
class PostgreSQLEnableDisableExtensionError
Description
Exception raised when enabling/disabling an extension fails. None
class PostgreSQLGetLastArchivedWALError
Description
Exception raised when retrieving last archived WAL fails. None
class PostgreSQLGetCurrentTimelineError
Description
Exception raised when retrieving current timeline id for the PostgreSQL unit fails. None
class PostgreSQLGetPostgreSQLVersionError
Description
Exception raised when retrieving PostgreSQL version fails. None
class PostgreSQLListUsersError
Description
Exception raised when retrieving PostgreSQL users list fails. None
class PostgreSQLUpdateUserPasswordError
Description
Exception raised when updating a user password fails. None
class PostgreSQL
Description
Class to encapsulate all operations related to interacting with PostgreSQL instance. None
Methods
PostgreSQL. __init__( self , primary_host: str , current_host: str , user: str , password: str , database: str , system_users )
PostgreSQL. create_database( self , database: str , user: str , plugins , client_relations )
Creates a new database and grant privileges to a user on it.
Arguments
database to be created.
user that will have access to the database.
extensions to enable in the new database.
current established client relations.
PostgreSQL. create_user( self , user: str , password: str , admin: bool , extra_user_roles: str )
Creates a database user.
Arguments
user to be created.
password to be assigned to the user.
whether the user should have additional admin privileges.
additional privileges and/or roles to be assigned to the user.
PostgreSQL. delete_user( self , user: str )
Deletes a database user.
Arguments
user to be deleted.
PostgreSQL. enable_disable_extensions( self , extensions , database: str )
Enables or disables a PostgreSQL extension.
Description
Args: extensions: the name of the extensions. database: optional database where to enable/disable the extension.
Raises: PostgreSQLEnableDisableExtensionError if the operation fails.
PostgreSQL. get_last_archived_wal( self )
Description
Get the name of the last archived wal for the current PostgreSQL cluster. None
PostgreSQL. get_current_timeline( self )
Description
Get the timeline id for the current PostgreSQL unit. None
PostgreSQL. get_postgresql_text_search_configs( self )
Returns the PostgreSQL available text search configs.
Returns
Set of PostgreSQL text search configs.
PostgreSQL. get_postgresql_timezones( self )
Returns the PostgreSQL available timezones.
Returns
Set of PostgreSQL timezones.
PostgreSQL. get_postgresql_version( self , current_host )
Returns the PostgreSQL version.
Returns
PostgreSQL version number.
PostgreSQL. is_tls_enabled( self , check_current_host: bool )
Returns whether TLS is enabled.
Arguments
whether to check the current host instead of the primary host.
Returns
whether TLS is enabled.
PostgreSQL. list_users( self )
Returns the list of PostgreSQL database users.
Returns
List of PostgreSQL database users.
PostgreSQL. list_valid_privileges_and_roles( self )
Returns two sets with valid privileges and roles.
Returns
Tuple containing two sets: the first with valid privileges and the second with valid roles.
PostgreSQL. set_up_database( self )
Description
Set up postgres database with the right permissions. None
PostgreSQL. update_user_password( self , username: str , password: str , database_host: str )
Update a user password.
Description
Args: username: the user to update the password. password: the new password for the user. database_host: the host to connect to.
Raises: PostgreSQLUpdateUserPasswordError if the password couldn't be changed.
PostgreSQL. is_restart_pending( self )
Description
Query pg_settings for pending restart. None
PostgreSQL. build_postgresql_parameters( config_options: Dict , available_memory: int , limit_memory )
Builds the PostgreSQL parameters.
Arguments
charm config options containing profile and PostgreSQL parameters.
available memory to use in calculation in bytes.
(optional) limit memory to use in calculation in bytes.
Returns
Dictionary with the PostgreSQL parameters.
PostgreSQL. validate_date_style( self , date_style: str )
Validate a date style against PostgreSQL.
Returns
Whether the date style is valid.