k8s backend improvements: (#205)

- add liveness probe for crawls, configurable via 'crawler_liveness_port'
- add User system:anonymous permissions
- treat jobs that have exceeded total as 'partial_complete' (experimental)
This commit is contained in:
Ilya Kreymer 2022-03-30 14:39:06 -07:00 committed by GitHub
parent 9e2274f612
commit aa83d51f7a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 22 additions and 0 deletions

View File

@ -45,6 +45,8 @@ class K8SManager:
self.crawl_retries = int(os.environ.get("CRAWL_RETRIES", "3"))
self.crawler_liveness_port = int(os.environ.get("CRAWLER_LIVENESS_PORT", 0))
self.no_delete_jobs = os.environ.get("NO_DELETE_JOBS", "0") != "0"
self.grace_period = int(os.environ.get("GRACE_PERIOD_SECS", "600"))
@ -524,6 +526,9 @@ class K8SManager:
return "stopping"
# job fully done, do not treat as running or stopping
if finished >= total:
return "partial_complete"
return None
# pylint: disable=no-self-use
@ -699,6 +704,16 @@ class K8SManager:
},
}
if self.crawler_liveness_port:
liveness_probe = {
"httpGet": {"path": "/healthz", "port": self.crawler_liveness_port},
"initialDelaySeconds": 15,
"periodSeconds": 120,
"failureThreshold": 3,
}
else:
liveness_probe = None
job_template = {
"metadata": {"annotations": annotations},
"spec": {
@ -749,6 +764,7 @@ class K8SManager:
},
],
"resources": resources,
"livenessProbe": liveness_probe,
}
],
"volumes": [

View File

@ -21,6 +21,8 @@ data:
CRAWLER_REQUESTS_MEM: "{{ .Values.crawler_requests_memory }}"
CRAWLER_LIMITS_MEM: "{{ .Values.crawler_limits_memory }}"
CRAWLER_LIVENESS_PORT: "{{ .Values.crawler_liveness_port | default 0 }}"
{{- if .Values.crawler_pv_claim }}
CRAWLER_PV_CLAIM: "{{ .Values.crawler_pv_claim }}"
{{- end }}

View File

@ -24,6 +24,10 @@ subjects:
name: default
namespace: {{ .Release.Namespace }}
- kind: User
name: system:anonymous
namespace: {{ .Release.Namespace }}
roleRef:
kind: Role
name: crawler-run