---
title: Charmhub | Deploy PgBouncer K8s using Charmhub - The Open Operator Collection
description: Deploy the latest version of PgBouncer K8s as a Kubernetes Operator on
  any cloud.
url: https://charmhub.io/pgbouncer-k8s/docs/t-managing-units
---

# PgBouncer K8s

[Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")

* [Canonical](https://charmhub.io/publisher/data-platform "View all packages from Canonical")
* [Databases](https://charmhub.io/?filter=databases)

Platform:

1/stable 593

```
juju deploy pgbouncer-k8s --channel 1/stable --trust
```

[Learn to deploy on juju >](https://juju.is/docs/juju/manage-applications)

---

#### Relevant links

* [Homepage](https://ubuntu.com/data/postgresql)

---

#### Contacts

##### Maintainers

+ [Canonical Data Platform](mailto:data-platform@lists.launchpad.net)

* [Submit a bug](https://github.com/canonical/pgbouncer-k8s-operator/issues)

---

Share your thoughts on this charm with the community on discourse.

[Join the discussion](https://discourse.charmhub.io/)

# Scale your PgBouncer K8s

This is part of the [PgBouncer K8s Tutorial](https://charmhub.io/pgbouncer-k8s/docs/tutorial). Please refer to this page for more information and the overview of the content.

## [Adding and Removing units](https://charmhub.io/pgbouncer-k8s/docs/t-managing-units#p-28301-adding-and-removing-units)

Please check the explanation of scaling Charmed PostgreSQL K8s operator [here](https://charmhub.io/postgresql-k8s/docs/t-scale).

### [Add more PgBouncer instances](https://charmhub.io/pgbouncer-k8s/docs/t-managing-units#p-28301-add-more-pgbouncer-instances)

You can add two more units to your deployed PgBouncer application by scaling it using:

```
juju scale-application pgbouncer-k8s 3
```

You can now watch the scaling process in live using: `juju status --watch 1s`. It usually takes several minutes for new cluster members to be added. You’ll know that all three nodes are in sync when `juju status` reports `Workload=active` and `Agent=idle`:

```
Model   Controller  Cloud/Region        Version  SLA          Timestamp
test16  microk8s    microk8s/localhost  3.1.6    unsupported  22:16:20+02:00

App              Version  Status  Scale  Charm            Channel    Rev  Address         Exposed  Message
data-integrator           active      1  data-integrator  stable      13  10.152.183.136  no
pgbouncer-k8s    1.18.0   active      3  pgbouncer-k8s    1/stable    76  10.152.183.84   no
postgresql-k8s   14.9     active      1  postgresql-k8s   14/stable  158  10.152.183.92   no       Primary

Unit                Workload  Agent  Address     Ports  Message
data-integrator/0*  active    idle   10.1.12.16
pgbouncer-k8s/0*    active    idle   10.1.12.15
pgbouncer-k8s/1     active    idle   10.1.12.61
pgbouncer-k8s/2     active    idle   10.1.12.50
postgresql-k8s/0*   active    idle   10.1.12.6          Primary
```

You can scale Charmed PostgreSQL in the same way:

```
juju scale-application postgresql-k8s 3
```

Make sure all units are active using `juju status`:

```
Model   Controller  Cloud/Region        Version  SLA          Timestamp
test16  microk8s    microk8s/localhost  3.1.6    unsupported  22:18:00+02:00

App              Version  Status  Scale  Charm            Channel    Rev  Address         Exposed  Message
data-integrator           active      1  data-integrator  stable      13  10.152.183.136  no
pgbouncer-k8s    1.18.0   active      3  pgbouncer-k8s    1/stable    76  10.152.183.84   no
postgresql-k8s   14.9     active      3  postgresql-k8s   14/stable  158  10.152.183.92   no

Unit                Workload  Agent  Address     Ports  Message
data-integrator/0*  active    idle   10.1.12.16
pgbouncer-k8s/0*    active    idle   10.1.12.15
pgbouncer-k8s/1     active    idle   10.1.12.61
pgbouncer-k8s/2     active    idle   10.1.12.50
postgresql-k8s/0*   active    idle   10.1.12.6          Primary
postgresql-k8s/1    active    idle   10.1.12.35
postgresql-k8s/2    active    idle   10.1.12.39
```

### [Remove extra members](https://charmhub.io/pgbouncer-k8s/docs/t-managing-units#p-28301-remove-extra-members)

Removing a unit from the application scales the replicas down.

```
juju scale-application pgbouncer-k8s 2
```

```
juju scale-application postgresql-k8s 2
```

You’ll know that the replica was successfully removed when `juju status --watch 1s` reports:

```
Model   Controller  Cloud/Region        Version  SLA          Timestamp
test16  microk8s    microk8s/localhost  3.1.6    unsupported  22:19:10+02:00

App              Version  Status  Scale  Charm            Channel    Rev  Address         Exposed  Message
data-integrator           active      1  data-integrator  stable      13  10.152.183.136  no
pgbouncer-k8s    1.18.0   active      2  pgbouncer-k8s    1/stable    76  10.152.183.84   no
postgresql-k8s   14.9     active      2  postgresql-k8s   14/stable  158  10.152.183.92   no

Unit                Workload  Agent  Address     Ports  Message
data-integrator/0*  active    idle   10.1.12.16
pgbouncer-k8s/0*    active    idle   10.1.12.15
pgbouncer-k8s/1     active    idle   10.1.12.61
postgresql-k8s/0*   active    idle   10.1.12.6          Primary
postgresql-k8s/1    active    idle   10.1.12.35
```

---
