Skip to content

Commit

Permalink
helm-chart: move more variables to sharedBackendEnv (#6761)
Browse files Browse the repository at this point in the history
This reduces duplication between deployment templates.
  • Loading branch information
SpecLad authored Sep 1, 2023
1 parent 213bcf0 commit 3deadda
Show file tree
Hide file tree
Showing 11 changed files with 56 additions and 364 deletions.
2 changes: 1 addition & 1 deletion backend_entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ cmd_run() {

echo "waiting for migrations to complete..."
while ! ~/manage.py migrate --check; do
sleep 1
sleep 10
done

exec supervisord -c "supervisord/$1.conf"
Expand Down
2 changes: 1 addition & 1 deletion helm-chart/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 0.9.0
version: 0.9.1

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
53 changes: 53 additions & 0 deletions helm-chart/templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,59 @@ Create the name of the service account to use
{{- end }}

{{- define "cvat.sharedBackendEnv" }}
{{- if .Values.redis.enabled }}
- name: CVAT_REDIS_HOST
value: "{{ .Release.Name }}-redis-master"
{{- else }}
- name: CVAT_REDIS_HOST
value: "{{ .Values.redis.external.host }}"
{{- end }}

- name: CVAT_REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.redis.secret.name) . }}"
key: redis-password

{{- if .Values.postgresql.enabled }}
- name: CVAT_POSTGRES_HOST
value: "{{ .Release.Name }}-postgresql"
- name: CVAT_POSTGRES_PORT
value: "{{ .Values.postgresql.service.ports.postgresql }}"
{{- else }}
- name: CVAT_POSTGRES_HOST
value: "{{ .Values.postgresql.external.host }}"
- name: CVAT_POSTGRES_PORT
value: "{{ .Values.postgresql.external.port }}"
{{- end }}

- name: CVAT_POSTGRES_USER
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: username
- name: CVAT_POSTGRES_DBNAME
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: database
- name: CVAT_POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: password

{{- if .Values.analytics.enabled}}
- name: CVAT_ANALYTICS
value: "1"
- name: DJANGO_LOG_SERVER_HOST
value: "{{ .Release.Name }}-vector"
- name: DJANGO_LOG_SERVER_PORT
value: "80"
- name: CLICKHOUSE_HOST
value: "{{ .Release.Name }}-clickhouse"
{{- end }}

- name: SMOKESCREEN_OPTS
value: {{ .Values.smokescreen.opts | toJson }}
{{- if .Values.nuclio.enabled }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,44 +53,6 @@ spec:
{{- end }}
args: ["run", "worker.webhooks"]
env:
{{- if .Values.redis.enabled }}
- name: CVAT_REDIS_HOST
value: "{{ .Release.Name }}-redis-master"
{{- else }}
- name: CVAT_REDIS_HOST
value: "{{ .Values.redis.external.host }}"
{{- end }}
- name: CVAT_REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.redis.secret.name) . }}"
key: redis-password
{{- if .Values.postgresql.enabled }}
- name: CVAT_POSTGRES_HOST
value: "{{ .Release.Name }}-postgresql"
- name: CVAT_POSTGRES_PORT
value: "{{ .Values.postgresql.service.ports.postgresql }}"
{{- else }}
- name: CVAT_POSTGRES_HOST
value: "{{ .Values.postgresql.external.host }}"
- name: CVAT_POSTGRES_PORT
value: "{{ .Values.postgresql.external.port }}"
{{- end }}
- name: CVAT_POSTGRES_USER
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: username
- name: CVAT_POSTGRES_DBNAME
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: database
- name: CVAT_POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: password
{{ include "cvat.sharedBackendEnv" . | indent 10 }}
{{- with .Values.cvat.backend.worker.webhooks.additionalEnv }}
{{- toYaml . | nindent 10 }}
Expand Down
48 changes: 0 additions & 48 deletions helm-chart/templates/cvat_backend/server/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -59,55 +59,7 @@ spec:
value: {{ .Values.cvat.backend.server.envs.DJANGO_MODWSGI_EXTRA_ARGS}}
- name: IAM_OPA_BUNDLE
value: "1"
{{- if .Values.redis.enabled }}
- name: CVAT_REDIS_HOST
value: "{{ .Release.Name }}-redis-master"
{{- else }}
- name: CVAT_REDIS_HOST
value: "{{ .Values.redis.external.host }}"
{{- end }}
- name: CVAT_REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.redis.secret.name) . }}"
key: redis-password
{{- if .Values.postgresql.enabled }}
- name: CVAT_POSTGRES_HOST
value: "{{ .Release.Name }}-postgresql"
- name: CVAT_POSTGRES_PORT
value: "{{ .Values.postgresql.service.ports.postgresql }}"
{{- else }}
- name: CVAT_POSTGRES_HOST
value: "{{ .Values.postgresql.external.host }}"
- name: CVAT_POSTGRES_PORT
value: "{{ .Values.postgresql.external.port }}"
{{- end }}
- name: CVAT_POSTGRES_USER
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: username
- name: CVAT_POSTGRES_DBNAME
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: database
- name: CVAT_POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: password
{{ include "cvat.sharedBackendEnv" . | indent 10 }}
{{- if .Values.analytics.enabled}}
- name: CVAT_ANALYTICS
value: "1"
- name: DJANGO_LOG_SERVER_HOST
value: "{{ .Release.Name }}-vector"
- name: DJANGO_LOG_SERVER_PORT
value: "80"
- name: CLICKHOUSE_HOST
value: "{{ .Release.Name }}-clickhouse"
{{- end }}
{{- with .Values.cvat.backend.server.additionalEnv }}
{{- toYaml . | nindent 10 }}
{{- end }}
Expand Down
48 changes: 0 additions & 48 deletions helm-chart/templates/cvat_backend/utils/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,55 +53,7 @@ spec:
{{- end }}
args: ["run", "utils"]
env:
{{- if .Values.redis.enabled }}
- name: CVAT_REDIS_HOST
value: "{{ .Release.Name }}-redis-master"
{{- else }}
- name: CVAT_REDIS_HOST
value: "{{ .Values.redis.external.host }}"
{{- end }}
- name: CVAT_REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.redis.secret.name) . }}"
key: redis-password
{{- if .Values.postgresql.enabled }}
- name: CVAT_POSTGRES_HOST
value: "{{ .Release.Name }}-postgresql"
- name: CVAT_POSTGRES_PORT
value: "{{ .Values.postgresql.service.ports.postgresql }}"
{{- else }}
- name: CVAT_POSTGRES_HOST
value: "{{ .Values.postgresql.external.host }}"
- name: CVAT_POSTGRES_PORT
value: "{{ .Values.postgresql.external.port }}"
{{- end }}
- name: CVAT_POSTGRES_USER
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: username
- name: CVAT_POSTGRES_DBNAME
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: database
- name: CVAT_POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: password
{{ include "cvat.sharedBackendEnv" . | indent 10 }}
{{- if .Values.analytics.enabled}}
- name: CVAT_ANALYTICS
value: "1"
- name: DJANGO_LOG_SERVER_HOST
value: "{{ .Release.Name }}-vector"
- name: DJANGO_LOG_SERVER_PORT
value: "80"
- name: CLICKHOUSE_HOST
value: "{{ .Release.Name }}-clickhouse"
{{- end }}
{{- with .Values.cvat.backend.utils.additionalEnv }}
{{- toYaml . | nindent 10 }}
{{- end }}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,53 +53,7 @@ spec:
{{- end }}
args: ["run", "worker.analytics_reports"]
env:
{{- if .Values.redis.enabled }}
- name: CVAT_REDIS_HOST
value: "{{ .Release.Name }}-redis-master"
{{- else }}
- name: CVAT_REDIS_HOST
value: "{{ .Values.redis.external.host }}"
{{- end }}
- name: CVAT_REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.redis.secret.name) . }}"
key: redis-password
{{- if .Values.postgresql.enabled }}
- name: CVAT_POSTGRES_HOST
value: "{{ .Release.Name }}-postgresql"
- name: CVAT_POSTGRES_PORT
value: "{{ .Values.postgresql.service.ports.postgresql }}"
{{- else }}
- name: CVAT_POSTGRES_HOST
value: "{{ .Values.postgresql.external.host }}"
- name: CVAT_POSTGRES_PORT
value: "{{ .Values.postgresql.external.port }}"
{{- end }}
- name: CVAT_POSTGRES_USER
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: username
- name: CVAT_POSTGRES_DBNAME
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: database
- name: CVAT_POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: password
{{ include "cvat.sharedBackendEnv" . | indent 10 }}
{{- if .Values.analytics.enabled}}
- name: DJANGO_LOG_SERVER_HOST
value: "{{ .Release.Name }}-vector"
- name: DJANGO_LOG_SERVER_PORT
value: "80"
- name: CLICKHOUSE_HOST
value: "{{ .Release.Name }}-clickhouse"
{{- end }}
{{- with .Values.cvat.backend.worker.analyticsreports.additionalEnv }}
{{- toYaml . | nindent 10 }}
{{- end }}
Expand Down
48 changes: 0 additions & 48 deletions helm-chart/templates/cvat_backend/worker_annotation/deployment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -53,55 +53,7 @@ spec:
{{- end }}
args: ["run", "worker.annotation"]
env:
{{- if .Values.redis.enabled }}
- name: CVAT_REDIS_HOST
value: "{{ .Release.Name }}-redis-master"
{{- else }}
- name: CVAT_REDIS_HOST
value: "{{ .Values.redis.external.host }}"
{{- end }}
- name: CVAT_REDIS_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.redis.secret.name) . }}"
key: redis-password
{{- if .Values.postgresql.enabled }}
- name: CVAT_POSTGRES_HOST
value: "{{ .Release.Name }}-postgresql"
- name: CVAT_POSTGRES_PORT
value: "{{ .Values.postgresql.service.ports.postgresql }}"
{{- else }}
- name: CVAT_POSTGRES_HOST
value: "{{ .Values.postgresql.external.host }}"
- name: CVAT_POSTGRES_PORT
value: "{{ .Values.postgresql.external.port }}"
{{- end }}
- name: CVAT_POSTGRES_USER
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: username
- name: CVAT_POSTGRES_DBNAME
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: database
- name: CVAT_POSTGRES_PASSWORD
valueFrom:
secretKeyRef:
name: "{{ tpl (.Values.postgresql.secret.name) . }}"
key: password
{{ include "cvat.sharedBackendEnv" . | indent 10 }}
{{- if .Values.analytics.enabled}}
- name: CVAT_ANALYTICS
value: "1"
- name: DJANGO_LOG_SERVER_HOST
value: "{{ .Release.Name }}-vector"
- name: DJANGO_LOG_SERVER_PORT
value: "80"
- name: CLICKHOUSE_HOST
value: "{{ .Release.Name }}-clickhouse"
{{- end }}
{{- with .Values.cvat.backend.worker.annotation.additionalEnv }}
{{- toYaml . | nindent 10 }}
{{- end }}
Expand Down
Loading

0 comments on commit 3deadda

Please sign in to comment.