{"id":38171219,"url":"https://github.com/canonical/postgresql-operator","last_synced_at":"2026-01-16T23:26:52.240Z","repository":{"id":40481417,"uuid":"422321785","full_name":"canonical/postgresql-operator","owner":"canonical","description":"A Charmed Operator for running PostgreSQL on machines","archived":false,"fork":false,"pushed_at":"2026-01-11T02:17:54.000Z","size":175070,"stargazers_count":11,"open_issues_count":107,"forks_count":27,"subscribers_count":11,"default_branch":"main","last_synced_at":"2026-01-11T10:16:30.677Z","etag":null,"topics":["charm","data-platform","postgresql","python"],"latest_commit_sha":null,"homepage":"https://charmhub.io/postgresql","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/canonical.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2021-10-28T18:55:00.000Z","updated_at":"2026-01-09T13:42:06.000Z","dependencies_parsed_at":"2026-01-09T08:06:50.553Z","dependency_job_id":null,"html_url":"https://github.com/canonical/postgresql-operator","commit_stats":null,"previous_names":[],"tags_count":684,"template":false,"template_full_name":null,"purl":"pkg:github/canonical/postgresql-operator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canonical%2Fpostgresql-operator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canonical%2Fpostgresql-operator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canonical%2Fpostgresql-operator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canonical%2Fpostgresql-operator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/canonical","download_url":"https://codeload.github.com/canonical/postgresql-operator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/canonical%2Fpostgresql-operator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":28487586,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-01-16T22:54:02.790Z","status":"ssl_error","status_checked_at":"2026-01-16T22:50:10.344Z","response_time":107,"last_error":"SSL_connect returned=1 errno=0 peeraddr=140.82.121.6:443 state=error: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["charm","data-platform","postgresql","python"],"created_at":"2026-01-16T23:26:52.116Z","updated_at":"2026-01-16T23:26:52.219Z","avatar_url":"https://github.com/canonical.png","language":"Python","readme":"# Charmed PostgreSQL VM Operator\n\n[![CharmHub Badge](https://charmhub.io/postgresql/badge.svg)](https://charmhub.io/postgresql)\n[![Release](https://github.com/canonical/postgresql-operator/actions/workflows/release.yaml/badge.svg)](https://github.com/canonical/postgresql-operator/actions/workflows/release.yaml)\n[![Tests](https://github.com/canonical/postgresql-operator/actions/workflows/ci.yaml/badge.svg?branch=main)](https://github.com/canonical/postgresql-operator/actions/workflows/ci.yaml?query=branch%3Amain)\n[![codecov](https://codecov.io/gh/canonical/postgresql-operator/graph/badge.svg?token=4V2mu7aWmu)](https://codecov.io/gh/canonical/postgresql-operator)\n\n\nThis repository contains a charmed operator for deploying [PostgreSQL](https://www.postgresql.org/about/) on virtual machines via the [Juju orchestration engine](https://juju.is/).\n\nTo learn more about how to deploy and operate Charmed PostgreSQL, see the [official documentation](https://canonical-charmed-postgresql.readthedocs-hosted.com/).\n\n## Overview\n\nThis operator provides a PostgreSQL database with replication enabled: one primary instance and one (or more) hot standby replicas. The Operator in this repository is a Python script which wraps PostgreSQL versions distributed by Ubuntu Jammy series and adding [Patroni](https://github.com/zalando/patroni) on top of it, providing lifecycle management and handling events (install, configure, integrate, remove, etc).\n  \n## Basic usage\n\n### Deployment\n\nBootstrap a [lxd controller](https://juju.is/docs/olm/lxd#heading--create-a-controller) and create a new Juju model:\n\n```shell\njuju add-model sample-model\n```\n\nTo deploy a single unit of PostgreSQL using its [default configuration](config.yaml), run the following command:\n\n```shell\njuju deploy postgresql --channel 14/stable\n```\n\nIt is customary to use PostgreSQL with replication to ensure high availability. A replica is equivalent to a juju unit.\n\nTo deploy PostgreSQL with multiple replicas, specify the number of desired units with the `-n` option:\n\n```shell\njuju deploy postgresql --channel 14/stable -n \u003cnumber_of_units\u003e\n```\n\nTo add replicas to an existing deployment, see the [Add replicas](#add-replicas) section.\n\n\u003e[!TIP]\n\u003eIt is generally recommended to have an odd number of units to avoid a \"[split-brain](https://en.wikipedia.org/wiki/Split-brain_(computing))\" scenario\n\n### Primary replica\n\nTo retrieve the primary replica, use the action `get-primary` on any of the units running PostgreSQL.\n\n```shell\njuju run postgresql/leader get-primary\n```\n\nSimilarly, the primary replica is displayed as a status message in `juju status`. Note that this hook gets called at regular time intervals, so the primary may be outdated if the status hook has not been called recently.\n\n### Replication\n\n#### Add replicas\n\nTo add more replicas one can use the `juju add-unit` functionality i.e.\n\n```shell\njuju add-unit postgresql -n \u003cnumber_of_units_to_add\u003e\n```\n\nThe implementation of `add-unit` allows the operator to add more than one unit, but functions internally by adding one replica at a time. This is done to avoid multiple replicas syncing from the primary at the same time.\n\n#### Remove replicas\n\nTo scale down the number of replicas the `juju remove-unit` functionality may be used i.e.\n\n```shell\njuju remove-unit postgresql \u003cname_of_unit_1\u003e \u003cname_of_unit_2\u003e\n```\n\nThe implementation of `remove-unit` allows the operator to remove more than one unit. The functionality of `remove-unit` functions by removing one replica at a time to avoid downtime.\n\n### Password rotation\n\n#### Charm users\n\nTo rotate the password of users internal to the Charmed PostgreSQL operator, use the `set-password` action as follows:\n\n```shell\njuju run postgresql/leader set-password username=\u003cuser\u003e password=\u003cpassword\u003e\n```\n\n\u003e[!NOTE]\n\u003eCurrently, internal users are `operator`, `replication`, `backup` and `rewind`. These users should not be used outside the operator.\n\n#### Integrated (related) application users\n\nTo rotate the passwords of users created for integrated applications, the integration to Charmed PostgreSQL should be removed and re-created. This process will generate a new user and password for the application (and remove the old user).\n\n## Integrations (Relations)\n\nSupported [integrations](https://juju.is/docs/olm/relations):\n\n#### New `postgresql_client` interface\n\nCurrent charm relies on [Data Platform libraries](https://charmhub.io/data-platform-libs). Your\napplication should define an interface in `metadata.yaml`:\n\n```yaml\nrequires:\n  database:\n    interface: postgresql_client\n```\n\nPlease read the usage documentation of the\n[data_interfaces](https://charmhub.io/data-platform-libs/libraries/data_interfaces) library for\nmore information about how to enable a PostgreSQL interface in your application.\n\nRelations to new applications are supported via the `postgresql_client` interface. To create a\nrelation to another application:\n\njuju `v2.x`:\n\n```shell\njuju relate postgresql \u003capplication_name\u003e\n```\n\njuju `v3.x`:\n\n```shell\njuju integrate postgresql \u003capplication_name\u003e\n```\n\nTo remove a relation:\n\n```shell\njuju remove-relation postgresql \u003capplication_name\u003e\n```\n\n#### Legacy `pgsql` interface\n\nWe have also added support for the two database legacy relations from the [original version](https://launchpad.net/postgresql-charm) of the charm via the `pgsql` interface. Please note that these relations will be deprecated.\n\n ```shell\njuju relate postgresql:db mailman3-core\njuju relate postgresql:db-admin landscape-server\n```\n\n#### `tls-certificates` interface\n\nThe Charmed PostgreSQL Operator also supports TLS encryption on internal and external connections. Below is an example of enabling TLS with the [self-signed certificates charm](https://charmhub.io/self-signed-certificates).\n\n```shell\n# Deploy the self-signed certificates TLS operator. \njuju deploy self-signed-certificates --config ca-common-name=\"Example CA\"\n\n# Enable TLS via relation.\njuju integrate postgresql self-signed-certificates\n\n# Disable TLS by removing relation.\njuju remove-relation postgresql self-signed-certificates\n```\n\n\u003e[!WARNING]\n\u003eThe TLS settings shown here are for self-signed-certificates, which are not recommended for production clusters. See the guide [Security with X.509 certificates](https://charmhub.io/topics/security-with-x-509-certificates) for an overview of available certificates charms.\n\n## Security\n\nSecurity issues in the Charmed PostgreSQL Operator can be reported through [private security reports](https://github.com/canonical/postgresql-operator/security/advisories/new) on GitHub.\nFor more information, see the [Security policy](SECURITY.md).\n\n## Contributing\n\n* For best practices on how to write and contribute to charms, see the [Juju SDK docs](https://juju.is/docs/sdk/how-to)\n* For more specific developer guidance for contributions to Charmed PostgreSQL, see the file [CONTRIBUTING.md](CONTRIBUTING.md)\n* Report security issues for the Charmed PostgreSQL Operator through [LaunchPad](https://wiki.ubuntu.com/DebuggingSecurity#How%20to%20File).\n* Report technical issues, bug reports and feature requests through the [GitHub Issues tab](https://github.com/canonical/postgresql-operator/issues).\n\n## Licensing and trademark\n\nThe Charmed PostgreSQL Operator is distributed under the [Apache Software License, version 2.0](https://github.com/canonical/postgresql-operator/blob/main/LICENSE). It installs, operates and depends on [PostgreSQL](https://www.postgresql.org/ftp/source/), which is licensed under the [PostgreSQL License](https://www.postgresql.org/about/licence/), a liberal Open Source license similar to the BSD or MIT licenses.\n\nPostgreSQL is a trademark or registered trademark of PostgreSQL Global Development Group. Other trademarks are property of their respective owners.\n","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanonical%2Fpostgresql-operator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fcanonical%2Fpostgresql-operator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fcanonical%2Fpostgresql-operator/lists"}