aula-05: KEDA + Victoria Metrics para auto-scaling

- Auto-scaling baseado em pods indisponíveis e restarts
- Victoria Metrics para coleta de métricas
- NGINX Ingress com retry automático (5 tentativas)
- Configuração ultra-agressiva: +5 pods/segundo
- Script setup.sh para instalação completa
- Mínimo 5 pods, máximo 30 pods
This commit is contained in:
Allyson de Paula
2025-12-25 17:19:11 -03:00
parent 9e834de48d
commit ed60410cb9
7 changed files with 603 additions and 0 deletions

56
aula-05/deployment.yaml Normal file
View File

@@ -0,0 +1,56 @@
# Deployment com 5 replicas iniciais - KEDA escala automaticamente até 30
# Configurado para 300 requisições sem falhas
apiVersion: apps/v1
kind: Deployment
metadata:
name: node-bugado
spec:
replicas: 5 # Mínimo 5 pods - KEDA escala ultra-agressivo quando detecta problemas
selector:
matchLabels:
app: node-bugado
template:
metadata:
labels:
app: node-bugado
spec:
terminationGracePeriodSeconds: 1
containers:
- name: app
image: node:24-alpine
command: ["node", "/app/app.js"]
env:
- name: MAX_REQUESTS
valueFrom:
configMapKeyRef:
name: app-config
key: MAX_REQUESTS
ports:
- containerPort: 3000
resources:
requests:
cpu: 50m
memory: 64Mi
limits:
cpu: 200m
memory: 128Mi
readinessProbe:
httpGet:
path: /health
port: 3000
periodSeconds: 1 # Verifica a cada 1 segundo
failureThreshold: 1 # 1 falha = remove do Service
livenessProbe:
httpGet:
path: /health
port: 3000
initialDelaySeconds: 2 # Espera para começar a testar
periodSeconds: 1 # A cada 1 seg faz o teste novamente
failureThreshold: 2 # 2 falhas = reinicia o container
volumeMounts:
- name: app-volume
mountPath: /app
volumes:
- name: app-volume
configMap:
name: app-config