Step-by-Step Guide: Setting Up GitLab Runner on AWS

Step-by-Step Guide: Setting Up GitLab Runner on AWS for Optimal Performance

Introduction:

Meetix GitLab Auto Scaling Runner enables you to automatically scale your CI/CD infrastructure based on workload demands, ensuring smooth and cost-effective pipeline execution.

Prerequisites:

Before you begin, make sure you meet the following prerequisites:

  1. Basic AWS Knowledge: Familiarity with AWS services, EC2 instances, and AWS Identity and Access Management (IAM) is required.
  2. GitLab & CI/CD Knowledge: Understanding of GitLab CI/CD concepts, including runners, pipelines, and jobs.

Create GitLab token:

  1. Navigate to your GitLab project.
  2. Go to "Settings" and select "CI/CD".
  3. Within the "CI/CD Settings," locate and expand the "Runners" section.
  4. Click on "New Project Runner". On the "New Project Runner" page.

Provide the following details:

  • Operating System: Linux
  • Check the box for "Run untagged jobs" in Tags.
  • Add a "Runner Description".
  • Unselect "Paused", "Protected" and "Lock to current projects".
  • Enter a maximum job timeout (recommended: 1800 seconds).

5. Finally, click the "Create Runner" button. You will receive an alert confirming the runner's creation.

6. Copy the "runner token" for later use.

These steps will allow you to create a GitLab token, which is essential for configuring your GitLab Runner in the setup process.

Launching the AMI:

Find and Launch the AMI:

  • Visit the AWS Marketplace "Gitlab autoscaling runner for CI/CD by meetrix"
  • Click "Continue to Subscribe" to begin the subscription process.
  • After subscribing, you will need to accept the terms and conditions. Click on "Accept Terms" to proceed.
  • Please wait for a few minutes while the processing takes place. Once it's completed, click on "Continue to Configuration" to customize the instance according to your specific requirements.

Initial Setup & Configuration:

  • Select your prefered region in "Configure this software" page and click "Continue to Launch" button.
  • Select "Launch CloudFormation" in "Choose Action".
  • Click "Launch" button.

Create Stack:

Step1: Create stack

  1. Ensure the "Template is ready" radio button is selected under "Prepare template".

click "Next"

Step2: Specify stack options

  1. Provide a unique "Stack name".
  2. For "DeploymentName", enter a name of your choice.
  3. Select your preferred "keyName".
  4. Choose an instance type (Recommended: t3.medium).
  5. Paste the copied "GitLab Runner token" in the "RunnerToken" field.
  6. Set "SSHLocation" as "0.0.0.0/0."
  7. Click "Next."

Step3: Configure stack options

  1. Under stack failure options, select "Roll back all stack resources".
  2. click "Next"

Step4: Review

  1. Review and verify the details you've entered.
  1. Tick the box that says, "I acknowledge that AWS CloudFormation might create IAM resources with custom names".
  1. click "Submit".

Afterward, you'll be directed to the CloudFormation stacks page.

You can easily locate the corresponding stack by searching for the stack name you entered in Step 2.

The stack will be successfully created in a few minutes.

Run pipeline:

To verify the GitLab Runner, follow these steps:

  1. Go to your GitLab project.
  2. Settings CI/CD > expand runners.
  3. Disable shared runners.
  1. Click on "Pipelines" under "Build."
  2. Select "Run pipeline".
  3. In the "Run Pipeline" page, choose the branch name as "master" or your preferred branch.
  4. Click the "Run pipeline" button.

The pipeline will run successfully in a few minutes.

Troubleshooting & Common Issues:

Common Problems Resolutions
Runner not picking up jobs. Double-check runner registration and configuration.
Permission issues on the EC2 instance. Review IAM roles and permissions.
Network connectivity problems. Verify network settings and security groups.

Shutting Down & Relaunching:

Shutting Down the Runner:

  • Ensure all running jobs are completed.
  • Click "Remove runner" button of the created project runner in runners in cicd settings
  • Delete the created stack in the AWS Management Console under CloudFormation Stacks.

Technical Support:

  • Reach out to Meetrix Support (support@meetrix.io) ¬†for assistance with GitLab runner issues.
Discover Seamless Meetings with >>>
Meetrix