browsertrix/backend/btrixcloud/k8s/templates/profilebrowser.yaml
Ilya Kreymer 5b6aa3bc95
Affinity + Tolerations + Cleanup Crawl Job (#256)
* k8s: add tolerations for 'nodeType=crawling:NoSchedule' to allow scheduling crawling on designated nodes for crawler and profiles jobs and statefulsets
* add affinity for 'nodeType=crawling' on crawling and profile browser statefulsets
* refactor crawljob: combine crawl_updater logic into base crawl_job
* increment new 'crawlAttemptCount' counter crawlconfig when crawl is started, not necessarily finished, to avoid deleting configs that had attempted but not finished crawls.
* better external mongodb support: use MONGO_DB_URL to set custom url directly, otherwise build from username, password and mongo host
2022-06-10 19:21:37 -07:00

102 lines
2.1 KiB
YAML

---
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: browser-{{ id }}
namespace: {{ namespace }}
labels:
browser: {{ id }}
role: browser
spec:
selector:
matchLabels:
browser: {{ id }}
role: browser
serviceName: browser-{{ id }}
replicas: 1
template:
metadata:
labels:
browser: {{ id }}
role: browser
spec:
affinity:
nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 1
preference:
matchExpressions:
- key: nodeType
operator: In
values:
- "{{ crawler_node_type }}"
podAffinity:
preferredDuringSchedulingIgnoredDuringExecution:
- weight: 2
podAffinityTerm:
topologyKey: "failure-domain.beta.kubernetes.io/zone"
labelSelector:
matchLabels:
job-name: job-{{ id }}
crawl: {{ id }}
tolerations:
- key: "nodeType"
operator: "Equal"
value: "crawling"
effect: "NoSchedule"
containers:
- name: browser
image: {{ crawler_image }}
imagePullPolicy: {{ crawler_image_pull_policy }}
command:
- create-login-profile
- --interactive
- --filename
- /tmp/profile.tar.gz
- --url
- {{ url }}
{%- if profile_filename %}
- --profile
- "@{{ profile_filename }}"
{%- endif %}
envFrom:
- secretRef:
name: storage-{{ storage_name }}
env:
- name: STORE_PATH
value: {{ storage_path }}
---
apiVersion: v1
kind: Service
metadata:
name: browser-{{ id }}
labels:
browser: {{ id }}
role: browser
spec:
clusterIP: None
selector:
browser: {{ id }}
role: browser
ports:
- protocol: TCP
port: 9223
name: browser-api
- protocol: TCP
port: 9222
name: browser-ws