30% Time Savings in AI Development: The EKS CI/CD Solution

EKS Cluster

Introduction

In the swiftly evolving realm of artificial intelligence (AI) development, time stands as a critical factor. The ability to promptly translate ideas into functional models can be the decisive factor for a project’s success. With this in mind, our company initiated a journey to enhance our development process. Consequently, the results exceeded expectations. By implementing Continuous Integration and Continuous Deployment (CI/CD) automation on Amazon Elastic Kubernetes Service (EKS), we achieved an impressive 30% reduction in development time. In this case study, we will delve into the intricate details of our transformation and investigate how EKS CI/CD emerged as our clandestine tool for attaining unparalleled efficiency.

The Challenge: Time Constraints in Development

While specializing in cutting-edge solutions across various industries, our company encountered a significant challenge. The surging demand for AI applications, however, presented a pressing issue. These included time-consuming manual tasks, sluggish deployment processes, and compatibility problems, which consequently impeded our ability to swiftly meet market demands.

The Solution: Embracing EKS CI/CD Automation

Understanding the urgency, we made a strategic decision to revamp our development pipeline. As a result, we opted for Amazon EKS, a managed Kubernetes service renowned for streamlining the deployment and scaling of containerized applications. To enhance this transition, we implemented CI/CD automation. Consequently, we seamlessly integrated GitHub Actions into our CI/CD pipeline, and we employed eksctl to efficiently oversee our EKS clusters. Here’s a detailed breakdown of our approach:

name: cd

on:
  push:
    branches:
      - main
  pull_request:
    branches:
      - main

env: 
  AWS_REGION: us-east-2
  ECR_REPOSITORY: <YOUR_ECR_REPOSITORY>
  SHORT_SHA: $(echo ${{ github.sha }} | cut -c 1-8)

jobs:
  run-tests:
    runs-on: ubuntu-latest
    steps:
    - name: Clone
      uses: actions/checkout@v2

    - name: Test
      run: |
        cd site
        npm install
        npm test

  build:
    runs-on: ubuntu-latest
    if: github.ref == 'refs/heads/main'
    needs:
      - run-tests

    steps:
    - name: Clone
      uses: actions/checkout@v2

    - name: Configure AWS credentials
      uses: aws-actions/configure-aws-credentials@v1
      with:
        aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
        aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
        aws-region: ${{ env.AWS_REGION }}
      
    - name: Login to Amazon ECR
      id: login-ecr
      uses: aws-actions/amazon-ecr-login@v1

    - name: Build, tag, and push image to Amazon ECR
      id: build-image
      env:
        ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
      run: |
        cd site
        docker image build \
        --tag ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest \
        --tag ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.SHORT_SHA }} \
        .
        docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:latest
        docker push ${{ env.ECR_REGISTRY }}/${{ env.ECR_REPOSITORY }}:${{ env.SHORT_SHA }}

    - name: Install and configure kubectl
      run: |
        VERSION=$(curl --silent https://storage.googleapis.com/kubernetes-release/release/stable.txt)
        # https://github.com/aws/aws-cli/issues/6920#issuecomment-1117981158
        VERSION=v1.23.6
        curl https://storage.googleapis.com/kubernetes-release/release/$VERSION/bin/linux/amd64/kubectl \
          --progress-bar \
          --location \
          --remote-name
        chmod +x kubectl
        sudo mv kubectl /usr/local/bin/
        echo ${{ secrets.KUBECONFIG }} | base64 --decode > kubeconfig.yaml

    - name: Deploy
      env:
        ECR_REGISTRY: ${{ steps.login-ecr.outputs.registry }}
      run: |
        export ECR_REPOSITORY="${ECR_REGISTRY}/${ECR_REPOSITORY}"
        export IMAGE_TAG="${{ env.SHORT_SHA }}"
        export KUBECONFIG=kubeconfig.yaml
        envsubst < k8s/kustomization.tmpl.yaml > k8s/kustomization.yaml
        kubectl kustomize k8s | kubectl apply -f -

1. Containerization of Applications for EKS

The initial stage involved containerization. Consequently, we encapsulated our AI applications and services within containers, guaranteeing consistent performance across various environments. This containerization process played a critical role in securing the predictability of our deployments.

2. Building the CI/CD Pipeline for EKS

We established a robust CI/CD pipeline with GitHub Actions, thoughtfully designed to automatically initiate code commits to our version control system. This meticulously crafted pipeline comprised the following pivotal stages:

  • Build: Within this stage, our focus was on the meticulous construction and rigorous testing of our containers, ensuring that any issues were detected and addressed early in the process.
  • Deploy to EKS: Upon successful testing, our containers underwent an automated deployment to our EKS clusters, enabling swift and reliable implementation.
  • Testing: A comprehensive suite of automated tests, encompassing both unit tests and end-to-end tests, was meticulously executed to rigorously validate the application’s functionality.
  • Deployment Approval: Subsequently, following the successful completion of tests, the deployment was poised for review and approval by our dedicated team of experts.

3. Implementing Kustomize for Configuration Management

We utilized Kubernetes’ native configuration management tool, kustomize, to manage our configuration files. Consequently, this allowed us to maintain separate configuration profiles for development, staging, and production environments, ensuring consistency and security.

4. Monitoring and Scaling for EKS

EKS provided us with excellent tools for monitoring and scaling our applications. Additionally, we integrated Amazon CloudWatch for monitoring and adopted Kubernetes Horizontal Pod Autoscaling to manage our application’s resources dynamically.

The Usage

Prerequisites

  • AWS Account with key credentials and required permissions.
  • Node Application.
  • EKS cluster.
  • ECR repository.
  • jq and wget must be installed.
  • KUBECTL Version must be “v1.23.6”

Steps to run this EKS project

1. Make the changes in the .github/workflows/cd.yml file like AWS_REGION and ECR_REPOSITORY.

2. Create the AWS_ACCESS_KEY_ID, AWS_SECRET_ACCESS_KEY, and KUBECONFIG secrets in your repo.

3. Then apply these transforms using the following command:

export KUBECONFIG=kubeconfig.yaml
kubectl kustomize k8s | kubectl apply -f -

4. We will test our script by committing:

git push

5. We query our cluster:

kubectl get ns

6. To get the URL of our Load Balancer we run the following command, If it is not working then you can take it from the AWS account:

make cluster-elb

7. By using this URL in our browser we can see our website and a docker image has been pushed to our repository.

The Results: A 30% Reduction in Development Time after using EKS

The implementation of EKS CI/CD automation, consequently, brought about a profound transformation in our development process. As we delve into the details of this revolution, we observe several key benefits:

1. Rapid Iteration

With automated testing and deployment, we could iterate on our AI models and applications rapidly. Developers could focus on coding while the pipeline handled the rest. This significantly reduced the time required to develop and release new features.

2. Consistency and Reliability

The combination of containerization and automated deployments ensured unwavering consistency in how our applications operated across various environments. This eradicated the notorious “it works on my machine” issue and substantially curbed deployment-related problems.

3. Enhanced Collaboration

Our development and operations teams were no longer siloed. Collaboration improved as both teams worked together to define the CI/CD pipeline and monitor applications in production.

4. Scalability

EKS’s robust auto-scaling capabilities seamlessly enabled us to manage surges in user traffic. Thus, permitting us to efficiently scale our applications in response to demand fluctuations. This, in turn, resulted in the optimization of resource utilization.

5. Cost Savings

Through the automation of resource provisioning and scaling, we were able to optimize infrastructure usage, resulting in significant cost savings.

6. Increased Customer Satisfaction

Our capacity to promptly introduce new features and updates significantly elevated customer satisfaction. As a result, this led to clients observing tangible results at an accelerated pace, thereby strengthening our reputation and fostering even more robust client relationships.

Conclusion

To sump up, the transformative influence of automation, coupled with EKS CI/CD, emerged as a pivotal game-changer for our AI company. Importantly, with a remarkable 30% reduction in development time, we gained the capacity to innovate at an unprecedented pace. Consequently, this case study stands as a testament to the remarkable potential inherent in contemporary DevOps practices and cloud-native technologies. Furthermore, as we persist in enhancing and fine-tuning our processes, our steadfast dedication remains fixed on maintaining a leading position in the realm of AI innovation, all attributed to the remarkable might of automation.

References