clearml-helm-charts/charts/clearml/templates/apiserver-deployment.yaml
Valeriano Manassero 7995fc8441
Add external multihost elasticsearch support (#150)
* Changed: elasticsearch connstring creation

* Changed: elasticsearch connstring creation

* Changed: bump up version
2023-02-09 10:29:00 +01:00

266 lines
11 KiB
YAML

{{- if .Values.apiserver.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "apiserver.referenceName" . }}
labels:
{{- include "clearml.labels" . | nindent 4 }}
spec:
replicas: {{ .Values.apiserver.replicaCount }}
selector:
matchLabels:
{{- include "apiserver.selectorLabels" . | nindent 6 }}
template:
metadata:
{{- with .Values.apiserver.podAnnotations }}
annotations:
{{- toYaml . | nindent 8 }}
{{- end }}
labels:
{{- include "apiserver.selectorLabels" . | nindent 8 }}
spec:
{{- if .Values.imageCredentials.enabled }}
imagePullSecrets:
{{- if .Values.imageCredentials.existingSecret }}
- name: {{ .Values.imageCredentials.existingSecret }}
{{- else }}
- name: clearml-registry-key
{{- end }}
{{- end }}
{{- if or .Values.apiserver.additionalConfigs .Values.apiserver.existingAdditionalConfigsConfigMap .Values.apiserver.existingAdditionalConfigsSecret }}
volumes:
- name: apiserver-config
{{- if or .Values.apiserver.existingAdditionalConfigsConfigMap }}
configMap:
name: {{ .Values.apiserver.existingAdditionalConfigsConfigMap }}
{{- else if or .Values.apiserver.existingAdditionalConfigsSecret }}
secret:
secretName: {{ .Values.apiserver.existingAdditionalConfigsSecret }}
{{- else if or .Values.apiserver.additionalConfigs }}
configMap:
name: "{{ include "apiserver.referenceName" . }}-configmap"
{{- end }}
{{- end }}
securityContext: {{ toYaml .Values.apiserver.podSecurityContext | nindent 8 }}
initContainers:
- name: init-apiserver
{{- if .Values.enterpriseFeatures.enabled }}
image: "{{ .Values.apiserver.image.repository }}:{{ .Values.enterpriseFeatures.apiserverImageTagOverride }}"
{{- else }}
image: "{{ .Values.apiserver.image.repository }}:{{ .Values.apiserver.image.tag }}"
{{- end }}
command:
- /bin/sh
- -c
- >
set -x;
{{- if .Values.elasticsearch.enabled }}
while [ $(curl -sw '%{http_code}' "http://{{ include "elasticsearch.servicename" . }}:{{ include "elasticsearch.serviceport" . }}/_cluster/health" -o /dev/null) -ne 200 ] ; do
echo "waiting for elasticsearch" ;
sleep 5 ;
done ;
{{- end }}
{{- if .Values.mongodb.enabled }}
while [ $(curl --telnet-option BOGUS --connect-timeout 2 -s "telnet://{{ .Release.Name }}-mongodb:27017" -o /dev/null; echo $?) -ne 49 ] ; do
echo "waiting for mongodb" ;
sleep 5 ;
done ;
{{- end }}
{{- if .Values.redis.enabled }}
while [ $(curl --telnet-option BOGUS --connect-timeout 2 -s "telnet://{{ include "redis.servicename" . }}:{{ include "redis.serviceport" . }}" -o /dev/null; echo $?) -ne 49 ] ; do
echo "waiting for redis" ;
sleep 5 ;
done ;
{{- end }}
containers:
- name: clearml-apiserver
{{- if .Values.enterpriseFeatures.enabled }}
image: "{{ .Values.apiserver.image.repository }}:{{ .Values.enterpriseFeatures.apiserverImageTagOverride }}"
{{- else }}
image: "{{ .Values.apiserver.image.repository }}:{{ .Values.apiserver.image.tag }}"
{{- end }}
imagePullPolicy: {{ .Values.apiserver.image.pullPolicy }}
ports:
- name: http
containerPort: 8008
protocol: TCP
env:
- name: CLEARML__HOSTS__ELASTIC__WORKERS__HOSTS
value: {{ include "elasticsearch.connectionstring" . }}
- name: CLEARML__HOSTS__ELASTIC__EVENTS__HOSTS
value: {{ include "elasticsearch.connectionstring" . }}
- name: CLEARML__HOSTS__ELASTIC__DATASETS__HOSTS
value: {{ include "elasticsearch.connectionstring" . }}
- name: CLEARML__HOSTS__ELASTIC__LOGS__HOSTS
value: {{ include "elasticsearch.connectionstring" . }}
{{- if .Values.mongodb.enabled }}
- name: CLEARML_MONGODB_SERVICE_CONNECTION_STRING
value: {{ include "mongodb.connectionstring" . | quote }}
{{- else }}
- name: CLEARML__HOSTS__MONGO__BACKEND__HOST
value: {{ .Values.externalServices.mongodbConnectionStringBackend | quote }}
- name: CLEARML__HOSTS__MONGO__AUTH__HOST
value: {{ .Values.externalServices.mongodbConnectionStringAuth | quote }}
{{- end }}
- name: CLEARML_REDIS_SERVICE_HOST
value: {{ include "redis.servicename" . }}
- name: CLEARML_REDIS_SERVICE_PORT
value: "{{ include "redis.serviceport" . }}"
- name: CLEARML_CONFIG_PATH
value: /opt/clearml/config
- name: CLEARML__apiserver__default_company_name
value: "{{ .Values.clearml.defaultCompany }}"
{{- if not (eq .Values.clearml.cookieDomain "") }}
- name: CLEARML__APISERVER__AUTH__SESSION_AUTH_COOKIE_NAME
value: {{ .Values.clearml.cookieName }}
- name: CLEARML__APISERVER__AUTH__COOKIES__DOMAIN
value: ".{{ .Values.clearml.cookieDomain }}"
{{- end }}
- name: CLEARML__secure__credentials__apiserver__user_key
valueFrom:
secretKeyRef:
name: clearml-conf
key: apiserver_key
- name: CLEARML__secure__credentials__apiserver__user_secret
valueFrom:
secretKeyRef:
name: clearml-conf
key: apiserver_secret
- name: CLEARML__secure__auth__token_secret
valueFrom:
secretKeyRef:
name: clearml-conf
key: secure_auth_token_secret
{{- if .Values.apiserver.prepopulateEnabled }}
- name: CLEARML__APISERVER__PRE_POPULATE__ENABLED
value: "true"
- name: CLEARML__APISERVER__PRE_POPULATE__ZIP_FILES
value: "/opt/clearml/db-pre-populate"
{{- end }}
{{- if .Values.enterpriseFeatures.enabled }}
- name: CLEARML__apiserver__default_company
value: "{{ .Values.enterpriseFeatures.defaultCompanyGuid }}"
- name: APPLY_ES_MAPPINGS
value: "false"
- name: NUMBER_OF_GUNICORN_WORKERS
value: "{{ .Values.apiserver.processes.count }}"
- name: GUNICORN_TIMEOUT
value: "{{ .Values.apiserver.processes.timeout }}"
- name: GUNICORN_MAX_REQUESTS
value: "{{ .Values.apiserver.processes.maxRequests }}"
- name: GUNICORN_MAX_REQUESTS_JITTER
value: "{{ .Values.apiserver.processes.maxRequestsJitter }}"
- name: CLEARML_CONFIG_VERBOSE
value: "0"
- name: CLEARML__SERVICES__APPLICATIONS__TEMPLATES__FOLDER
value: "/opt/allegro/config/applications"
- name: CLEARML__apiserver__apilog__prefix
value: "fluentd."
- name: CLEARML__apiserver__apilog__index_name_prefix__default
value: "allegro.apiserver.api-logs."
- name: CLEARML__apiserver__apilog__adapter
value: "logging"
- name: CLEARML__apiserver__apilog__rotation__index_size
value: "225000"
- name: CLEARML__services__tasks__non_responsive_tasks_watchdog__enabled
value: "false"
- name: CLEARML__APISERVER__AUTH__COOKIES__MAX_AGE
value: "2678400"
- name: CLEARML__services__frames__scroll_state_expiration_hours
value: "6"
- name: CLEARML__services__organization__features__applications
value: "true"
- name: CLEARML__services__organization__features__app_management
value: "true"
- name: CLEARML__SERVICES___ELASTIC__MAPPINGS__EVENTS__NUMBER_OF_REPLICAS
value: {{ .Values.apiserver.indexReplicas | quote }}
- name: CLEARML__SERVICES___ELASTIC__MAPPINGS__EVENTS__NUMBER_OF_SHARDS
value: {{ .Values.apiserver.indexShards | quote }}
- name: CLEARML__APISERVER__LOG_CALLS
value: "false"
- name: ALLEGRO_ENV
value: "onprem_k8s"
- name: CLEARML__secure__credentials__fileserver__user_key
valueFrom:
secretKeyRef:
name: clearml-conf
key: fileserver_key
- name: CLEARML__secure__credentials__fileserver__user_secret
valueFrom:
secretKeyRef:
name: clearml-conf
key: fileserver_secret
- name: CLEARML__secure__applications__agents_credentials__apps_agent__user_key
valueFrom:
secretKeyRef:
name: clearml-conf
key: apps_agent_key
- name: CLEARML__secure__applications__agents_credentials__apps_agent__user_secret
valueFrom:
secretKeyRef:
name: clearml-conf
key: apps_agent_secret
{{- else }}
- name: CLEARML__SECURE__CREDENTIALS__TESTS__USER_KEY
valueFrom:
secretKeyRef:
name: "clearml-conf"
key: test_user_key
- name: CLEARML__SECURE__CREDENTIALS__TESTS__USER_SECRET
valueFrom:
secretKeyRef:
name: "clearml-conf"
key: test_user_secret
- name: CLEARML_ENV
value: "helm-cloud"
{{- end }}
{{- if .Values.apiserver.extraEnvs }}
{{ toYaml .Values.apiserver.extraEnvs | nindent 10 }}
{{- end }}
{{- if not .Values.enterpriseFeatures.enabled }}
args:
- apiserver
{{- end }}
livenessProbe:
initialDelaySeconds: 60
httpGet:
path: /debug.ping
port: 8008
readinessProbe:
initialDelaySeconds: 60
failureThreshold: 8
httpGet:
{{- if .Values.enterpriseFeatures.enabled }}
path: /server.health_check
{{- else }}
path: /debug.ping
{{- end }}
port: 8008
httpHeaders:
- name: Authorization
value: Basic {{ include "readinessProbeAuth" . }}
{{- if or .Values.apiserver.additionalConfigs .Values.apiserver.existingAdditionalConfigsConfigMap .Values.apiserver.existingAdditionalConfigsSecret }}
volumeMounts:
- name: apiserver-config
{{- if .Values.enterpriseFeatures.enabled }}
mountPath: /opt/clearml/config/default
{{- else }}
mountPath: /opt/clearml/config
{{- end }}
{{- end }}
resources:
{{- toYaml .Values.apiserver.resources | nindent 12 }}
{{- with .Values.apiserver.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.apiserver.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.apiserver.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- end }}