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
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:
1 |
sudo dnf install -y policycoreutils-python-utils openssh-server openssh-clients perl |
Step 2: Enable and Start OpenSSH Server
Ensure that the OpenSSH server daemon is enabled and running:
1 |
sudo systemctl status sshd |
If it is not running, enable and start the service:
1 2 |
sudo systemctl enable sshd sudo systemctl start sshd |
Step 3: Configure Firewall Rules
Check if firewalld is running:
1 |
sudo systemctl status firewalld |
If firewalld is active, allow HTTP and HTTPS traffic:
1 2 3 |
sudo firewall-cmd --permanent --add-service=http sudo firewall-cmd --permanent --add-service=https sudo systemctl reload firewalld |
Step 4: Install GitLab
Download and install GitLab Community Edition:
1 |
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ce/script.rpm.sh | sudo bashsudo EXTERNAL_URL="URL" dnf install -y gitlab-ce (for community edition) |
Step 5: Reconfigure GitLab
After installation, reconfigure GitLab:
1 |
sudo gitlab-ctl reconfigure |
Retrieve the initial root password from:
1 |
cat /etc/gitlab/initial_root_password |
Connecting GitLab with AWS CodePipeline
Step 1: Create an AWS IAM Role for CodePipeline
- Navigate to the AWS IAM console.
- Create a new AWS IAM role with the following permissions:
- AWSCodePipelineFullAccess
- AWSCodeBuildAdminAccess
- AmazonS3FullAccess (if using S3 for artifacts)
- Attach the role to the Amazon EC2 instance running GitLab.
Step 2: Configure GitLab Connection in AWS CodePipeline
- Open AWS CodePipeline and go to Connections under settings.
- Click Create Connection, select GitLab Self-Managed, and click Next.
- Generate a Personal Access Token (PAT) in GitLab:
- Go to GitLab > User Settings > Access Tokens.
- Create a new token with scopes: read_repository, api.
- Copy and save the token securely.
- Enter the PAT token in AWS CodePipeline and complete the connection setup.
Step 3: Create an AWS CodePipeline
- Open the AWS CodePipeline console.
- Click Create Pipeline and follow these steps:
- Source: Select GitLab Self-Managed and choose the connected repository.
- Build Stage: Configure AWS CodeBuild.
- Save and start the pipeline.
Connecting GitLab with ArgoCD
Step 1: Install ArgoCD on Kubernetes
- Install ArgoCD on your Kubernetes cluster:
1 2 |
kubectl create namespace argocd kubectl apply -n argocd -f https://raw.githubusercontent.com/argoproj/argo-cd/stable/manifests/install.yaml |
Step 2: Expose ArgoCD Using an Internal Load Balancer
Modify the ArgoCD argocd-server service to use an internal load balancer:
1 |
kubectl patch svc argocd-server -n argocd -p '{"spec": {"type": "LoadBalancer", "annotations": {"service.beta.kubernetes.io/aws-load-balancer-internal": "true"}}}' |
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:
1 |
kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d |
Log in using the CLI:
1 |
argocd login <internal-load-balancer-url>:443 --username admin --password <password> |
Step 4: Register GitLab as a Repository in ArgoCD
- Open the ArgoCD UI and go to Repositories.
- Click New Repository and enter the GitLab self-managed repository details.
- Use SSH or HTTPS to connect to the GitLab repository.
- If using SSH, generate a key pair and add the public key to GitLab under Deploy Keys.
Step 5: Create an ArgoCD Application
- In the ArgoCD UI, go to Applications and click Create Application.
- Enter the application name, select the GitLab repository, and choose the Kubernetes cluster.
- Define the sync policy:
- Manual: Requires manual approval for changes.
- Automated: Automatically deploys changes when new commits are pushed.
- Click Create and sync the application.
Conclusion
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
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 Partner, AWS Migration Partner, AWS Data and Analytics Partner, AWS DevOps Competency Partner, AWS GenAI Competency Partner, Amazon QuickSight Service Delivery Partner, Amazon EKS Service Delivery Partner, AWS Microsoft Workload Partners, Amazon EC2 Service Delivery Partner, Amazon ECS Service Delivery Partner, AWS Glue Service Delivery Partner, Amazon Redshift Service Delivery Partner, AWS Control Tower Service Delivery Partner, AWS WAF Service Delivery Partner, Amazon CloudFront, Amazon OpenSearch, AWS DMS, AWS Systems Manager, Amazon 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.
Comments