apiVersion: v1
kind: Pod
metadata:
  name: mc
spec:
  restartPolicy: Never
  initContainers:
    - name: minio-setup
      image: minio/mc:RELEASE.2022-03-13T22-34-00Z
      env:
        - name: MINIO_ACCESS_KEY
          value: hysds
        - name: MINIO_SECRET_KEY
          value: password
      command: ["/bin/sh", "-c"]
      args:
        - until curl -s -I http://minio:9000; do echo "(Minio server) waiting..."; sleep 2; done;
          until curl -s -I http://minio:9001; do echo "(Minio client) waiting..."; sleep 2; done;
          mc alias set s3 http://minio:9000 ${MINIO_ACCESS_KEY} ${MINIO_SECRET_KEY};
          mc mb s3/datasets;
          mc policy set public s3/datasets;
  containers:
    - name: publish-aoi
      image: hysds-core:unity-v0.0.1
      command: ["/bin/sh", "-c"]
      args:
        - cd /home/ops/hysds/test/examples;
          /home/ops/hysds/scripts/ingest_dataset.py AOI_sacramento_valley /home/ops/datasets.json;
      volumeMounts:
        - name: celeryconfig
          mountPath: /home/ops/hysds/celeryconfig.py
          subPath: celeryconfig.py
        - name: aws-credentials
          mountPath: /home/ops/.aws/credentials
          subPath: aws-credentials
        - name: datasets
          mountPath: /home/ops/datasets.json
          subPath: datasets.json
  volumes:
    - name: celeryconfig
      configMap:
        name: celeryconfig
    - name: aws-credentials
      configMap:
        name: aws-credentials
    - name: datasets
      configMap:
        name: datasets
