node affinity: set to required instead of preferred to keep crawlers on dedicated infrastructure (#1366)

Previously, the crawler pods use preferred node affinity, instead of
required node affinity. This results in crawler nodes running on the
main node pool. Instead, we want to ensure crawler nodes are running on
dedicated node pool (if configured).
- Converts 'preferred node affinity' to 'required node affinity' for
the node pool, while keeping preferred pod affinity for keeping all
crawler / redis pods together.
- For profiles, updates to same node affinity, and also adds
resource constraint to match a single crawler for profile browser,
which did not have resource constraints.
This commit is contained in:
Ilya Kreymer 2023-11-13 10:02:05 -08:00 committed by GitHub
parent 67892994a6
commit a6a78c9ef2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 25 additions and 12 deletions

View File

@ -60,24 +60,28 @@ spec:
claimName: {{ name }} claimName: {{ name }}
affinity: affinity:
{% if crawler_node_type %}
nodeAffinity: nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution: requiredDuringSchedulingIgnoredDuringExecution:
- weight: 1 nodeSelectorTerms:
preference: - matchExpressions:
matchExpressions:
- key: nodeType - key: nodeType
operator: In operator: In
values: values:
- "{{ crawler_node_type }}" - "{{ crawler_node_type }}"
{% endif %}
podAffinity: podAffinity:
preferredDuringSchedulingIgnoredDuringExecution: preferredDuringSchedulingIgnoredDuringExecution:
- weight: 2 - weight: 10
podAffinityTerm: podAffinityTerm:
topologyKey: "failure-domain.beta.kubernetes.io/zone" topologyKey: "kubernetes.io/hostname"
labelSelector: labelSelector:
matchLabels: matchExpressions:
crawl: {{ id }} - key: crawl
operator: In
values:
- {{ id }}
tolerations: tolerations:
- key: nodeType - key: nodeType

View File

@ -18,16 +18,17 @@ spec:
restartPolicy: OnFailure restartPolicy: OnFailure
{% if crawler_node_type %}
affinity: affinity:
nodeAffinity: nodeAffinity:
preferredDuringSchedulingIgnoredDuringExecution: requiredDuringSchedulingIgnoredDuringExecution:
- weight: 1 nodeSelectorTerms:
preference: - matchExpressions:
matchExpressions:
- key: nodeType - key: nodeType
operator: In operator: In
values: values:
- "{{ crawler_node_type }}" - "{{ crawler_node_type }}"
{% endif %}
tolerations: tolerations:
- key: nodeType - key: nodeType
@ -74,3 +75,11 @@ spec:
- name: CHROME_FLAGS - name: CHROME_FLAGS
value: "--proxy-server=socks5://{{ crawler_socks_proxy_host }}:{{ crawler_socks_proxy_port | default('9050') }}" value: "--proxy-server=socks5://{{ crawler_socks_proxy_host }}:{{ crawler_socks_proxy_port | default('9050') }}"
{% endif %} {% endif %}
resources:
limits:
memory: "{{ crawler_memory }}"
requests:
cpu: "{{ crawler_cpu }}"
memory: "{{ crawler_memory }}"