apiVersion: v1
kind: ReplicationController
metadata:
  name: consolidater
  labels:
    app: consolidater
spec:
  replicas: 0
  selector:
    app: consolidater
  template:
    metadata:
      labels:
        app: consolidater
    spec:
      automountServiceAccountToken: true
      terminationGracePeriodSeconds: 5
      tolerations:
        - key: "preemptible"
          operator: "Equal"
          value: "true"
          effect: "NoSchedule"
      volumes:
        - name: "local-ssd"
          hostPath:
            path: "/mnt/disks/ssd0"
      containers:
        - name: consolidater
          image: geocube-consolidater:latest
          imagePullPolicy: "IfNotPresent"
          ports:
            - containerPort: 9000
              protocol: TCP
          resources:
            requests:
              cpu: 1900m
              memory: 1500Mi
            limits:
              memory: 4Gi
          command: ["/bin/sh","-c"]
          args:
            - |
              UUID=`uuid`;
              WORKDIR=/local-ssd/$UUID;
              mkdir -p $WORKDIR;
              /consolidater -eventsQueue events -consolidationsQueue consolidations -pgqConnection=postgresql://postgres:1234@10.20.0.95:5432/db-geocube -workdir $WORKDIR -cancelledJobs=/geocube-cancelled-jobs || true;
              exitcode=$?;
              rm -rf $WORKDIR;
              exit $exitcode;
          volumeMounts:
            - mountPath: "/local-ssd"
              name: "local-ssd"
