The high availability mode places requirements on the nodes, the network and the passwords before Enabling and deployment starts. What the mode consists of is described in High availability architecture.

Nodes

The cluster runs on nodes with the Linux package installation. Each node is a separate installation of the package with its own /etc/gitlab/gitlab.rb. The mode sets no upper limit on the number of nodes. What each layer needs:

  • PostgreSQL runs on every node of the cluster: one primary server and the others standby servers. The settings floor grows with every node listed in postgresql['ha_peers'], so the replication slots fit all the standby servers.
  • Sentinel runs on three or more nodes with sentinel['quorum'] = 2. With two Sentinel nodes the quorum of 2 is never reached and a Redis failover never starts. Two nodes are therefore enough for PostgreSQL high availability but give no automatic Redis failover.
  • Gitaly and Praefect run on every node: every repository is kept on three Gitaly nodes, and when one of them fails, Praefect serves the requests from the two remaining copies.
  • The application stack runs on every node of the cluster: nginx, Puma, Sidekiq and the other services of the package.

The reference cluster is three identical nodes: every node runs the full stack — the application, Redis, Sentinel and PostgreSQL, with one primary server and two standby servers. The cluster survives the failure of any one node: the Sentinel quorum of 2 out of 3 is still reached, and the database either keeps running or is promoted from a surviving standby server with the commands on the Operations page. The deployment examples on Enabling and deployment use this topology. The package version and the bundled PostgreSQL major version are the same on every database node.

Network

All nodes sit in one L2 network segment: the virtual IP addresses move between the nodes with VRRP (Virtual Router Redundancy Protocol), which does not cross routers. A dedicated network interface can be assigned to the cluster. The addresses of the other nodes go into keepalived['unicast_peers'] regardless.

Multicast is not used: VRRP runs in unicast mode between the peer addresses, and the keepalived nodes detect each other’s availability through these VRRP packets. Allow the VRRP traffic (IP protocol 112) between the node addresses on the cluster interface.

The cluster uses two free IP addresses of the segment as virtual ones: the frontend virtual IP address for users and the database virtual IP address for PostgreSQL clients. The frontend virtual IP address is the address users open, so external_url and the TLS certificate name it.

PortWho connectsPurpose
VRRP (IP protocol 112)Every keepalived node to the other nodesThe nodes detect each other’s availability
5432Database nodes to each other, clients through the database virtual IP addressPostgreSQL: replication, peer checks, client connections
6379Redis nodes to each otherRedis replication
26379Sentinel nodes to each other, every node of the clusterSentinel monitoring and client requests
8075Praefect of every node to every Gitaly nodeGitaly: the repository storage of the cluster
2305Rails and gitlab-shell of the node, to the local Praefect onlyPraefect: routing of repository requests
80, 443, 22Users, to the frontend virtual IP address onlyThe web interface and Git over SSH

Keep port 5432 reachable from the cluster subnet only: clients must connect through the database virtual IP address, which sits on the current primary server. The database listens on all interfaces, so the database virtual IP address is always accepted — this subnet rule and the pg_hba.conf entries rendered from postgresql['md5_auth_cidr_addresses'] are what limit access to it. The web and SSH ports need no rules between the nodes: the availability of the web chain is probed locally on each node, and the nodes exchange only the VRRP packets and the database and Redis connections listed above.

Passwords

The cluster uses passwords and tokens shared by every node. Each is stored as a literal value in /etc/gitlab/gitlab.rb on every node and is used by the components to authenticate to each other:

PasswordUsed by
postgresql['ha_replication_password']The standby server connects to the primary server for streaming replication
postgresql['ha_check_password'] (with postgresql['ha_check_user'])Failover peer checks and the start guard
postgresql['ha_rewind_password'] (with postgresql['ha_rewind_user'])pg_rewind on the rejoin of a fenced node
redis['password']Redis replication and the application connection to Redis
The Gitaly token (the gitaly['configuration'] block)Praefect connects to the Gitaly nodes of the cluster
The Praefect token (the praefect['configuration'] block)The application and gitlab-shell connect to Praefect
The Praefect database password (the praefect['configuration'] block)Praefect connects to the praefect_production database

Pick the values with gitlab-ctl pg-password-md5 <USER>: type a random secret at the prompt and use its output as the password value. Do not use whitespace, quotes or backslashes in the values: they are embedded into connection strings.

The components use the ha_* values as literal secrets. gitlab-ctl reconfigure itself computes and stores the database-side hashes. With postgresql['sql_replication_password'] set next to postgresql['ha_replication_password'], gitlab-ctl reconfigure fails.

The db_password and sql_user_password pair is needed from the first run of gitlab-ctl reconfigure with postgresql['listen_address'] set: with the address set, the application connects to the database over TCP instead of the unix socket, and TCP connections authenticate with a password. The deployment sets both on the database nodes.

Besides the passwords, two files must be identical on every node: /etc/gitlab/gitlab-secrets.json, the Rails encryption keys, and the host keys of the SSH service.

Both files are copied from the first node during the deployment. The step is part of Enabling and deployment.

What is not covered

The limitations of the mode are listed in High availability architecture. The ones that affect planning: the failover is manual, a PostgreSQL major upgrade goes through a switchover, and the repositories of an instance moved from a single-node installation need a migration into the cluster layout. Backups still cover the whole instance (see Backup and restore).

Additional resources