Experience with GitLab CI, Docker and Kubernetes Pipelines — Part 1
I woke up this morning with some content on my mind, I will try to keep it short and straightforward.
Last week, I was told to work on GitLab CI pipelines for a Spring boot application. As a Jenkins guy, there is a perfect learning curve for me to deliver the GitLab CI pipelines with a time limitation.
Before working on the concrete solution, I want to do a dry-run on our Amazon Web Services(AWS) lab environment to analyze and document the installation and configuration of the GitLab-CI pipeline processes.
GitLab Installation and Configuration:
Coming to the specs of the GitLab installation, I used the Omnibus package installer since it is quicker to install and upgrade GitLab.
To install GitLab in AWS, I created a t2.large sized ec2-instance with an Ubuntu Amazon Machine Image(AMI).
Note: Before running through the installation process on the ec2-instance, I created an Elastic IP and associated it with the above created ec2-instance and created an A record in Route53 for our example-labs.com domain, as gitlab.example-labs.com for later use in the process.
If you don’t want to go through the recommended Omnibus installation process, there are a couple other methods to install GitLab, or you can use GitLab-ee and GitLab-ce AMI’s available in AWS market place.
I’ve run the following commands to install and configure GitLab,
# Update the packages
sudo apt-get update# Install curl openssh and ca-certificates packages
sudo apt-get install -y curl openssh-server ca-certificates# Install postfix to send notifications
sudo apt-get install -y postfix
Note: In the postfix configuration screen, choose the ‘Internet Site’ and use your server’s external DNS for ‘mail name’ and accept the defaults for rest of the configuration screen.
# Add the GitLab package repository
curl https://packages.gitlab.com/install/repositories/gitlab/gitlab-ee/script.deb.sh | sudo bash# Install the GitLab package with your domain
sudo EXTERNAL_URL="https://gitlab.example-labs.com" apt-get install gitlab-ee
Note: GitLab will automatically request a self-signed certificate with Let's Encrypt with the EXTERNAL_URL from the above command until and unless you want to use your own certificates.
Upon successful installation, open a browser and search for the https://gitlab.example-labs.com. You should be redirected to GitLab login page and the default username will be ‘root’ to login.
Note: For any post-installation changes, feel free to edit the “/etc/gitlab/gitlab.rb” file and run “sudo gitlab-ctl reconfigure” command to reconfigure the GitLab instance.
Hope this helps you to install and configure a GitLab instance. Let me know in the comments if you’re struggling with any of the above processes that I can help you with?
In part-2, I blogged about configuring multiple executors in an ec2-instance GitLab runner and creating a .gitlab-ci.yaml file with Build, Test, Docker build, Docker push and Deploy to an EKS cluster stages by using docker containers through each stage with my sample application setup in GitLab CI.
Hope you like it 🙃
Happy Automation 🚀
Until next time!!!