Testes de Carga: /deploy/oke/load-test

This commit is contained in:
2026-08-17 18:59:14 -03:00
parent eaf6ea85b1
commit 23d32bbcfc
36 changed files with 3349 additions and 0 deletions

View File

@@ -0,0 +1,190 @@
apiVersion: v1
kind: Namespace
metadata:
name: agent-load-test
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: agent-template-backend
namespace: agent-load-test
spec:
replicas: 4
strategy:
type: RollingUpdate
rollingUpdate:
maxUnavailable: 0
maxSurge: 2
selector:
matchLabels:
app: agent-template-backend
template:
metadata:
labels:
app: agent-template-backend
annotations:
loadtest.runtime-checksum: "RUNTIME_CHECKSUM_PLACEHOLDER"
spec:
terminationGracePeriodSeconds: 60
topologySpreadConstraints:
- maxSkew: 1
topologyKey: kubernetes.io/hostname
whenUnsatisfiable: ScheduleAnyway
labelSelector:
matchLabels:
app: agent-template-backend
containers:
- name: agent-template-backend
image: IMAGE_PLACEHOLDER
imagePullPolicy: Always
ports:
- containerPort: 8000
envFrom:
- secretRef:
name: agent-backend-runtime
env:
- name: LANGFUSE_PUBLIC_KEY
valueFrom:
secretKeyRef:
name: langfuse-client
key: LANGFUSE_PUBLIC_KEY
- name: LANGFUSE_SECRET_KEY
valueFrom:
secretKeyRef:
name: langfuse-client
key: LANGFUSE_SECRET_KEY
- name: LANGFUSE_HOST
valueFrom:
secretKeyRef:
name: langfuse-client
key: LANGFUSE_HOST
readinessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 15
periodSeconds: 10
timeoutSeconds: 5
failureThreshold: 6
livenessProbe:
httpGet:
path: /health
port: 8000
initialDelaySeconds: 45
periodSeconds: 20
timeoutSeconds: 5
failureThreshold: 6
startupProbe:
httpGet:
path: /health
port: 8000
periodSeconds: 5
failureThreshold: 36
resources:
requests:
cpu: "500m"
memory: "768Mi"
limits:
cpu: "2000m"
memory: "2Gi"
volumeMounts:
- name: wallet
mountPath: /app/wallet
readOnly: true
volumes:
- name: wallet
secret:
secretName: agent-backend-wallet
---
apiVersion: v1
kind: Service
metadata:
name: agent-template-backend
namespace: agent-load-test
spec:
type: ClusterIP
sessionAffinity: None
selector:
app: agent-template-backend
ports:
- name: http
port: 8000
targetPort: 8000
---
apiVersion: v1
kind: Service
metadata:
name: agent-template-backend-lb
namespace: agent-load-test
#spec:
# type: LoadBalancer
# sessionAffinity: None
# selector:
# app: agent-template-backend
# ports:
# - name: http
# port: 8000
# targetPort: 8000
spec:
type: NodePort
selector:
app: agent-template-backend
ports:
- name: http
port: 8000
targetPort: 8000
nodePort: NODE_PORT_PLACEHOLDER
---
apiVersion: autoscaling/v2
kind: HorizontalPodAutoscaler
metadata:
name: agent-template-backend
namespace: agent-load-test
spec:
scaleTargetRef:
apiVersion: apps/v1
kind: Deployment
name: agent-template-backend
minReplicas: 4
maxReplicas: 30
behavior:
scaleUp:
stabilizationWindowSeconds: 0
policies:
- type: Percent
value: 100
periodSeconds: 60
- type: Pods
value: 8
periodSeconds: 60
selectPolicy: Max
scaleDown:
stabilizationWindowSeconds: 300
policies:
- type: Percent
value: 25
periodSeconds: 60
metrics:
- type: Resource
resource:
name: cpu
target:
type: Utilization
averageUtilization: 65
- type: Resource
resource:
name: memory
target:
type: Utilization
averageUtilization: 75
---
apiVersion: policy/v1
kind: PodDisruptionBudget
metadata:
name: agent-template-backend
namespace: agent-load-test
spec:
minAvailable: 3
selector:
matchLabels:
app: agent-template-backend

View File

@@ -0,0 +1,28 @@
apiVersion: batch/v1
kind: Job
metadata:
name: agent-load-generator
namespace: agent-load-test
spec:
backoffLimit: 0
ttlSecondsAfterFinished: 3600
template:
metadata:
labels:
app: agent-load-generator
spec:
restartPolicy: Never
containers:
- name: k6
image: grafana/k6:latest
args: ["run", "/scripts/loadtest.js"]
envFrom:
- secretRef:
name: agent-backend-runtime
volumeMounts:
- name: script
mountPath: /scripts
volumes:
- name: script
configMap:
name: k6-load-script