This template is a POC to setup a Gitlab system with High Availability on Amazon Web Service Cloud.
This template is heavily inspired by Gitlab university : HA on AWS.
The project tries to follow Immutable server pattern and Infrastructure-as-Code principles by using :
- Packer to create Amazon Virtual Machine Images (AMI)
- Ansible to install and configure packages on these Virtual Machine Images when running Packer
- Terraform to create and orchestrate the cloud infrastructure
- cloud-init and jinja2-cli to finalize setup automatically when launching AWS instances from AMI
- Docker to run Continuous Integration in containers with Gitlab-CI
-
a AWS account (Be careful this template implies creating billable resources on AWS cloud)
You will need an AWS access key and enough admin permissions to create AWS ressources
-
a AWS Route 53 DNS zone already created (the template will add new subdomain DNS A records)
-
a SSH Key pair to connect to Gitlab and AWS instances (see Github help for examples)
-
Packer >= 0.12
-
Terraform >= 8.2
-
GNU Make or some Unix equivalent Implementation
-
(optional) Graphiz to generate Terraform config Graph Images
# on ubuntu/debian sudo apt-get install graphviz
git clone --recursive https://github.com/csanquer/gitlab-setup.git
- Copy and edit the configuration files :
- terraform :
terraform/terraform.dist.tfvars
toterraform/terraform.tfvars
- packer :
packer/config.dist.json
topacker/config.json
- create Amazon Machine Images :
- Gitlab
- Gitlab-CI-multirunner
make ami
- check Terraform plan
make plan
- if terraform plan is correct, create AWS resources by applying the terraform plan
make apply
- you can check again the terraform exported variables output
make output
- you can also get Graphviz graphs of all terraform config
# in PNG image format make graphs # or in SVG make graphs format=svg
After creation, wait for a few minutes the autoscaled gitlab instances finish self initialization.
if variables are set in terraform/terraform.tvars
like :
aws_dns_zone = "my-aws.net"
gitlab_dns_subdomain = "gitlab"
The Gitlab server should be available to http://gitlab.my-aws.net/
make destroy