aula-11: ArgoCD + GitLab Runner para GitOps CI/CD
- ArgoCD via Helm com recursos mínimos (~1Gi) - GitLab Runner com executor Kubernetes - Exemplo node-bugado com Dockerfile e .gitlab-ci.yml - Manifests K8s para repositório GitOps - README.md da aula-03 (liveness + readiness probes)
This commit is contained in:
17
aula-11/node-bugado/k8s/configmap.yaml
Normal file
17
aula-11/node-bugado/k8s/configmap.yaml
Normal file
@@ -0,0 +1,17 @@
|
||||
# =============================================================================
|
||||
# ConfigMap - node-bugado
|
||||
# =============================================================================
|
||||
#
|
||||
# Configuração da aplicação.
|
||||
# MAX_REQUESTS define quantas requisições antes de "travar".
|
||||
#
|
||||
# =============================================================================
|
||||
|
||||
apiVersion: v1
|
||||
kind: ConfigMap
|
||||
metadata:
|
||||
name: node-bugado-config
|
||||
labels:
|
||||
app: node-bugado
|
||||
data:
|
||||
MAX_REQUESTS: "5"
|
||||
76
aula-11/node-bugado/k8s/deployment.yaml
Normal file
76
aula-11/node-bugado/k8s/deployment.yaml
Normal file
@@ -0,0 +1,76 @@
|
||||
# =============================================================================
|
||||
# Deployment - node-bugado
|
||||
# =============================================================================
|
||||
#
|
||||
# Deployment com liveness e readiness probes.
|
||||
# A imagem é atualizada automaticamente pelo pipeline GitLab CI.
|
||||
#
|
||||
# =============================================================================
|
||||
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: node-bugado
|
||||
labels:
|
||||
app: node-bugado
|
||||
spec:
|
||||
replicas: 2
|
||||
selector:
|
||||
matchLabels:
|
||||
app: node-bugado
|
||||
template:
|
||||
metadata:
|
||||
labels:
|
||||
app: node-bugado
|
||||
spec:
|
||||
terminationGracePeriodSeconds: 5
|
||||
containers:
|
||||
- name: node-bugado
|
||||
# IMPORTANTE: Esta linha é atualizada automaticamente pelo GitLab CI
|
||||
image: registry.kube.quest/workshop/node-bugado:latest
|
||||
ports:
|
||||
- containerPort: 3000
|
||||
name: http
|
||||
|
||||
# Variáveis de ambiente via ConfigMap
|
||||
env:
|
||||
- name: MAX_REQUESTS
|
||||
valueFrom:
|
||||
configMapKeyRef:
|
||||
name: node-bugado-config
|
||||
key: MAX_REQUESTS
|
||||
|
||||
# Recursos
|
||||
resources:
|
||||
requests:
|
||||
memory: "64Mi"
|
||||
cpu: "50m"
|
||||
limits:
|
||||
memory: "128Mi"
|
||||
cpu: "100m"
|
||||
|
||||
# Liveness probe - detecta quando a app trava
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 3000
|
||||
initialDelaySeconds: 5
|
||||
periodSeconds: 3
|
||||
failureThreshold: 2
|
||||
timeoutSeconds: 2
|
||||
|
||||
# Readiness probe - remove do service enquanto não está pronta
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /health
|
||||
port: 3000
|
||||
initialDelaySeconds: 2
|
||||
periodSeconds: 2
|
||||
failureThreshold: 1
|
||||
timeoutSeconds: 1
|
||||
|
||||
# Pod security context
|
||||
securityContext:
|
||||
runAsNonRoot: true
|
||||
runAsUser: 1000
|
||||
fsGroup: 1000
|
||||
38
aula-11/node-bugado/k8s/ingress.yaml
Normal file
38
aula-11/node-bugado/k8s/ingress.yaml
Normal file
@@ -0,0 +1,38 @@
|
||||
# =============================================================================
|
||||
# Ingress - node-bugado
|
||||
# =============================================================================
|
||||
#
|
||||
# Ingress NGINX para expor a aplicação externamente.
|
||||
# Configure o hostname de acordo com seu domínio.
|
||||
#
|
||||
# =============================================================================
|
||||
|
||||
apiVersion: networking.k8s.io/v1
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: node-bugado
|
||||
labels:
|
||||
app: node-bugado
|
||||
annotations:
|
||||
nginx.ingress.kubernetes.io/proxy-connect-timeout: "30"
|
||||
nginx.ingress.kubernetes.io/proxy-read-timeout: "30"
|
||||
# Descomente para Let's Encrypt:
|
||||
# cert-manager.io/cluster-issuer: letsencrypt-prod
|
||||
spec:
|
||||
ingressClassName: nginx
|
||||
rules:
|
||||
- host: bugado.kube.quest
|
||||
http:
|
||||
paths:
|
||||
- path: /
|
||||
pathType: Prefix
|
||||
backend:
|
||||
service:
|
||||
name: node-bugado
|
||||
port:
|
||||
number: 80
|
||||
# Descomente para TLS:
|
||||
# tls:
|
||||
# - hosts:
|
||||
# - bugado.kube.quest
|
||||
# secretName: node-bugado-tls
|
||||
24
aula-11/node-bugado/k8s/service.yaml
Normal file
24
aula-11/node-bugado/k8s/service.yaml
Normal file
@@ -0,0 +1,24 @@
|
||||
# =============================================================================
|
||||
# Service - node-bugado
|
||||
# =============================================================================
|
||||
#
|
||||
# Service ClusterIP para expor a aplicação internamente.
|
||||
# Use com Ingress para acesso externo.
|
||||
#
|
||||
# =============================================================================
|
||||
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: node-bugado
|
||||
labels:
|
||||
app: node-bugado
|
||||
spec:
|
||||
type: ClusterIP
|
||||
selector:
|
||||
app: node-bugado
|
||||
ports:
|
||||
- name: http
|
||||
port: 80
|
||||
targetPort: 3000
|
||||
protocol: TCP
|
||||
Reference in New Issue
Block a user