Skip to content

manage Kubernetes resources yaml files and Helm Charts

Notifications You must be signed in to change notification settings

idrr1993/GitOps

Repository files navigation

GitOps for Demo-Crm infrastructure

This project demonstrates the implementation of a CI/CD pipeline for a Node.js-based ticketing application

Table of Contents

Overview

Implemented a robust CI/CD pipeline for the Demo-CRM application (a ticketing system written in Node.js). The pipeline integrates:

  • [ArgoCD for automated deployment]
  • [Docker for containerization]
  • [Helm charts for Kubernetes deployment]

The application is deployed onto an AWS EKS cluster, with infrastructure provisioned and managed using Terraform, ensuring scalability, high availability, and automated infrastructure management.

Architecture

in the daigram we below we can see our infrastructure

  1. we can see that we work with AWS cloud service
  2. inside my AWS user i created VPC under Mumbai's region (ap-south-1), with CIDR = 10.0.0.0/16
  3. to this VPC i created 1 public subnet in AZ= ap-south-1a" with exit to network (mean that no needed for NAT or any athoer solution)
  4. also in aws region (same level as VPC) i created ECR to upload the image for my application (the image push when running my CI/CD in my application repo)
  5. inside the subnet i created EKS cluster with mudle from my infrastructure repo
  6. then i created 1 worker node with EC2 instance t3a.large
  7. and inside this node i created 2 demo-crm pods and 3 mongoDB pods
  8. also i used Nginx ingress controler that i installed with helm chart to send request that recive from ALB to application pod
  9. i created ALB that recive request from user and send it to Nginx ingress controller

Architecture Diagram

Technology Stack

Category Technologies
Infrastructure EKS, AWS
Containerization Docker and Docker compose
CI/CD github action
Security Use Secrets and diffrent networks
Application Node.js
Database MongoDB

Prerequisites

Requirements for building and running the project:

  • Demo-crm Application
  • AWS user to create ECR and EKS
  • Terraform modle to create EKS
  • docker and docker compose installed
  • Helm to install helm charts

Getting Started

Follow these instructions to set up the project locally and deploy it to your cloud environment.

Infrastructure Setup

1. Create MongoDB with Helm Chart and Configure PV and PVC

  • After creating the cluster, run this command to set up kubeconfig with AWS:

    aws eks update-kubeconfig --region ap-south-1 --name idan-raviv-cluster
  • Pull MongoDB Helm chart from Artifact Hub:

    helm pull oci://registry-1.docker.io/bitnamicharts/mongodb --version 16.4.5
  • Unzip the Helm chart:

    tar -xvzf mongodb-16.4.5.tgz
  • Apply the PVC and PV:

    kubectl apply -f storageclass.yaml
  • Add the Bitnami Helm repo:

    helm repo add bitnami https://charts.bitnami.com/bitnami
  • Install the chart locally after editing the values.yaml:

    helm install my-mongodb ./mongodb

2. Configure MongoDB

  • Retrieve the root password and store it in the MONGODB_ROOT_PASSWORD environment variable:

    export MONGODB_ROOT_PASSWORD=$(kubectl get secret --namespace default my-mongodb -o jsonpath="{.data.mongodb-root-password}" | base64 -d)
  • Connect to MongoDB:

    kubectl run --namespace default my-mongodb-client --rm --tty -i --restart='Never' --env="MONGODB_ROOT_PASSWORD=$MONGODB_ROOT_PASSWORD" --image docker.io/bitnami/mongodb:7.0.4-debian-11-r2 -- bash
  • Let the MongoDB pods know each other:

    mongosh admin --host "my-mongodb-0.my-mongodb-headless.default.svc.cluster.local:27017,my-mongodb-1.my-mongodb-headless.default.svc.cluster.local:27017" --authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD

3. Application Deploy

  • Print the MongoDB URI (for updating secret.yaml):

    echo -n "mongodb://root:${MONGODB_ROOT_PASSWORD}@my-mongodb-0.my-mongodb-headless.default.svc.cluster.local:27017,my-mongodb-1.my-mongodb-headless.default.svc.cluster.local:27017" | base64
  • Apply Kubernetes YAML files:

    kubectl apply -f config.yaml
    kubectl apply -f deployment.yaml
    kubectl apply -f secret.yaml
    kubectl apply -f service.yaml

4. Add NGINX Ingress

  • Add the ingress-nginx Helm repository:

    helm repo add ingress-nginx https://kubernetes.github.io/ingress-nginx
  • Install ingress-nginx Helm chart (creates the ingress controller):

    helm install -n ingress --create-namespace controller ingress-nginx/ingress-nginx --set controller.ingressClassResource.default=true
  • Check the service to get the external IP:

    kubectl get service -n ingress
  • Create and apply ingress.yaml:

    kubectl apply -f ingress.yaml
  • Check the ingress external IP or DNS:

    kubectl get ingress
  • Access the service via the DNS/IP on port 80.

5. Install ArgoCD with Helm and Configure It

  • Add ArgoCD Helm repository:

    helm repo add argo https://argoproj.github.io/argo-helm
  • Install ArgoCD Helm chart:

    helm install my-argo-cd argo/argo-cd --namespace argocd --create-namespace
  • Port-forward ArgoCD service to port 8080 (in background):

    kubectl port-forward service/my-argo-cd-argocd-server -n argocd 8080:443 &
  • Port-forward helper commands:

    • fg to move the job to foreground
    • kill %1 to stop the job
  • Get the ArgoCD admin password:

    kubectl -n argocd get secret argocd-initial-admin-secret -o jsonpath="{.data.password}" | base64 -d; echo
  • Your GitHub repo URL:

    git@github.com:idrr1993/mydemo-example-apps.git
    
  • To get your SSH private key:

    cat ~/.ssh/id_rsa
  • If SSH fails, connect the repo via HTTPS using a GitHub token:

    1. Go to GitHub → Settings → Developer settings → Personal access tokens
    2. Generate a classic token with repo and read:packages permissions
    3. In the ArgoCD UI:
      • Go to Settings > Repositories
      • Choose Connect repo via HTTPS
      • Fill in:
        • Project: default
        • Repository URL: https://github.com/<user name/<repo name>.git
        • Username: your GitHub username
        • Password: your GitHub token
      • Click Connect and check if status is Synced or OutOfSync

6. Upload Files to GitHub Repository

git init
git remote add origin git@github.com:<user>/<mydemo-example-apps>.git
git remote -v
git add .
git commit -m "Initial commit"
git branch -M main  # Ensure branch is named 'main'
git push -u origin main

Contact

Idan Raviv - LinkedIn - Email

Project Link: https://github.com/idrr1993/GitOps

About

manage Kubernetes resources yaml files and Helm Charts

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages