Deployment
apiVersion: apps/v1kind: Deploymentmetadata: name: myapp namespace: production labels: app: myapp version: v1.0.0spec: replicas: 3 selector: matchLabels: app: myapp strategy: type: RollingUpdate rollingUpdate: maxSurge: 1 maxUnavailable: 0 template: metadata: labels: app: myapp version: v1.0.0 annotations: prometheus.io/scrape: "true" prometheus.io/port: "9090" spec: affinity: podAntiAffinity: preferredDuringSchedulingIgnoredDuringExecution: - weight: 100 podAffinityTerm: labelSelector: matchExpressions: - key: app operator: In values: - myapp topologyKey: kubernetes.io/hostname containers: - name: myapp image: myregistry/myapp:v1.0.0 imagePullPolicy: Always ports: - containerPort: 3000 name: http - containerPort: 9090 name: metrics env: - name: NODE_ENV value: production - name: DATABASE_URL valueFrom: secretKeyRef: name: myapp-secrets key: database-url envFrom: - configMapRef: name: myapp-config resources: requests: memory: "256Mi" cpu: "250m" limits: memory: "512Mi" cpu: "500m" livenessProbe: httpGet: path: /health port: 3000 initialDelaySeconds: 30 periodSeconds: 10 timeoutSeconds: 5 readinessProbe: httpGet: path: /ready port: 3000 initialDelaySeconds: 5 periodSeconds: 5 lifecycle: preStop: exec: command: ["/bin/sh", "-c", "sleep 15"] securityContext: runAsNonRoot: true runAsUser: 1001 readOnlyRootFilesystem: true allowPrivilegeEscalation: false volumeMounts: - name: temp mountPath: /tmp - name: cache mountPath: /app/.cache volumes: - name: temp emptyDir: {} - name: cache emptyDir: {} imagePullSecrets: - name: registry-credentials