> Source: https://docs.cyberelements.io/bastion/4.7/Installation/Dependencies/PostgreSQLCluster/PostgreSQLClusterIntroduction/

# Introduction

A virtual appliance can be used to deploy a PostgreSQL cluster.
This PostgreSQL cluster is typically operated with CyberElements Bastion platforms with cluster architecture to ensure end-to-end redundancy.

> **Note**
>
> Please note that the operation and updating of virtual appliances provided by Systancia are the responsibility of the Customer as defined in [the product lifecycle](https://docs.cyberelements.io/ProductLifeCycle/OSAndThirdPartySoftwareSupport/#virtual-appliances).

The virtual appliance includes all the components needed to deploy a PostgreSQL cluster, as well as a utility to facilitate its installation. It can be downloaded from the Systancia Marketplace (requires creation of a customer account): [Systancia Marketplace](https://www.systancia.com/en/my-systancia/marketplace/systancia-cleanroom/downloads-cleanroom/)

The PostgreSQL cluster is based on three PostgreSQL nodes and the use of a virtual IP address.
The use of three nodes ensures service resilience even if one node is lost (two active nodes being the minimum). This works using the following components:

- [Patroni](https://github.com/patroni/patroni)
- [Etcd](https://etcd.io/)
- [Keepalived](https://keepalived.org/)

Together, they allow automated management of virtual IP and replication.

This PostgreSQL cluster does not have a node that is always designated as `LEADER`; the `LEADER` alternates depending on the circumstances encountered by the cluster. If the `LEADER` were to fail, a new `LEADER` would be elected by absolute majority and the virtual IP would switch to the latter. Note that it takes approximately 20 seconds to reliably identify the loss of the `LEADER` and switch the virtual IP to the new `LEADER`.
The `LEADER` node is the only one with read/write access to the PostgreSQL database; the `REPLICA` nodes are read-only.

The typical architecture of a CyberElements Bastion cluster based on a PostgreSQL cluster is as follows:

To install a PostgreSQL cluster with CyberElements virtual appliances, please follow the steps below:

- (1) **[Prerequisites](https://docs.cyberelements.io/bastion/4.7/Installation/Dependencies/PostgreSQLCluster/Installation/Prerequisites/)**

  ---

  Defining the prerequisites for the PostgreSQL cluster.
- (2) **[Import the virtual appliance](https://docs.cyberelements.io/bastion/4.7/Installation/Dependencies/PostgreSQLCluster/Installation/Importation/)**

  ---

  The virtual appliance must be imported three times to prepare for the installation of the PostgreSQL cluster.
- (3) **[Install the PostgreSQL cluster](https://docs.cyberelements.io/bastion/4.7/Installation/Dependencies/PostgreSQLCluster/Installation/Install/)**

  ---

  Instructions for configuring and installing the PostgreSQL cluster.
