# https://kubernetes.io/docs/concepts/workloads/controllers/deployment/
apiVersion: apps/v1
kind: Deployment
metadata:
  name: mal
  labels:
    app: mal
spec:
  replicas: 1
  selector:
    matchLabels:
      app: mal
  strategy:
    rollingUpdate:
      maxSurge: 25%
      maxUnavailable: 25%
    type: RollingUpdate
  template:
    metadata:
      annotations:
        kubectl.kubernetes.io/default-container: mal
      labels:
        app: mal
    spec:
      containers:
        - name: mal
          image: main
          imagePullPolicy: IfNotPresent
          ports:
            - containerPort: 3000
              name: http
          resources:
            requests:
              cpu: 100m
              memory: 100Mi
            limits:
              cpu: 100m
              memory: 100Mi
          livenessProbe:
            tcpSocket:
              port: 3000
            initialDelaySeconds: 5
            timeoutSeconds: 5
            successThreshold: 1
            failureThreshold: 3
            periodSeconds: 10
          readinessProbe:
            tcpSocket:
              port: 3000
            initialDelaySeconds: 2
            timeoutSeconds: 5
            successThreshold: 1
            failureThreshold: 3
            periodSeconds: 10
          env:
            - name: DATABASE_FILE
              value: /app/data/mal.db
            - name: GIN_MODE
              value: release
            - name: PLAYBACK_PROXY_SECRET
              valueFrom:
                secretKeyRef:
                  name: mal
                  key: PLAYBACK_PROXY_SECRET
          volumeMounts:
            - name: data
              mountPath: /app/data
      volumes:
        - name: data
          persistentVolumeClaim:
            claimName: mal-data
      restartPolicy: Always
