Configuring GitLab for HA

Configuring GitLab for HA

Assuming you have already configured a database, Redis, and NFS, you can
configure the GitLab application server(s) now. Complete the steps below
for each GitLab application server in your environment.

Note: There is some additional configuration near the bottom for
additional GitLab application servers. It's important to read and understand
these additional steps before proceeding with GitLab installation.

If necessary, install the NFS client utility packages using the following
commands:

Specify the necessary NFS shares. Mounts are specified in
/etc/fstab. The exact contents of /etc/fstab will depend on how you chose
to configure your NFS server. See NFS documentation for the various
options. Here is an example snippet to add to /etc/fstab:

Download/install GitLab Omnibus using steps 1 and 2 from
GitLab downloads. Do not complete other
steps on the download page.

Create/edit /etc/gitlab/gitlab.rb and use the following configuration.
Be sure to change the external_url to match your eventual GitLab front-end
URL. Depending your the NFS configuration, you may need to change some GitLab
data locations. See NFS documentation for /etc/gitlab/gitlab.rb
configuration values for various scenarios. The example below assumes you've
added NFS mounts in the default data locations.

external_url'https://gitlab.example.com'# Prevent GitLab from starting if NFS data mounts are not availablehigh_availability['mountpoint']='/var/opt/gitlab/git-data'# Disable components that will not be on the GitLab application serverroles['application_role']# PostgreSQL connection detailsgitlab_rails['db_adapter']='postgresql'gitlab_rails['db_encoding']='unicode'gitlab_rails['db_host']='10.1.0.5'# IP/hostname of database servergitlab_rails['db_password']='DB password'# Redis connection detailsgitlab_rails['redis_port']='6379'gitlab_rails['redis_host']='10.1.0.6'# IP/hostname of Redis servergitlab_rails['redis_password']='Redis Password'

Note: To maintain uniformity of links across HA clusters, the external_url
on the first application server as well as the additional application
servers should point to the external url that users will use to access GitLab.
In a typical HA setup, this will be the url of the load balancer which will
route traffic to all GitLab application servers in the HA cluster.

Run sudo gitlab-ctl reconfigure to compile the configuration.

First GitLab application server

As a final step, run the setup rake task on the first GitLab application server.
It is not necessary to run this on additional application servers.

Initialize the database by running sudo gitlab-rake gitlab:setup.

WARNING: Only run this setup task on NEW GitLab instances because it
will wipe any existing data.

Note: When you specify https in the external_url, as in the example
above, GitLab assumes you have SSL certificates in /etc/gitlab/ssl/. If
certificates are not present, Nginx will fail to start. See
Nginx documentation
for more information.

Extra configuration for additional GitLab application servers

Configure shared secrets. These values can be obtained from the primary
GitLab server in /etc/gitlab/gitlab-secrets.json. Add these to
/etc/gitlab/gitlab.rbprior to running the first reconfigure in
the steps above.