GitLab Scaling and High Availability
In this repository you can see a simple and initial deploy of GitLab on docker-compose. The main idea was to deploy on swarm cluster.
You can easily configure and deploy your Docker-based GitLab installation in a swarm cluster.
Create a Docker-compose.yml : cd dockerCompose
Run docker-compose up
There are a few things that we will need before we can get to Gitlab:
The Proxy
Setting up NFS
sudo apt install -y nfs-kernel-server
.
+-- /srv/gitlab-swarm/
| +-- gitlab
+-- config
+-- data
+-- logs
| +-- grafana
| +-- postgres
| +-- prometheus
We can create it using the following shell:
mkdir -p /srv/gitlab-swarm && \
mkdir -p /srv/gitlab-swarm/gitlab/{data,logs,config} && \
mkdir -p /srv/gitlab-swarm/postgres && \
mkdir -p /srv/gitlab-swarm/grafana && \
mkdir -p /srv/gitlab-swarm/prometheus && \
chmod -R 777 /srv/gitlab-swarm
mkdir -p /exports/gitlab-swarm
mount --bind /srv/gitlab-swarm /exports/gitlab-swarm
# /etc/exports
/exports/ *(rw,sync,fsid=0,crossmnt,no_subtree_check)
/exports/gitlab-swarm *(rw,sync,no_root_squash,no_subtree_check)
Now we reload the NFS configuration: exportfs -ra
we need to add the following line to /etc/fstab: /srv/gitlab-swarm/ /exports/gitlab-swarm/ none bind
Remember that we need the NFS client installed on each node of the cluster: sudo apt install -y nfs-common
To test if the NFS configuration is correct, we can try mounting the share:
mkdir /var/tmp/test-nfs && \
mount -t nfs4 127.0.0.1:/gitlab-swarm /var/tmp/test-nfs && \
grep nfs4 /proc/mounts | cut -d ' ' -f 1,2,3 && \
umount /var/tmp/test-nfs
127.0.0.1:/gitlab-swarm /var/tmp/test-nfs nfs4
Building the stack
Create the configuration files for the services we are deploying. The first one is for Gitlab itself (gitlab.rb).
The Prometheus configuration file to setup metrics collection from gitlab
The Grafana configuration file
Services
Deploying the stack
docker stack deploy -c stack.yaml gitlab
And if you access gitlab.localtest.me
you get to our Gitlab instance running on Docker Swarm.
This project is licensed under the MIT License - see the LICENSE file for details