apiVersion: apps/v1
kind: Deployment
metadata:
  name: asr-api
spec:
  selector:
    matchLabels:
      app: asr-api
  template:
    metadata:
      labels:
        app: asr-api
    spec:
      containers:
        - name: asr-api
          image: ghcr.io/tartunlp/speech-to-text-api:latest  # TODO
          env:
            - name: MQ_HOST
              value: $(RABBITMQ_SERVICE_HOST)
            - name: MQ_PORT
              value: $(RABBITMQ_SERVICE_PORT)
            - name: MQ_USERNAME
              valueFrom:
                secretKeyRef:
                  key: username
                  name: rabbitmq
            - name: MQ_PASSWORD
              valueFrom:
                secretKeyRef:
                  key: password
                  name: rabbitmq
            - name: API_USERNAME
              valueFrom:
                secretKeyRef:
                  key: username
                  name: asr
            - name: API_PASSWORD
              valueFrom:
                secretKeyRef:
                  key: password
                  name: asr
            - name: MYSQL_HOST
              value: $(MYSQL_SERVICE_HOST)
            - name: MYSQL_PORT
              value: "3306"
            - name: MYSQL_USERNAME
              valueFrom:
                secretKeyRef:
                  key: username
                  name: mysql-asr
            - name: MYSQL_PASSWORD
              valueFrom:
                secretKeyRef:
                  key: password
                  name: mysql-asr
            - name: MYSQL_DATABASE
              valueFrom:
                configMapKeyRef:
                  key: asr
                  name: databases
          args: [
              '--root-path', '/api/speech-to-text'
          ]
          ports:
            - containerPort: 8000
          volumeMounts:
            - mountPath: /app/data
              name: asr-storage
          resources:
            requests:
              memory: "256Mi"
              cpu: "1.0"
            limits:
              memory: "256Mi"
      volumes:
        - name: asr-storage
          persistentVolumeClaim:
            claimName: asr-storage