aula-03: Alta disponibilidade com replicas e readiness probe
Múltiplas réplicas com readiness probe para remover pods não-saudáveis do Service enquanto liveness probe os reinicia.
This commit is contained in:
47
aula-03/deployment.yaml
Normal file
47
aula-03/deployment.yaml
Normal file
@@ -0,0 +1,47 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: node-bugado
|
||||
spec:
|
||||
replicas: 5 # Alta disponibilidade: enquanto um reinicia, outros atendem
|
||||
selector:
|
||||
matchLabels:
|
||||
app: node-bugado
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: node-bugado
|
||||
spec:
|
||||
terminationGracePeriodSeconds: 5
|
||||
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
|
||||
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
|
||||
Reference in New Issue
Block a user