apiVersion: apps/v1
kind: Deployment
metadata:
  name: {{ .Chart.Name }}
spec:
  replicas: {{ .Values.replicaCount }}
  selector:
    matchLabels:
      app: {{ .Chart.Name }}
  template:
    metadata:
      labels:
        app: {{ .Chart.Name }}
    spec:
      containers:
        - name: {{ .Chart.Name }}
          image: "{{ .Values.image.repository }}:{{ .Values.image.tag }}"
          imagePullPolicy: {{ .Values.image.pullPolicy }}
          ports:
            - containerPort: {{ .Values.service.port }}
          env:
            - name: SECRET_KEY
              valueFrom:
                secretKeyRef:
                  name: visus-api-secret
                  key: SECRET_KEY
            - name: DATABASE_URL
              valueFrom:
                secretKeyRef:
                  name: visus-api-secret
                  key: DATABASE_URL
            - name: ALGORITHM
              valueFrom:
                secretKeyRef:
                  name: visus-api-secret
                  key: ALGORITHM
          volumeMounts:
            - name: uploads-volume
              mountPath: {{ .Values.persistence.uploads.containerPath }}
          resources:
            {{- toYaml .Values.resources | nindent 12 }}
      volumes:
        - name: uploads-volume
          persistentVolumeClaim:
            claimName: "{{ .Release.Name }}-uploads-pvc"