apiVersion: apps/v1
kind: Deployment
metadata:
  name: tankwar-server
  namespace: tankwar
  labels:
    app: tankwar-server
spec:
  # Single replica for Plan A (in-memory room state).
  # Kubernetes will auto-reschedule if the pod or its node fails.
  replicas: 1
  strategy:
    # Recreate instead of RollingUpdate so the port & state are never
    # duplicated across two pods with in-memory room registry.
    type: Recreate
  selector:
    matchLabels:
      app: tankwar-server
  template:
    metadata:
      labels:
        app: tankwar-server
    spec:
      terminationGracePeriodSeconds: 15
      containers:
        - name: tankwar-server
          image: tankwar-server:latest
          imagePullPolicy: Never
          ports:
            - name: ws
              containerPort: 3000
              protocol: TCP
          env:
            - name: NODE_ENV
              value: "production"
            - name: HOST
              value: "0.0.0.0"
            - name: PORT
              value: "3000"
          resources:
            requests:
              cpu: "100m"
              memory: "128Mi"
            limits:
              cpu: "1000m"
              memory: "512Mi"
          readinessProbe:
            httpGet:
              path: /health
              port: 3000
            initialDelaySeconds: 3
            periodSeconds: 5
            timeoutSeconds: 2
            failureThreshold: 3
          livenessProbe:
            httpGet:
              path: /health
              port: 3000
            initialDelaySeconds: 15
            periodSeconds: 15
            timeoutSeconds: 3
            failureThreshold: 3
