---
apiVersion: apps/v1
kind: Deployment
metadata:
  name: wes-celery-worker
spec:
  selector:
    matchLabels:
      app: wes-celery-worker
  template:
    metadata:
      labels:
        app: wes-celery-worker
    spec:
      initContainers:
      - name: vol-init
        image: busybox
        command: [ 'mkdir' ]
        args: [ '-p', '/data/db', '/data/output', '/data/tmp' ]
        volumeMounts:
        - mountPath: /data
          name: wes-volume
      containers:
      - name: wes-celery-worker
        image: prowes/elixir-wes-app:rc1
        workingDir: '/app/pro_wes'
        command: [ 'celery' ]
        args: [ 'worker', '-A', 'celery_worker', '-E', '--loglevel=info', '-c', '1', '-Q', 'celery' ]
        env:
        - name: MONGO_HOST
          value: mongodb
        - name: MONGO_PORT
          value: "27017"
        - name: MONGO_USERNAME
          valueFrom:
            secretKeyRef:
              key: database-user
              name: mongodb
        - name: MONGO_PASSWORD
          valueFrom:
            secretKeyRef:
              key: database-password
              name: mongodb
        - name: MONGO_DBNAME
          value: prowes-db
        - name: RABBIT_HOST
          value: rabbitmq-cluster
        - name: RABBIT_PORT
          value: "5672"
        resources:
          requests:
            memory: "512Mi"
            cpu: "300m"
          limits:
            memory: "8Gi"
            cpu: "1"
        volumeMounts:
        - mountPath: /data
          name: wes-volume
        - mountPath: /app/pro_wes/config/app_config.yaml
          subPath: app_config.yaml
          name: wes-config
        - mountPath: /.netrc
          subPath: .netrc
          name: wes-netrc-secret
      volumes:
      - name: wes-volume
        persistentVolumeClaim:
          claimName: wes-volume
      - name: wes-config
        configMap:
          defaultMode: 420
          name: wes-config
      - name: wes-netrc-secret
        secret:
          secretName: netrc
