apiVersion: apps/v1
kind: Deployment
metadata:
  name: factotum-job-worker
  labels:
    app: factotum-job-worker
spec:
  # replicas: 2
  selector:
    matchLabels:
      app: factotum-job-worker
  template:
    metadata:
      labels:
        app: factotum-job-worker
    spec:
      initContainers:
        - name: change-ownership
          image: k8s.gcr.io/busybox
          command: ["/bin/sh", "-c"]
          args:
            - chmod 777 /var/run/docker.sock;
              chown -R 1000:1000 /private/tmp/data;
          volumeMounts:
            - name: docker-sock
              mountPath: /var/run/docker.sock
            - name: data-work
              mountPath: /private/tmp/data
      containers:
        - name: factotum-job-worker
          image: verdi:unity-v0.0.1
          command: ["supervisord", "--nodaemon"]
          volumeMounts:
            - name: docker-sock
              mountPath: /var/run/docker.sock
            - name: celeryconfig
              mountPath: /home/ops/hysds/celeryconfig.py
              subPath: celeryconfig.py
            - name: datasets
              mountPath: /home/ops/datasets.json
              subPath: datasets.json
            - name: supervisord-job-worker
              mountPath: /home/ops/supervisord.conf
              subPath: supervisord.conf
            - name: aws-credentials
              mountPath: /home/ops/.aws/credentials
              subPath: aws-credentials
            - name: data-work
              mountPath: /private/tmp/data
      volumes:
        - name: docker-sock
          hostPath:
            path: /var/run/docker.sock
        - name: celeryconfig
          configMap:
            name: celeryconfig
        - name: datasets
          configMap:
            name: datasets
        - name: supervisord-job-worker
          configMap:
            name: supervisord-job-worker
        - name: aws-credentials
          configMap:
            name: aws-credentials
        - name: data-work
          hostPath:
            path: /private/tmp/data
