AWS, Cloud Computing, DevOps

3 Mins Read

Setting Up a Self-Managed GitLab and Integrating It with AWS CodePipeline

Voiced by Amazon Polly

Overview

GitLab is a powerful DevOps platform that allows teams to collaborate on code, manage CI/CD pipelines, and ensure efficient software delivery. This blog establishes a self-managed GitLab instance on a ubuntu server and demonstrates how to connect it with AWS CodePipeline to automate deployments.

Pioneers in Cloud Consulting & Migration Services

  • Reduced infrastructural costs
  • Accelerated application deployment
Get Started

Introduction

A self-managed GitLab instance controls repository management, security policies, and CI/CD workflows. Hosting GitLab on an Amazon EC2 instance or an on-premises server offers flexibility and integration capabilities. AWS CodePipeline enables continuous integration and deployment by automating the build, test, and release process. By connecting GitLab with AWS CodePipeline, teams can streamline their software delivery pipeline efficiently.

Steps to Set Up GitLab Self-Managed

Step 1: Install Required Dependencies

Run the following commands to install the necessary dependencies for GitLab:

Step 2: Enable and Start OpenSSH Server

Ensure that the OpenSSH server daemon is enabled and running:

If it is not running, enable and start the service:

Step 3: Configure Firewall Rules

Check if firewalld is running:

If firewalld is active, allow HTTP and HTTPS traffic:

Step 4: Install GitLab

Download and install GitLab Community Edition:

Step 5: Reconfigure GitLab

After installation, reconfigure GitLab:

Retrieve the initial root password from:

Connecting GitLab with AWS CodePipeline

Step 1: Create an AWS IAM Role for CodePipeline

  1. Navigate to the AWS IAM console.
  2. Create a new AWS IAM role with the following permissions:
    1. AWSCodePipelineFullAccess
    2. AWSCodeBuildAdminAccess
    3. AmazonS3FullAccess (if using S3 for artifacts)
  3. Attach the role to the Amazon EC2 instance running GitLab.

Step 2: Configure GitLab Connection in AWS CodePipeline

  1. Open AWS CodePipeline and go to Connections under settings.
  2. Click Create Connection, select GitLab Self-Managed, and click Next.
  3. Generate a Personal Access Token (PAT) in GitLab:
    1. Go to GitLab > User Settings > Access Tokens.
    2. Create a new token with scopes: read_repository, api.
    3. Copy and save the token securely.
  4. Enter the PAT token in AWS CodePipeline and complete the connection setup.

Step 3: Create an AWS CodePipeline

  1. Open the AWS CodePipeline console.
  2. Click Create Pipeline and follow these steps:
    1. Source: Select GitLab Self-Managed and choose the connected repository.
    2. Build Stage: Configure AWS CodeBuild.
  3. Save and start the pipeline.

Connecting GitLab with ArgoCD

Step 1: Install ArgoCD on Kubernetes

  1. Install ArgoCD on your Kubernetes cluster:

Step 2: Expose ArgoCD Using an Internal Load Balancer

Modify the ArgoCD argocd-server service to use an internal load balancer:

This will create an internal AWS load balancer accessible only within the Amazon VPC.

Step 3: Log in to ArgoCD

Retrieve the initial admin password:

Log in using the CLI:

Step 4: Register GitLab as a Repository in ArgoCD

  1. Open the ArgoCD UI and go to Repositories.
  2. Click New Repository and enter the GitLab self-managed repository details.
  3. Use SSH or HTTPS to connect to the GitLab repository.
  4. If using SSH, generate a key pair and add the public key to GitLab under Deploy Keys.

Step 5: Create an ArgoCD Application

  1. In the ArgoCD UI, go to Applications and click Create Application.
  2. Enter the application name, select the GitLab repository, and choose the Kubernetes cluster.
  3. Define the sync policy:
    1. Manual: Requires manual approval for changes.
    2. Automated: Automatically deploys changes when new commits are pushed.
  4. Click Create and sync the application.

Conclusion

By setting up a self-managed GitLab instance and integrating it with AWS CodePipeline, teams can create an efficient and automated CI/CD pipeline. This setup enables a seamless workflow, reducing manual effort and improving deployment consistency. With GitLab’s self-hosted capabilities and AWS’s automation tools, software delivery becomes faster and more reliable.

Drop a query if you have any questions regarding AWS CodePipeline and we will get back to you quickly.

Making IT Networks Enterprise-ready – Cloud Management Services

  • Accelerated cloud migration
  • End-to-end view of the cloud environment
Get Started

About CloudThat

CloudThat is a leading provider of Cloud Training and Consulting services with a global presence in India, the USA, Asia, Europe, and Africa. Specializing in AWS, Microsoft Azure, GCP, VMware, Databricks, and more, the company serves mid-market and enterprise clients, offering comprehensive expertise in Cloud Migration, Data Platforms, DevOps, IoT, AI/ML, and more.

CloudThat is the first Indian Company to win the prestigious Microsoft Partner 2024 Award and is recognized as a top-tier partner with AWS and Microsoft, including the prestigious ‘Think Big’ partner award from AWS and the Microsoft Superstars FY 2023 award in Asia & India. Having trained 650k+ professionals in 500+ cloud certifications and completed 300+ consulting projects globally, CloudThat is an official AWS Advanced Consulting Partner, Microsoft Gold Partner, AWS Training PartnerAWS Migration PartnerAWS Data and Analytics PartnerAWS DevOps Competency PartnerAWS GenAI Competency PartnerAmazon QuickSight Service Delivery PartnerAmazon EKS Service Delivery Partner AWS Microsoft Workload PartnersAmazon EC2 Service Delivery PartnerAmazon ECS Service Delivery PartnerAWS Glue Service Delivery PartnerAmazon Redshift Service Delivery PartnerAWS Control Tower Service Delivery PartnerAWS WAF Service Delivery PartnerAmazon CloudFrontAmazon OpenSearchAWS DMSAWS Systems ManagerAmazon RDS, and many more.

FAQs

1. What are the benefits of using a self-managed GitLab instance over GitLab SaaS?

ANS: – A self-managed GitLab instance provides greater control over security, customization, and compliance, making it ideal for enterprises with strict security and regulatory requirements.

2. How do I troubleshoot GitLab connectivity issues with AWS CodePipeline?

ANS: – Ensure that the GitLab instance is accessible from AWS, the Personal Access Token (PAT) has the correct permissions (read_repository, api), and firewall rules allow inbound traffic from AWS services.

WRITTEN BY Bhupesh .

Bhupesh is working as a Research Associate at CloudThat. He is passionate about learning and gaining industrial experience in cloud computing technologies like AWS and Azure. Bhupesh is also an excellent communicator and collaborator. He also proactively seeks new challenges and opportunities to learn and grow in his role. His passion for learning and exploring new technologies and his technical expertise make him a valuable member of any team working in the field.

Share

Comments

    Click to Comment

Get The Most Out Of Us

Our support doesn't end here. We have monthly newsletters, study guides, practice questions, and more to assist you in upgrading your cloud career. Subscribe to get them all!