apiVersion: v1
kind: Pod
metadata:
  name: factotum
spec:
  initContainers:
    - name: init-mozart-rabbitmq
      image: busybox
      volumeMounts:
      - mountPath: /wait-for-it.sh
        name: global-config
        subPath: wait-for-it.sh
      command: ['sh', '/wait-for-it.sh', '-t', '0', 'mozart-rabbitmq:15672']
    - name: init-mozart-redis
      image: busybox
      volumeMounts:
      - mountPath: /wait-for-it.sh
        name: global-config
        subPath: wait-for-it.sh
      command: ['sh', '/wait-for-it.sh', '-t', '0', 'mozart-redis:6379']
    - name: init-mozart-elasticsearch
      image: busybox
      volumeMounts:
      - mountPath: /wait-for-it.sh
        name: global-config
        subPath: wait-for-it.sh
      command: ['sh', '/wait-for-it.sh', '-t', '0', 'mozart-elasticsearch:9200']
    - name: init-metrics-redis
      image: busybox
      volumeMounts:
      - mountPath: /wait-for-it.sh
        name: global-config
        subPath: wait-for-it.sh
      command: ['sh', '/wait-for-it.sh', '-t', '0', 'metrics-redis:6379']
    - name: init-grq-rest
      image: busybox
      volumeMounts:
      - mountPath: /wait-for-it.sh
        name: global-config
        subPath: wait-for-it.sh
      command: ['sh', '/wait-for-it.sh', '-t', '0', 'grq:8878']
  containers:
  - name: factotum
    image: hysds/verdi:latest
    ports:
    - containerPort: 22
      name: ssh
    - containerPort: 80
      name: http
    - containerPort: 443
      name: https
    - containerPort: 8085
      name: dav
    - containerPort: 9001
      name: supervisord
    resources:
      limits:
        cpu: "0.5"
    securityContext: 
      privileged: true 
    volumeMounts:
    - mountPath: /var/run/docker.sock
      name: dockersock
    - mountPath: /data/work
      name: work
    - mountPath: /home/ops/.ssh/id_rsa
      name: global-secrets
      subPath: id_rsa
      readOnly: true
    - mountPath: /home/ops/.ssh/authorized_keys
      name: global-secrets
      subPath: id_rsa.pub
      readOnly: true
    - mountPath: /home/ops/.aws/config
      name: global-config
      subPath: aws_config
      readOnly: true
    - mountPath: /home/ops/.aws/credentials
      name: global-config
      subPath: aws_credentials
      readOnly: true
    - mountPath: /home/ops/verdi/etc/celeryconfig.py
      name: global-config
      subPath: celeryconfig.py
    - mountPath: /home/ops/verdi/etc/datasets.json
      name: global-config
      subPath: datasets.json
    - mountPath: /home/ops/verdi/etc/conf.d/factotum.conf
      name: config
      subPath: factotum.conf
    - mountPath: /home/ops/verdi/log
      name: log
  volumes:
  - name: dockersock
    hostPath:
      path: /var/run/docker.sock
  - name: work
    hostPath:
      path: /data/work
  - name: global-secrets
    secret:
      secretName: hysds-global-secrets
  - name: global-config
    configMap:
      name: hysds-global-config
  - name: config
    configMap:
      name: hysds-factotum-config
  - name: log
    emptyDir: {}
