apiVersion: apps/v1
kind: Deployment
metadata:
  name: ecommerce-admin-panel
  namespace: ecommerce
  labels:
    app: ecommerce-admin-panel
spec:
  replicas: 2
  selector:
    matchLabels:
      app: ecommerce-admin-panel
  strategy:
    type: RollingUpdate
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 0
  template:
    metadata:
      labels:
        app: ecommerce-admin-panel
    spec:
      containers:
        - name: ecommerce-admin-panel
          # Using local image built in minikube docker-env
          image: ecommerce-admin-panel:latest
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 80
              protocol: TCP
          resources:
            requests:
              memory: "64Mi"
              cpu: "50m"
            limits:
              memory: "128Mi"
              cpu: "200m"
          livenessProbe:
            httpGet:
              path: /
              port: 80
            initialDelaySeconds: 10
            periodSeconds: 30
            failureThreshold: 3
          readinessProbe:
            httpGet:
              path: /
              port: 80
            initialDelaySeconds: 5
            periodSeconds: 10
            failureThreshold: 3
      # Spread pods across nodes for high availability
      topologySpreadConstraints:
        - maxSkew: 1
          topologyKey: kubernetes.io/hostname
          whenUnsatisfiable: ScheduleAnyway
          labelSelector:
            matchLabels:
              app: ecommerce-admin-panel
