Basic CI_CD pipeline for Microservices-based Application
Basic CI_CD pipeline for Microservices-based Application
Application
Building a fully automated CI/CD pipeline for a microservices-based application hosted on a
cloud platform (AWS, Azure, or GCP). Using popular DevOps tools and practices to ensure
efficient builds, testing, and deployments.
Tech Stack:
Steps of Implementation:
Codebase: Creating a basic microservices application using your preferred language (e.g.,
Node.js, Java, Python) and, structuring it into separate repositories for each microservice.
● Create the Simple Web App: Simple HTML file with the content:
"Hi there! This is Aman, your newbie DevOps friend"
Steps:
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<title>Welcome</title>
</head>
<body>
</body>
</html>
Started this simple web server using Python to serve the HTML file:
Plan:
cd ~/webapp
mkdir backend
cd backend
npm init -y
Install the Required Packages: Installed the Express framework for creating a backend server:
npm install express
I created a file named app.js using vim/nano with following code I found on internet:
});
app.listen(PORT, () => {
});
node app.js
Modify the index.html file in the frontend service to call the backend.
○
Restart the Python server to serve the updated frontend:
Since each microservices ideally have their own repositories so we followed that rule.
Created a directory for the frontend and moved index.html into it:
mkdir ~/frontend
mv ~/my-simple-webapp/index.html ~/frontend/
cd ~/frontend
git init
git add .
Backend Repository:
cd ~/webapp/backend
git init
git add .
git commit -m "Initial commit for backend service"
Push both repositories to GitHub, Create separate GitHub repositories for frontend and
backend.
FROM python:3.10-slim
WORKDIR /app
EXPOSE 8081
- cd ~/frontend
FROM node:16
WORKDIR /app
COPY package*.json ./
# Install dependencies
COPY . .
EXPOSE 5000
- cd /webapp/backend
name: Backend CI
On:
push:
branches:
- master
pull_request:
jobs:
lint-test-build:
runs-on: ubuntu-latest
steps:
uses: actions/checkout@v3
# Set up Node.js
uses: actions/setup-node@v3
with:
node-version: 16
# Install dependencies
name: Frontend CI
on:
push:
branches:
- master
pull_request:
jobs:
lint-test-build:
runs-on: ubuntu-latest
steps:
uses: actions/checkout@v3
# Set up Python
uses: actions/setup-python@v4
with:
python-version: 3.10
cd /webapp/backend
cd /frontend
curl
https://raw.githubusercontent.com/helm/helm/main/scripts/get-helm-3 |
bash
helm version
chmod +x kubectl
docker login