End-to-End DevOps Project
Sahil Kasekar
DevOps Engineer @Philips | Ex-Intern @ZoHo | Software Development and Testing | Embedded Systems Enthusiast |
?? What We’re Building Today
Goal: Create a CI/CD pipeline that automates:
??? Project Setup
Tools Involved:
??? Step-by-Step Implementation
1. Application Code Setup
Create a simple Node.js web application.
File: app.js
const express = require('express');
const app = express();
const PORT = 3000;
app.get('/', (req, res) => {
res.send('Hello, DevOps Enthusiasts! ??');
});
app.listen(PORT, () => {
console.log(`Server running on https://localhost:${PORT}`);
});
Add a Dockerfile to containerize the application:
File: Dockerfile
FROM node:14
WORKDIR /app
COPY package*.json ./
RUN npm install
COPY . .
EXPOSE 3000
CMD ["node", "app.js"]
Push the code to a GitHub repository.
2. CI/CD Pipeline with Jenkins
Set up a Jenkins pipeline to build, test, and deploy the application.
Jenkinsfile: (groovy)
pipeline {
agent any
stages {
stage('Checkout Code') {
steps {
git 'https://github.com/your-repo/devops-end-to-end.git'
}
}
stage('Build Docker Image') {
steps {
sh 'docker build -t your-dockerhub-username/devops-app:${BUILD_NUMBER} .'
}
}
stage('Push to Docker Hub') {
steps {
withDockerRegistry([credentialsId: 'docker-hub-credentials', url: '']) {
sh 'docker push your-dockerhub-username/devops-app:${BUILD_NUMBER}'
}
}
}
stage('Deploy to Kubernetes') {
steps {
sh 'helm upgrade --install devops-app ./helm-chart --set image.tag=${BUILD_NUMBER}'
}
}
}
}
领英推荐
3. Kubernetes Deployment with Helm
Use a Helm Chart to define your Kubernetes deployment and service.
File: values.yaml
image:
repository: your-dockerhub-username/devops-app
tag: "latest"
replicaCount: 2
service:
type: LoadBalancer
port: 3000
Deploy the application:
helm upgrade --install devops-app ./helm-chart
4. Monitoring with Prometheus and Grafana
Install Prometheus and Grafana using Helm:
helm repo add prometheus-community https://prometheus-community.github.io/helm-charts
helm install monitoring prometheus-community/kube-prometheus-stack
Access Grafana to set up dashboards:
kubectl port-forward svc/monitoring-grafana 3000:80
?? Project Workflow
?? What We’ve Achieved
?? Key Takeaways