apiVersion: apps/v1 kind: Deployment metadata: name: finance-service namespace: the-order labels: app: finance-service version: v1 spec: replicas: 2 selector: matchLabels: app: finance-service template: metadata: labels: app: finance-service version: v1 spec: containers: - name: finance image: theorder/finance-service:latest ports: - containerPort: 4003 name: http env: - name: PORT value: "4003" - name: NODE_ENV valueFrom: configMapKeyRef: name: the-order-config key: ENVIRONMENT - name: DATABASE_URL valueFrom: secretKeyRef: name: the-order-secrets key: database-url - name: PAYMENT_GATEWAY_API_KEY valueFrom: secretKeyRef: name: the-order-secrets key: payment-gateway-api-key resources: requests: memory: "256Mi" cpu: "100m" limits: memory: "512Mi" cpu: "500m" livenessProbe: httpGet: path: /health port: 4003 initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 5 failureThreshold: 3 readinessProbe: httpGet: path: /health port: 4003 initialDelaySeconds: 10 periodSeconds: 5 timeoutSeconds: 3 failureThreshold: 3 startupProbe: httpGet: path: /health port: 4003 initialDelaySeconds: 0 periodSeconds: 10 timeoutSeconds: 3 failureThreshold: 30 lifecycle: preStop: exec: command: ["/bin/sh", "-c", "sleep 15"] --- apiVersion: v1 kind: Service metadata: name: finance-service namespace: the-order spec: selector: app: finance-service ports: - port: 80 targetPort: 4003 protocol: TCP type: ClusterIP --- apiVersion: autoscaling/v2 kind: HorizontalPodAutoscaler metadata: name: finance-service-hpa namespace: the-order spec: scaleTargetRef: apiVersion: apps/v1 kind: Deployment name: finance-service minReplicas: 2 maxReplicas: 10 metrics: - type: Resource resource: name: cpu target: type: Utilization averageUtilization: 70 - type: Resource resource: name: memory target: type: Utilization averageUtilization: 80