The Definitive Guide to Helm Chart Deployment on an EKS Cluster Using CircleCI Config

The Definitive Guide to Helm Chart Deployment on an EKS Cluster Using CircleCI Config

Overview :-

Deploying applications on Kubernetes can sometimes feel like steering a ship through stormy seas, especially for those new to the technology. Helm charts offer a streamlined way to package and deploy your applications on Kubernetes environments like Amazon EKS. When combined with the automation capabilities of CircleCI, the process becomes more manageable and efficient. This guide will walk you through the essentials of using Helm charts for deployment on an EKS cluster, specifically leveraging CircleCI for continuous integration and deployment.

Pre-requisites :-

Before diving into the deployment process, ensure you have the following set up:

  • An AWS Account: You’ll need an active AWS account to create an EKS cluster.

  • EKS Cluster: If you don’t already have a cluster, you’ll need to set one up. AWS provides a straightforward guide to get this done.

  • Helm Installed: Helm is a package manager for Kubernetes. Make sure it’s installed and configured on your machine.

  • CircleCI Account: Sign up for CircleCI if you haven’t already. It will handle the automation of your deployment processes.

  • Basic Knowledge of YAML: Since Helm charts and CircleCI configurations are written in YAML, a basic understanding is beneficial.

Procedure :-

Setting Up CircleCI

  1. CircleCI Project Setup: Connect your GitHub repository containing the Helm chart to CircleCI.

  2. Configuring CircleCI: Add a .circleci/config.yml file to your repository. This file will define the build and deployment process.

version: 2.1
orbs:
  aws-eks: circleci/aws-eks@2.2
  orb-tools: circleci/orb-tools@12.0
  helm: {}
jobs:
  install-helm-chart-on-eks-cluster:
    docker:
      - image: cimg/python:3.10
    working_directory: ~/project
    parameters:
      release_name:
        type: string
        default: "prometheus-community"
      cluster-name:
        type: string
        default: "mahira-eks-cluster"
        description: Cluster name
      helm_version:
        type: string
        default: "v3.8.2"
        description: the helm client version to install. e.g. v3.0.0
      add_repo:
        type: string
        default: "https://prometheus-community.github.io/helm-charts"
        description: the helm chart repository url to use
      chart:
        type: string
        default: "prometheus-community/prometheus"
        description: the helm chart to install
      debug:
        description: |
          Enable debug mode 
        type: boolean
        default: 
    steps:
      - run:
          name: Install and configure kubectl
          command: curl -LO "https://dl.k8s.io/release/$(curl -L -s https://dl.k8s.io/release/stable.txt)/bin/linux/amd64/kubectl" && sudo install -o root -g root -m 0755 kubectl /usr/local/bin/kubectl && kubectl version --client

      - run:
          name: "cluster configs"
          command: |
            aws eks --region us-east-1 update-kubeconfig --name mahira-eks-cluster

      - helm/install_helm_client:
          version: << parameters.helm_version >>

      - run:
          name: Install cncf stable repo
          command: |
            helm repo add stable http://cncf.gitlab.io/stable

      - helm/install_helm_chart:
          chart: << parameters.chart >>
          add_repo: << parameters.add_repo >>
          release_name: << parameters.release_name >>
          helm_version: << parameters.helm_version >>
          debug: << parameters.debug >>

workflows:
  version: 2
  install-helm:
    jobs:
      - install-helm:
          context:
            - aws-creds

Deploying Your Application

  1. Push Changes: Commit any changes to your Helm chart or CircleCI configuration and push them to your GitHub repository.

  2. Automated Deployment: CircleCI will detect the new commit, run the defined pipeline, and deploy your Helm chart to your EKS cluster.

Conclusion :-

Deploying applications using Helm on an EKS cluster doesn’t have to be complicated. By integrating CircleCI into your workflow, you can automate the deployment process, making it both reliable and repeatable. This setup not only simplifies the management of your Kubernetes applications but also ensures that your deployments are consistent and error-free. Embrace this method, and you’ll likely find that managing your Kubernetes deployments becomes a more streamlined and less daunting task.