GithubHelp home page GithubHelp logo

adarshiitdh / mern_microservices_eks_deployment Goto Github PK

View Code? Open in Web Editor NEW

This project forked from unpredictableprashant/samplemernwithmicroservices

1.0 0.0 1.0 116 KB

JavaScript 62.51% CSS 11.53% HTML 21.33% Dockerfile 4.64%

mern_microservices_eks_deployment's Introduction

MERN Microservices deployment using EKS

This application has 3 microservices, 2 for the backend and 1 for the frontend.

tree --filelimits 3 MERN_Microservices_EKS_Deployment/
MERN_Microservices_EKS_Deployment/
├── README.md
├── backend
│   ├── README.md
│   ├── helloService  
│   └── profileService  
└── frontend 

Table of Contents

  1. Set Up the AWS Environment
  2. Prepare the MERN Application
  3. Version Control
  4. Continuous Integration with Jenkins
  5. Kubernetes (EKS) Deployment via HELM
  6. Monitoring and Logging

kubernetes

Prerequisites

1: EC2 (min of 4Gb ram and 20 GB disk)

2: Install aws-cli in it

3: Jenkins installed in it

4: Install docker in it

5: Install EKSCTL in it

6: Install Kubectl in it

image

Set Up the AWS Environment

  1. Set Up AWS CLI on the EC2:
    • Install AWS CLI and configure it with AWS credentials. On your Ec2, run the aws configure --profile command to create an AWS CLI profile to use with git-remote-codecommit. When prompted, provide your AWS access key, your secret access key, the AWS Region where you created your AWS CodeCommit repository, and the default output format you prefer. For example:
       % aws configure --profile demo-profile
      AWS Access Key ID [None]: ***************
      AWS Secret Access Key [None]: ***************
      Default region name [None]: ap-south-1
      Default output format [None]: 
      

Prepare the MERN Application

  1. Containerize the MERN Application:

  2. Push Docker Images to Amazon ECR:

Version Control

  1. Use AWS CodeCommit:

    • Create a CodeCommit repository. image

      Now install the git-remote-codecommit in the EC2

      apt install python3-pip
      pip install git-remote-codecommit
      
    • Push the MERN application source code to the CodeCommit repository.

      Now clone the codecommit repo to the ec2

       git clone codecommit::ap-south-1://adarsh_Microservice_Repo
      

      image image image image image

      Code is sucessfully pushed to code commit image

Continuous Integration with Jenkins

  1. Create Jenkins Jobs:

    • Create Jenkins jobs for building and pushing Docker images to ECR.

    • Trigger the Jenkins jobs whenever there's a new commit in the CodeCommit repository.

Kubernetes (EKS) Deployment via HELM

  1. Create EKS Cluster:

    • Use eksctl or other tools to create an Amazon EKS cluster.

    Installing EKSCTL on EC2 using https://eksctl.io/installation/

    # for ARM systems, set ARCH to: `arm64`, `armv6` or `armv7`
    ARCH=amd64
    PLATFORM=$(uname -s)_$ARCH
    
    curl -sLO "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_$PLATFORM.tar.gz"
    
    # (Optional) Verify checksum
    curl -sL "https://github.com/eksctl-io/eksctl/releases/latest/download/eksctl_checksums.txt" | grep $PLATFORM | sha256sum --check
    
    tar -xzf eksctl_$PLATFORM.tar.gz -C /tmp && rm eksctl_$PLATFORM.tar.gz
    sudo mv /tmp/eksctl /usr/local/bin
    

    image

    eksctl create cluster --name mern_microservice_adarsh --region ap-south-1 --nodegroup-name standard-workers --node-type t2.micro --nodes 2 --nodes-min 1 --nodes-max 3
    

    image

    image

    image

    aws eks --region ap-south-1 update-kubeconfig --name mern-microservice-adarsh
    

    image

    Now install kubectl to interact with the cluster [https://docs.aws.amazon.com/eks/latest/userguide/install-kubectl.html]

    curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.28.3/2023-11-14/bin/linux/amd64/kubectl
    curl -O https://s3.us-west-2.amazonaws.com/amazon-eks/1.28.3/2023-11-14/bin/linux/amd64/kubectl.sha256
    sha256sum -c kubectl.sha256
    chmod +x ./kubectl
    mkdir -p $HOME/bin && cp ./kubectl $HOME/bin/kubectl && export PATH=$HOME/bin:$PATH
    echo 'export PATH=$HOME/bin:$PATH' >> ~/.bashrc
    kubectl version --client
    
    aws eks --region ap-south-1 update-kubeconfig --name mern-microservice-adarsh
    

    Note if you below error then update awscli version

    error-1: Unable to connect to the server: getting credentials: decoding stdout: no kind "ExecCredential" is registered for version "client.authentication.k8s.io/v1alpha1" in scheme

    error-2: error: exec plugin: invalid apiVersion “client.authentication.k8s.io/v1alpha1

    solution : Update the awscli version

    curl "https://awscli.amazonaws.com/awscli-exe-linux-x86_64.zip" -o "awscliv2.zip"
    sudo apt install unzip
    unzip awscliv2.zip
    sudo ./aws/install --update
    
  2. Deploy Application with Helm:

Monitoring and Logging

  1. Set Up Monitoring:

    • Use CloudWatch for monitoring and setting up alarms.

image

image

image

image

image

image

  1. Configure Logging:

    • Use CloudWatch Logs or another logging solution for collecting logs.

mern_microservices_eks_deployment's People

Contributors

adarshiitdh avatar unpredictableprashant avatar

Stargazers

 avatar

Forkers

patilajayv

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.