browsertrix/backend/btrixcloud/k8s/templates/crawl_job.yaml
Ilya Kreymer 86ca9c4bac
backend: Fix for total crawl time limit. (#665)
* backend: fix for total crawl timelimit:
- time limit is computed for total job run time
- when limit is exceeded, job starts to stop crawls gracefully, equivalent to 'stop crawl' operation
- fix for #664

* rename crawl-timeout -> crawl_expire_time

* fix lint
2023-03-10 11:43:16 -08:00

116 lines
2.8 KiB
YAML

apiVersion: batch/v1
kind: Job
metadata:
name: job-{{ id }}
annotations:
btrix.run.manual: "{{ manual }}"
labels:
btrix.user: {{ userid }}
btrix.org: {{ oid }}
btrix.crawlconfig: {{ cid }}
spec:
backoffLimit: 1000
ttlSecondsAfterFinished: 20
template:
metadata:
labels:
btrix.user: {{ userid }}
btrix.org: {{ oid }}
btrix.crawlconfig: {{ cid }}
spec:
restartPolicy: OnFailure
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: nodeType
operator: In
values:
- "{{ crawler_node_type }}"
tolerations:
- key: "nodeType"
operator: "Equal"
value: "crawling"
effect: "NoSchedule"
containers:
- name: crawl-job
image: {{ job_image }}
imagePullPolicy: {{ job_pull_policy }}
command: ["uvicorn", "btrixcloud.k8s.crawl_job:app", "--host", "0.0.0.0", "--access-log", "--log-level", "info"]
volumeMounts:
- name: config-volume
mountPath: /config
envFrom:
- secretRef:
name: mongo-auth
env:
- name: JOB_ID
valueFrom:
fieldRef:
fieldPath: metadata.labels['job-name']
- name: RUN_MANUAL
value: "{{ manual }}"
- name: USER_ID
value: "{{ userid }}"
- name: ORG_ID
value: "{{ oid }}"
- name: CRAWL_CONFIG_ID
value: "{{ cid }}"
- name: REV
value: "{{ rev }}"
- name: TAGS
value: "{{ tags }}"
- name: CRAWL_EXPIRE_TIME
value: "{{ crawl_expire_time }}"
- name: STORE_PATH
valueFrom:
configMapKeyRef:
name: crawl-config-{{ cid }}
key: STORE_PATH
- name: STORE_FILENAME
valueFrom:
configMapKeyRef:
name: crawl-config-{{ cid }}
key: STORE_FILENAME
- name: STORAGE_NAME
valueFrom:
configMapKeyRef:
name: crawl-config-{{ cid }}
key: STORAGE_NAME
- name: PROFILE_FILENAME
valueFrom:
configMapKeyRef:
name: crawl-config-{{ cid }}
key: PROFILE_FILENAME
volumes:
- name: config-volume
configMap:
name: shared-job-config
items:
- key: config.yaml
path: config.yaml