apiVersion: apps/v1
kind: Deployment
metadata:
  name: etl-gardener-ndt5
  namespace: default
spec:
  replicas: 1
  selector:
    matchLabels:
      # Used to match pre-existing pods that may be affected during updates.
      run: etl-gardener-ndt5
  strategy:
    rollingUpdate:
      maxSurge: 1
      maxUnavailable: 1
    type: RollingUpdate
  # Pod template.
  template:
    metadata:
      labels:
        # Note: run=etl-gardener-server should match a service config with a
        # public IP and port so that it is publicly accessible.
        run: etl-gardener-ndt5
      annotations:
        # Tell prometheus service discovery to collect metrics from the containers.
        prometheus.io/scrape: 'true'
    spec:
      # When container receives SIGTERM, it begins a new checkpoint. This can
      # take longer than the default grace period of 30s.
      terminationGracePeriodSeconds: 300

      # Place the pod into the Guaranteed QoS by setting equal resource
      # requests and limits for *all* containers in the pod.
      # For more background, see:
      # https://github.com/kubernetes/community/blob/master/contributors/design-proposals/resource-qos.md
      containers:
      - image: gcr.io/{{GCLOUD_PROJECT}}/etl-gardener:{{GIT_COMMIT}}
        name: etl-gardener
        args: ["--prometheusx.listen-address=:9090"]
        env:
        - name: GARDENER_SERVICE
          value: "true"
        - name: PROJECT
          value: "{{GCLOUD_PROJECT}}"
        # NOTE: We read archives from the public archive for all projects.
        # TODO: Update when we address https://github.com/m-lab/dev-tracker/issues/369
        - name: TASKFILE_BUCKET
          value: "archive-measurement-lab"
        - name: START_DATE
          value: "20190513"
        - name: DATE_SKIP  # Should be 0 for normal operation
          value: "0"
        - name: TASK_FILE_SKIP # Should be 0 for normal operation
          value: "0"
        - name: EXPERIMENT
          value: "ndt/ndt5"
        - name: DATASET
          value: "batch"
        - name: FINAL_DATASET
          value: "base_tables"
        - name: QUEUE_BASE
          value: "etl-ndt5-batch-"
        - name: NUM_QUEUES
          value: "2"

        ports:
        - name: prometheus-port
          containerPort: 9090
        - name: service-port
          containerPort: 8080

        livenessProbe:
          httpGet:
            path: /alive
            port: service-port
          initialDelaySeconds: 30
          periodSeconds: 60

        resources:
          requests:
            memory: "3Gi"
            cpu: "1"
          limits:
            memory: "3Gi"
            cpu: "1"

        volumeMounts:
        - mountPath: /volume-claim
          name: ndt5-storage

      nodeSelector:
        gardener-node: "true"

      volumes:
      - name: ndt5-storage
        persistentVolumeClaim:
          claimName: gardener-ndt5-disk0

