GitLab - Install GitLab Runner on Amazon Linux 2
GitLab is a powerful, all-in-one package for use as a source code repository as well as a full continuous integration / continuous deployment (CI/CD) suite. Using GitLab on AWS for implementing CI/CD tasks is made possible by using an EC2 Instance that’s allocated for use by GitLab as a “runner.” Runners execute the commands included in the pipeline definition. This document walks through the steps used to install the runner software. The software is installed on a typical AWS EC2 Instance running Amazon Linux 2 as an OS. If you’d like to follow along using this blog in a simple proof-of-concept (PoC), it’s acceptable to use choose a free tier option.
Prerequisites
The runner has to have a communication channel to the main GitLab server. Ports 80, and/or 443 need to be opened based on the configuration of the GitLab server. This is accomplished via a modification of the AWS Security group(s) regulating EC2 access. Access can be validated via a curl command from the runner vm to the GitLab server.
Steps
Update the instance with the latest packages
sudo yum update -y
Add the repository of the package
curl -L https://packages.gitlab.com/install/repositories/runner/gitlab-runner/script.deb.sh | sudo bash
3. Download the package for RHEL/CentOS/Fedora
sudo curl -L --output /usr/local/bin/gitlab-runner https://gitlab-runner-downloads.s3.amazonaws.com/latest/binaries/gitlab-runner-linux-386
4. Install the Package
export GITLAB_RUNNER_DISABLE_SKEL=true; sudo -E yum install gitlab-runner
5. Register the runner - When registering the the runner, there are options. In this case, guidance for a "Specific Runner” is used
sudo gitlab-runner register
During registration, you'll be asked a number of questions. The PoC keeps the answers simple.
Please enter the gitlab-ci coordinator URL (e.g. https://gitlab.com/):
<URL of the GitLab Server to conne to>
Please enter the gitlab-ci token for this runner:
<Token is provided by the GitLab server>
Please enter the gitlab-ci description for this runner:
<This can be something simple>
Please enter the gitlab-ci tags for this runner (comma separated):
<leave blank>
After this, the runner should have connectivity to the GitLab server.
References
https://docs.gitlab.com/runner/install/linux-repository.html
Registering Runners - https://docs.gitlab.com/runner/register/index.html
https://medium.com/@journald/gitlab-runner-setup-on-ec2-instance-centos-7-3b49f4b43132