apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Values.pod.name }}
  namespace: {{ .Release.Namespace }}
  labels:
    app: {{ .Values.pod.name }}
spec:
  replicas: {{ .Values.deployment.replicaCount }}
  selector:
    matchLabels:
      app: {{ .Values.pod.name }}
  template:
    metadata:
      name: {{ .Values.pod.name }}
      creationTimestamp: null
      labels:
        app: {{ .Values.pod.name }}
    spec:
      volumes:
        - name: {{ .Values.configMap.name }}
          configMap:
            name: {{ .Values.configMap.name }}
            defaultMode: 420
        - name: {{ .Values.volumeClaim.name }}
          persistentVolumeClaim:
            claimName: {{ .Values.volumeClaim.name }}
      containers:
        - name: {{ .Values.pod.name }}
          image: "{{ .Values.container.mizuAgent.image.repository }}:{{ .Values.container.mizuAgent.image.tag | default .Chart.AppVersion }}"
          command:
            - ./mizuagent
            - '--api-server'
          env:
            - name: SYNC_ENTRIES_CONFIG
            - name: LOG_LEVEL
              value: INFO
          resources:
            limits:
              cpu: 750m
              memory: 1Gi
            requests:
              cpu: 50m
              memory: 50Mi
          volumeMounts:
            - name: {{ .Values.configMap.name }}
              mountPath: /app/config/
            - name: {{ .Values.volumeClaim.name }}
              mountPath: /app/data/
          livenessProbe:
            httpGet:
              path: /echo
              port: {{ .Values.pod.port }}
              scheme: HTTP
            initialDelaySeconds: 1
            timeoutSeconds: 1
            periodSeconds: 10
            successThreshold: 1
            failureThreshold: 3
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: Always
        - name: {{ .Values.container.basenine.name }}
          image: "{{ .Values.container.basenine.image.repository }}:{{ .Values.container.basenine.image.tag | default .Chart.AppVersion }}"
          command:
            - /basenine
          args:
            - '-addr'
            - 0.0.0.0
            - '-port'
            - '9099'
            - '-persistent'
          workingDir: /app/data/
          resources:
            limits:
              cpu: 750m
              memory: 1Gi
            requests:
              cpu: 50m
              memory: 50Mi
          volumeMounts:
            - name: {{ .Values.configMap.name }}
              mountPath: /app/config/
            - name: {{ .Values.volumeClaim.name }}
              mountPath: /app/data/
          readinessProbe:
            tcpSocket:
              port: 9099
            timeoutSeconds: 1
            periodSeconds: 1
            successThreshold: 1
            failureThreshold: 3
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: Always
        - name: kratos
          image: "{{ .Values.container.kratos.image.repository }}:{{ .Values.container.kratos.image.tag | default .Chart.AppVersion }}"
          resources:
            limits:
              cpu: 750m
              memory: 1Gi
            requests:
              cpu: 50m
              memory: 50Mi
          volumeMounts:
            - name: {{ .Values.configMap.name }}
              mountPath: /app/config/
            - name: {{ .Values.volumeClaim.name }}
              mountPath: /app/data/
          readinessProbe:
            httpGet:
              path: /health/ready
              port: 4433
              scheme: HTTP
            timeoutSeconds: 1
            periodSeconds: 1
            successThreshold: 1
            failureThreshold: 3
          terminationMessagePath: /dev/termination-log
          terminationMessagePolicy: File
          imagePullPolicy: Always
      restartPolicy: Always
      terminationGracePeriodSeconds: 0
      dnsPolicy: ClusterFirstWithHostNet
      serviceAccountName: {{ .Values.serviceAccountName }}
      serviceAccount: {{ .Values.serviceAccountName }}
      securityContext: { }
      schedulerName: default-scheduler
