apiVersion: batch/v1
kind: Job
metadata:
  name: scraper-job
spec:
  template:
    metadata:
      labels:
        app: scraper
    spec:
      affinity:
        nodeAffinity:
          requiredDuringSchedulingIgnoredDuringExecution:
            nodeSelectorTerms:
            - matchExpressions:
              - key: cloud.google.com/gke-preemptible
                operator: Exists
      restartPolicy: Never
      volumes:
      - name: google-cloud-key
        secret:
          secretName: scraper-datastore-key
      containers:
      - name: scraper
        image: eu.gcr.io/college-de-france/scraper:prod-v1.0.1
        resources:
          requests:
            cpu: "20m"
            memory: "250Mi"
        volumeMounts:
        - name: google-cloud-key
          mountPath: /var/secrets/google
        env:
        - name: GOOGLE_APPLICATION_CREDENTIALS
          value: /var/secrets/google/key.json
        command: ["python"]
        args: ["/scraper/scraper.py", "--project_id=college-de-france", "--user_agent=https://github.com/attwad/cdf-scraper", "--stop_when_present"]
