apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    app: next-starter
  name: next-starter
spec:
  minReadySeconds: 5
  replicas: 2
  revisionHistoryLimit: 1
  selector:
    matchLabels:
      app: next-starter
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 50%
    type: RollingUpdate
  template:
    metadata:
      labels:
        app: next-starter
    spec:
      affinity:
        podAntiAffinity:
          preferredDuringSchedulingIgnoredDuringExecution:
            - podAffinityTerm:
                labelSelector:
                  matchExpressions:
                    - key: app
                      operator: In
                      values:
                        - next-starter
                topologyKey: kubernetes.io/hostname
              weight: 100

      containers:
        - name: frontend
          envFrom:
            - configMapRef:
                name: frontend-config
          image: next-starter
          imagePullPolicy: Always
          livenessProbe:
            initialDelaySeconds: 10
            periodSeconds: 15
            tcpSocket:
              port: 3000
            timeoutSeconds: 30
          ports:
            - containerPort: 3000
          readinessProbe:
            initialDelaySeconds: 10
            periodSeconds: 10
            tcpSocket:
              port: 3000
          resources:
            limits:
              cpu: 200m
              memory: 400M
            requests:
              cpu: 100m
              memory: 200M
