0%
1. Architecture Cloud Moderne Cloud
Les piliers de l'architecture cloud pour applications JavaScript.
Docker
Containerisation des applications
Kubernetes
Orchestration de conteneurs
Serverless
AWS Lambda, Cloud Functions
CI/CD
GitHub Actions, GitLab CI
Monitoring
Prometheus, Grafana
IaC
Terraform, Pulumi, CDK
2. Docker Avancé pour Node.js Docker
Multi-stage builds, optimisation, production-ready.
# Dockerfile multi-stage pour Node.js
FROM node:18-alpine AS builder
WORKDIR /app
COPY package*.json ./
RUN npm ci --only=production
FROM node:18-alpine AS runner
RUN apk add --no-cache tini
USER node
WORKDIR /app
COPY --from=builder --chown=node:node /app/node_modules ./node_modules
COPY --chown=node:node . .
EXPOSE 3000
ENTRYPOINT ["/sbin/tini", "--"]
CMD ["node", "server.js"]
# docker-compose.yml complet
version: '3.8'
services:
api:
build: .
ports:
- "3000:3000"
environment:
- NODE_ENV=production
- DB_URL=postgresql://postgres:5432/mydb
- REDIS_URL=redis://redis:6379
depends_on:
- postgres
- redis
healthcheck:
test: ["CMD", "curl", "-f", "http://localhost:3000/health"]
interval: 30s
timeout: 10s
retries: 3
postgres:
image: postgres:15-alpine
environment:
POSTGRES_PASSWORD: ${DB_PASSWORD}
volumes:
- pgdata:/var/lib/postgresql/data
networks:
- internal
redis:
image: redis:7-alpine
networks:
- internal
volumes:
pgdata:
networks:
internal:
driver: bridge
🐳 Simulation Docker Production
3. Kubernetes - Orchestration K8s
Déploiement, scaling, service mesh, ingress.
# deployment.yaml
apiVersion: apps/v1
kind: Deployment
metadata:
name: nodejs-app
spec:
replicas: 3
selector:
matchLabels:
app: nodejs-app
template:
metadata:
labels:
app: nodejs-app
spec:
containers:
- name: app
image: myapp:latest
ports:
- containerPort: 3000
env:
- name: NODE_ENV
value: "production"
resources:
requests:
memory: "256Mi"
cpu: "250m"
limits:
memory: "512Mi"
cpu: "500m"
livenessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 30
readinessProbe:
httpGet:
path: /ready
port: 3000
---
apiVersion: v1
kind: Service
metadata:
name: nodejs-service
spec:
selector:
app: nodejs-app
ports:
- port: 80
targetPort: 3000
type: LoadBalancer
---
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: nodejs-ingress
annotations:
nginx.ingress.kubernetes.io/rewrite-target: /
spec:
rules:
- host: api.monapp.com
http:
paths:
- path: /
pathType: Prefix
backend:
service:
name: nodejs-service
port:
number: 80
# HPA - Horizontal Pod Autoscaler
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: nodejs-hpa
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: nodejs-app
minReplicas: 2
maxReplicas: 10
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 70
☸️ Simulation Kubernetes
4. AWS Serverless (Lambda, API Gateway) Serverless
Développez sans gérer de serveurs.
// AWS Lambda avec Node.js 20
exports.handler = async (event, context) => {
console.log('Event:', JSON.stringify(event));
// Récupérer le corps de la requête
const body = JSON.parse(event.body || '{}');
// Traitement
const result = {
message: 'Hello from Lambda!',
timestamp: new Date().toISOString(),
data: body
};
// Retourner la réponse
return {
statusCode: 200,
headers: {
'Content-Type': 'application/json',
'Access-Control-Allow-Origin': '*'
},
body: JSON.stringify(result)
};
};
// Lambda avec DynamoDB
const { DynamoDBClient } = require('@aws-sdk/client-dynamodb');
const { DynamoDBDocumentClient, GetCommand, PutCommand } = require('@aws-sdk/lib-dynamodb');
const client = new DynamoDBClient({});
const docClient = DynamoDBDocumentClient.from(client);
exports.getUser = async (event) => {
const userId = event.pathParameters.id;
const command = new GetCommand({
TableName: 'Users',
Key: { id: userId }
});
const response = await docClient.send(command);
return {
statusCode: 200,
body: JSON.stringify(response.Item)
};
};
// serverless.yml configuration
service: my-api
provider:
name: aws
runtime: nodejs18.x
region: eu-west-3
environment:
DYNAMODB_TABLE: Users
functions:
createUser:
handler: handlers/create.handler
events:
- http:
path: users
method: post
cors: true
getUsers:
handler: handlers/get.handler
events:
- http:
path: users
method: get
cors: true
⚡ Simulation AWS Serverless
5. CI/CD Pipeline Avancée CI/CD
GitHub Actions, GitLab CI, Jenkins, déploiement continu.
# .github/workflows/deploy.yml
name: CI/CD Pipeline
on:
push:
branches: [main, develop]
pull_request:
branches: [main]
env:
NODE_VERSION: '18'
DOCKER_IMAGE: ghcr.io/${{ github.repository }}
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: ${{ env.NODE_VERSION }}
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Run linter
run: npm run lint
- name: Run tests
run: npm run test:ci
- name: Run security audit
run: npm audit
build-and-push:
needs: test
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/main'
steps:
- uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: .
push: true
tags: |
${{ env.DOCKER_IMAGE }}:latest
${{ env.DOCKER_IMAGE }}:${{ github.sha }}
deploy:
needs: build-and-push
runs-on: ubuntu-latest
environment: production
steps:
- name: Deploy to Kubernetes
run: |
kubectl set image deployment/myapp app=${{ env.DOCKER_IMAGE }}:${{ github.sha }}
kubectl rollout status deployment/myapp
- name: Health check
run: |
curl --retry 5 --retry-delay 5 https://api.monapp.com/health
🔄 Simulation Pipeline CI/CD
6. Infrastructure as Code IaC
Terraform, AWS CDK, Pulumi.
# Terraform - AWS Infrastructure
terraform {
required_providers {
aws = { source = "hashicorp/aws", version = "~> 5.0" }
}
}
provider "aws" {
region = "eu-west-3"
}
# VPC
resource "aws_vpc" "main" {
cidr_block = "10.0.0.0/16"
tags = { Name = "myapp-vpc" }
}
# ECS Cluster
resource "aws_ecs_cluster" "main" {
name = "myapp-cluster"
}
# Load Balancer
resource "aws_lb" "main" {
name = "myapp-lb"
internal = false
load_balancer_type = "application"
security_groups = [aws_security_group.lb.id]
subnets = aws_subnet.public[*].id
}
# RDS Database
resource "aws_db_instance" "postgres" {
identifier = "myapp-db"
engine = "postgres"
instance_class = "db.t3.micro"
allocated_storage = 20
username = "admin"
password = var.db_password
skip_final_snapshot = true
}
# Outputs
output "api_endpoint" {
value = aws_lb.main.dns_name
}
🏗️ Simulation Terraform
7. Monitoring & Observability Observability
Prometheus, Grafana, OpenTelemetry, ELK Stack.
# prometheus.yml
global:
scrape_interval: 15s
scrape_configs:
- job_name: 'nodejs-app'
static_configs:
- targets: ['localhost:3000']
metrics_path: '/metrics'
# prom-client pour Node.js
const client = require('prom-client');
const collectDefaultMetrics = client.collectDefaultMetrics;
collectDefaultMetrics({ timeout: 5000 });
const httpRequestDuration = new client.Histogram({
name: 'http_request_duration_seconds',
help: 'Duration of HTTP requests in seconds',
labelNames: ['method', 'route', 'status_code']
});
// Middleware de monitoring
app.use((req, res, next) => {
const start = Date.now();
res.on('finish', () => {
const duration = (Date.now() - start) / 1000;
httpRequestDuration
.labels(req.method, req.route?.path || 'unknown', res.statusCode)
.observe(duration);
});
next();
});
// Endpoint /metrics
app.get('/metrics', async (req, res) => {
res.set('Content-Type', client.register.contentType);
res.end(await client.register.metrics());
});
// Grafana dashboard
// - Requests per second
// - Error rate (5xx)
// - Response time (p50, p95, p99)
// - CPU & Memory usage
📊 Simulation Monitoring
📈 Requests/sec
1,234
⚠️ Error Rate
0.5%
⏱️ Response Time (p95)
42ms
💾 Memory Usage
256MB
8. Message Queues & Event-Driven Events
RabbitMQ, Kafka, SQS, EventBridge.
// RabbitMQ avec amqplib
const amqp = require('amqplib');
async function setupMessaging() {
const connection = await amqp.connect('amqp://rabbitmq:5672');
const channel = await connection.createChannel();
// Déclarer exchange et queue
await channel.assertExchange('orders', 'topic', { durable: true });
await channel.assertQueue('order_created', { durable: true });
await channel.bindQueue('order_created', 'orders', 'order.created');
// Publisher
function publishOrderCreated(order) {
channel.publish('orders', 'order.created', Buffer.from(JSON.stringify(order)));
}
// Consumer
channel.consume('order_created', (msg) => {
const order = JSON.parse(msg.content.toString());
console.log('Order created:', order);
channel.ack(msg);
});
}
// AWS SQS avec SDK v3
const { SQSClient, SendMessageCommand } = require('@aws-sdk/client-sqs');
const sqs = new SQSClient({ region: 'eu-west-3' });
async function sendToQueue(message) {
const command = new SendMessageCommand({
QueueUrl: 'https://sqs.eu-west-3.amazonaws.com/123456789/myqueue',
MessageBody: JSON.stringify(message),
DelaySeconds: 0
});
return sqs.send(command);
}
📨 Simulation Message Queue
9. Comparaison Cloud Providers Cloud
| Service | AWS | Azure | GCP |
|---|---|---|---|
| Compute (VM) | EC2 | Virtual Machines | Compute Engine |
| Containers | ECS / EKS | AKS | GKE |
| Serverless | Lambda | Functions | Cloud Functions |
| Database | RDS / DynamoDB | SQL Database / CosmosDB | Cloud SQL / Firestore |
| Object Storage | S3 | Blob Storage | Cloud Storage |
| CDN | CloudFront | CDN | Cloud CDN |
| Market Share | 33% | 22% | 10% |
☁️ Simulateur Cloud Provider
10. Mini-projet : API Scalable Project
Architecture cloud complète : Docker + K8s + AWS + Monitoring.
🌍 Architecture Scalable
─────────────────────────────────────────────────
[Users] → [CloudFront CDN] → [API Gateway] → [Load Balancer]
↓
[ECS/K8s Cluster]
├── API Pod 1
├── API Pod 2
└── API Pod 3
↓
[RDS Database]
[ElastiCache Redis]
[SQS Queue]
[S3 Bucket]
📊 Monitoring: CloudWatch + Prometheus + Grafana
🔐 Security: WAF + IAM + Secrets Manager
🚀 CI/CD: GitHub Actions → ECR → ECS
🏗️ Déploiement Infrastructure Complète
🏆 Compétences acquises - Cloud & DevOps
✅ Docker (multi-stage, compose, optimisation)
✅ Kubernetes (deployments, services, HPA, ingress)
✅ AWS Serverless (Lambda, API Gateway, DynamoDB)
✅ CI/CD Pipeline (GitHub Actions, déploiement)
✅ Infrastructure as Code (Terraform)
✅ Monitoring (Prometheus, Grafana, metrics)
✅ Message Queues (RabbitMQ, SQS)
✅ Architecture cloud scalable
📚 Prochaines étapes recommandées :
- 🎓 Certifications AWS : Developer Associate, Solutions Architect
- 🎓 Certifications Kubernetes : CKAD, CKA
- 🎓 Terraform Associate Certification
- 📦 Approfondir : Istio (Service Mesh), ArgoCD (GitOps)
- 🔐 Sécurité : AWS WAF, IAM, Secrets Manager, VPC
💡 Salaire moyen (France 2024) :
• DevOps Engineer : 55k - 80k€
• Cloud Architect : 70k - 110k€
• SRE (Site Reliability Engineer) : 65k - 95k€
• Platform Engineer : 60k - 90k€
• DevOps Engineer : 55k - 80k€
• Cloud Architect : 70k - 110k€
• SRE (Site Reliability Engineer) : 65k - 95k€
• Platform Engineer : 60k - 90k€