apiVersion: apps/v1
kind: Deployment
metadata:
  name: jobmanager-api
spec:
  selector:
    matchLabels:
      app: jobmanager-api
  replicas: 1
  template:
    metadata:
      labels:
        app: jobmanager-api
    spec:
      containers:
        - name: jobmanager-api
          image: registry.digitalocean.com/io-cullen/tile-viewer-api:v1.0.2
          command: ["gunicorn"]
          args:
            [
              "--bind",
              "0.0.0.0:5000",
              "--log-level=debug",
              "jobmanager.wsgi",
              "--timeout",
              "300",
            ]
          ports:
            - containerPort: 5000
              protocol: TCP
          imagePullPolicy: Always
          volumeMounts:
            - name: nfs-media-vol
              mountPath: /app/media
            - mountPath: /app/config.yaml
              subPath: config.yaml
              name: jobmanager-config-volume
        - name: jobmanager-api-nginx
          image: registry.digitalocean.com/io-cullen/tile-viewer-api:v1.0.2
          command: ["nginx"]
          args: ["-g", "daemon off;"]
          ports:
            - containerPort: 8080
              protocol: TCP
          imagePullPolicy: Always
          volumeMounts:
            - name: nfs-media-vol
              mountPath: /app/media
            - mountPath: /app/config.yaml
              subPath: config.yaml
              name: jobmanager-config-volume
            - mountPath: /etc/nginx/sites-available/jobmanager
              subPath: jobmanager
              name: jobmanager-api-nginx-siteconf
            - mountPath: /etc/nginx/nginx.conf
              subPath: nginx.conf
              name: jobmanager-api-nginx-conf
      # imagePullSecrets:
      #   - name: regcred
      volumes:
        - name: nfs-media-vol
          persistentVolumeClaim:
            claimName: nfs-media-data
        - configMap:
            name: jobmanager-config
            items:
              - key: config.yaml
                path: config.yaml
          name: jobmanager-config-volume
        - configMap:
            name: jobmanager-api-nginx-siteconf
            items:
              - key: jobmanager
                path: jobmanager
          name: jobmanager-api-nginx-siteconf
        - configMap:
            name: jobmanager-api-nginx-conf
            items:
              - key: nginx.conf
                path: nginx.conf
          name: jobmanager-api-nginx-conf
