Skip to content

Commit

Permalink
merged workers templates
Browse files Browse the repository at this point in the history
  • Loading branch information
AndrewChubatiuk committed Mar 27, 2024
1 parent 4f023b0 commit 940caf3
Show file tree
Hide file tree
Showing 8 changed files with 178 additions and 454 deletions.
5 changes: 1 addition & 4 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -34,10 +34,7 @@ jobs:
postgresql:
auth:
password: $(openssl rand -base64 32)
adhocWorker:
env:
WORKERS_COUNT: 1
scheduledWorker:
worker:
env:
WORKERS_COUNT: 1
EOM
Expand Down
125 changes: 55 additions & 70 deletions README.md

Large diffs are not rendered by default.

31 changes: 10 additions & 21 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -33,24 +33,10 @@ If release name contains chart name it will be used as a full name.
{{- end -}}

{{/*
Create a default fully qualified adhocWorker name.
Create a default fully qualified worker name.
*/}}
{{- define "redash.adhocWorker.fullname" -}}
{{- template "redash.fullname" . -}}-adhocworker
{{- end -}}

{{/*
Create a default fully qualified scheduledworker name.
*/}}
{{- define "redash.scheduledWorker.fullname" -}}
{{- template "redash.fullname" . -}}-scheduledworker
{{- end -}}

{{/*
Create a default fully qualified genericWorker name.
*/}}
{{- define "redash.genericWorker.fullname" -}}
{{- template "redash.fullname" . -}}-genericworker
{{- define "redash.worker.fullname" -}}
{{- template "redash.fullname" . -}}-{{ .workerName }}worker
{{- end -}}

{{/*
Expand Down Expand Up @@ -92,14 +78,14 @@ Shared environment block used across each component.
{{- if not .Values.redash.selfManagedSecrets }}
{{- if not .Values.postgresql.enabled }}
- name: REDASH_DATABASE_URL
{{- if .Values.externalPostgreSQLSecret }}
{{ if .Values.externalPostgreSQLSecret -}}
valueFrom:
secretKeyRef:
{{- .Values.externalPostgreSQLSecret | toYaml | nindent 6 }}
{{- else }}
{{ else -}}
value: {{ default "" .Values.externalPostgreSQL | quote }}
{{- end }}
{{- else }}
{{ else -}}
- name: REDASH_DATABASE_USER
value: "{{ .Values.postgresql.auth.username }}"
- name: REDASH_DATABASE_PASSWORD
Expand Down Expand Up @@ -526,6 +512,9 @@ Common labels
{{- define "redash.labels" -}}
helm.sh/chart: {{ include "redash.chart" . }}
{{ include "redash.selectorLabels" . }}
{{- if .workerName }}
app.kubernetes.io/component: {{ .workerName }}worker
{{- end }}
{{- if .Chart.AppVersion }}
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
{{- end }}
Expand All @@ -552,4 +541,4 @@ Create the name of the service account to use
{{- end -}}

# This ensures a random value is provided for postgresql.auth.password:
required "A secure random value for .postgresql.auth.assword is required" .Values.postgresql.auth.password
required "A secure random value for .postgresql.auth.password is required" .Values.postgresql.auth.password
77 changes: 0 additions & 77 deletions templates/adhocworker-deployment.yaml

This file was deleted.

77 changes: 0 additions & 77 deletions templates/genericworker-deployment.yaml

This file was deleted.

77 changes: 0 additions & 77 deletions templates/scheduledworker-deployment.yaml

This file was deleted.

79 changes: 79 additions & 0 deletions templates/worker-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
{{ range $workerName, $config := .Values.workers -}}
{{- $workerConfig := merge (deepCopy $.Values.worker) $config }}
{{- $context := deepCopy $ | merge (dict "workerName" $workerName)}}
---
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ include "redash.worker.fullname" $context }}
labels:
{{- include "redash.labels" $context | nindent 4 }}
spec:
replicas: {{ $workerConfig.replicaCount }}
selector:
matchLabels:
{{- include "redash.selectorLabels" $context | nindent 6 }}
template:
metadata:
labels:
{{- include "redash.selectorLabels" $context | nindent 8 }}
{{- if $workerConfig.podLabels }}
{{- tpl (toYaml $workerConfig.podLabels) $ | nindent 8 }}
{{- end }}
{{- if $workerConfig.podAnnotations }}
annotations:
{{ toYaml $workerConfig.podAnnotations | nindent 8 }}
{{- end }}
spec:
{{- with $.Values.imagePullSecrets }}
imagePullSecrets:
{{- toYaml . | nindent 8 }}
{{- end }}
serviceAccountName: {{ include "redash.serviceAccountName" $context }}
securityContext:
{{- toYaml $workerConfig.podSecurityContext | nindent 8 }}
containers:
- name: {{ include "redash.name" $context }}-{{ $workerName }}worker
securityContext:
{{- toYaml $workerConfig.securityContext | nindent 12 }}
image: {{ $.Values.image.registry }}/{{ $.Values.image.repo }}:{{ $.Values.image.tag }}
imagePullPolicy: {{ $.Values.image.pullPolicy }}
command: ["/bin/sh"]
args: ["-c", ". /config/dynamicenv.sh && /app/bin/docker-entrypoint worker"]
volumeMounts:
- name: config
mountPath: /config
{{- with $workerConfig.volumeMounts }}
{{- toYaml . | nindent 12 }}
{{- end }}
livenessProbe: {{ toYaml $workerConfig.livenessProbe | nindent 12 }}
env:
{{- include "redash.env" $ | nindent 12 }}
{{- range $key, $value := $workerConfig.env }}
- name: "{{ $key }}"
value: "{{ $value }}"
{{- end }}
{{ if (include "redash.envFrom" $) }}
envFrom:
{{- include "redash.envFrom" $ | nindent 12 }}
{{- end }}
{{- if $workerConfig.resources }}
resources: {{ toYaml $workerConfig.resources | nindent 12 }}
{{- end }}
volumes:
- name: config
configMap:
name: {{ include "redash.fullname" $context }}
{{- with $workerConfig.volumes }}
{{- toYaml . | nindent 8 }}
{{- end }}
{{- if $workerConfig.nodeSelector }}
nodeSelector: {{ toYaml $workerConfig.nodeSelector | nindent 8 }}
{{- end }}
{{- with $workerConfig.affinity }}
affinity: {{ toYaml . | nindent 8 }}
{{- end }}
{{- with $workerConfig.tolerations }}
tolerations: {{ toYaml . | nindent 8 }}
{{- end }}
{{- end }}
Loading

0 comments on commit 940caf3

Please sign in to comment.