Developers can now develop their containerized applications on AWS Graviton2 based EC2 instances using Amazon Elastic Kubernetes Service (EKS) and GitLab as their Continuous Integration (CI), Continuous Delivery (CD) natively on Arm architecture. Gitlab is a web-based DevOps platform that provides a git-based repository. A major feature of Gitlab is its CI/CD capability. Gitlab supports self-hosted runners deployed on Amazon M6g instances. These instances deliver 20% better price over comparable current generation x86-based instances and better performance for wide range of workloads.
Use case: Build and Deploy a MediaWiki application with Arm based Gitlab runners and EKS cluster.
Figure 1 Architecture - EKS cluster and Gitlab runners on Arm-based instances
In this architecture, we deployed an EKS cluster on M6g instances, spread across two (2) availability zones for redundancy. We also configured an Application Load Balancer (ALB) for accessing the application. The source code of the application is hosted in a Gitlab repository. When we commit the source code of MediaWiki application into the Gitlab repository, a pipeline is triggered with the following stages: build, push, and deploy:
For this use case, we have used the source code and related config files hosted on the official MediaWiki docker hub repo.
The following video captures the application deployment workflow.
Let us look at the following steps to configure this use case.
Here are the pre-requisites for building the use case:
Use the following source code to create a yaml file to provision our EKS cluster.
Run the eksctl command to create the cluster using the YAML manifest file.
eksctl create cluster <YAML manifest file>
This starts the cluster creation process. We should be able to see the following output.
Figure 2 eksctl command output.
We can track the progress with the Cloud Formation service. In the AWS management console, navigate to the Cloud Formation dashboard, select the stack being created and switch to the events tab. Here we can observe the events related to the creation of our EKS cluster.
Figure 3 CloudFormation output for cluster creation
After the cluster is created, we should be able to see the cluster being created in the Elastic Kubernetes Service (EKS) Dashboard in Active status.
Now, let us navigate to EKS Dashboard and select the cluster. Navigate to the Compute tab and click Add Node Group. Additionally, set the Name of a Node Group and the IAM role for worker nodes in the group. Note: The IAM role should have the attached policies, depending on your needs and workflow. In this case, we are using the following AWS-managed policies.
Figure 4 IAM roles and policies
On the Compute and Scaling page please select Amazon Linux 2 (arm64) as your AMI type. Select the instance type of your choice and set the disk size for your worker nodes. We can also set the scaling configuration with Minimum, Maximum and Desired number of worker nodes in our Node Group.
Figure 5 Node group Auto-scaling configuration
On the Networking page, please select the subnets where our worker nodes need to be placed. There will be four (4) subnets created by default for the EKS cluster. Also, select the security groups for the cluster. We are using ControlPlane and Cluster Nodes (security groups tags created by default with the EKS cluster). Please review all your data on the review page and create the Node Group. You should be able to see the new Node Group under your cluster in few minutes. Please wait for the status to become Active.
Figure 6 Node group details
Alternatively, we can also use the following command to check the status of the worker node in our EKS cluster. kubectl get nodes
This shows the worker nodes and their running status.
In this section, we deploy an m6g.large EC2 instance in AWS and configure the Gitlab-runner for our project repository.
Log in to the EC2 instance and install gitlab-runner using the following command.
sudo yum install gitlab-runner
Instantiate gitlab-runner registration using the following command.
Enter the following parameters: - Name of Node - Gitlab url - Token from Gitlab - Executor
Copy the registration token from Gitlab (CI/CD section of our project) and register the runner. After successful registration, we should see the runner associated with our project repository.
Here is our project repository in Gitlab:
Figure 7 Gitlab project repository
All the source code and configuration files mentioned in this blog are hosted here.
In this section, we cover the application deployment workflow. Starting from updating the code in the Gitlab repository to application deployment on EKS cluster.
Let us look at the current version of MediaWiki application pods running in our EKS cluster:
Figure 8 Applications pods running on EKS cluster
Now, we are going to make a simple change in the application’s source code. For instance, here we are changing the default logo to a new logo ‘Arm_logo’. In the Gitlab project repository, update the Dockerfile and LocalSettings.php files as shown in the following screenshot.
Now, let us commit both of these files in Gitlab. Once the commit is done, a pipeline gets triggered:
Once the pipeline gets successfully completed, copy the ALB URL in the AWS console to access the new version of the application in the browser:
As shown previously, developers can build their containerized application using AWS EKS with Gitlab CI/CD and leverage the cost and performance benefits of the AWS Graviton2 processors.
To learn more on running Gitlab on Arm architecture, please visit these sessions at Arm DevSummit or reach us here with questions or comments.