apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ include "mautrix-whatsapp.fullname" . }}
  labels:
    {{- include "mautrix-whatsapp.labels" . | nindent 4 }}
spec:
  replicas: 1
  selector:
    matchLabels:
      app.kubernetes.io/name: {{ include "mautrix-whatsapp.name" . }}
      app.kubernetes.io/instance: {{ .Release.Name }}
  template:
    {{- if .Values.podAnnotations }}
    annotations:
      {{- toYaml .Values.podAnnotations | nindent 6 }}
    {{- end }}
    metadata:
      labels:
        app.kubernetes.io/name: {{ include "mautrix-whatsapp.name" . }}
        app.kubernetes.io/instance: {{ .Release.Name }}
    spec:
      serviceAccountName: {{ template "mautrix-whatsapp.serviceAccountName" . }}
      containers:
        - name: {{ .Chart.Name }}
          securityContext:
            {{- toYaml .Values.securityContext | nindent 12 }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          volumeMounts:
            - mountPath: /data
              name: config-volume
          ports:
            - name: http
              containerPort: {{ .Values.service.port }}
              protocol: TCP
#          livenessProbe:
#            httpGet:
#              path: /_matrix/mau/live
#              port: http
#            initialDelaySeconds: 60
#            periodSeconds: 5
#          readinessProbe:
#            httpGet:
#              path: /_matrix/mau/ready
#              port: http
#            initialDelaySeconds: 60
#            periodSeconds: 5
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
      volumes:
        - name: config-volume
          configMap:
            name: {{ template "mautrix-whatsapp.fullname" . }}

      securityContext:
        {{- toYaml .Values.podSecurityContext | nindent 8 }}
      {{- with .Values.nodeSelector }}
      nodeSelector:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.affinity }}
      affinity:
        {{- toYaml . | nindent 8 }}
      {{- end }}
      {{- with .Values.tolerations }}
      tolerations:
        {{- toYaml . | nindent 8 }}
      {{- end }}