Skip to content

Commit

Permalink
feat(chart): add tolerations, nodeSelector, and affinity support for …
Browse files Browse the repository at this point in the history
…all pods
  • Loading branch information
electrosenpai committed Nov 20, 2024
1 parent 954f2cb commit f60f759
Show file tree
Hide file tree
Showing 7 changed files with 133 additions and 211 deletions.
190 changes: 18 additions & 172 deletions templates/api-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,34 +23,46 @@ spec:
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
{{- with .Values.api.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.api.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.api.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
initContainers:
{{ if .Values.postgresql.enabled }}
{{ if .Values.postgresql.enabled }}
- name: wait-for-postgresql
image: "docker.io/bitnami/kubectl:{{ include "kubectlVersion" . }}"
args:
- wait
- pod/{{ .Release.Name }}-postgresql-0
- --for=condition=ready
- --timeout=180s
{{ end }}
{{ if .Values.redis.enabled }}
{{ end }}
{{ if .Values.redis.enabled }}
- name: wait-for-redis
image: "docker.io/bitnami/kubectl:{{ include "kubectlVersion" . }}"
args:
- wait
- pod/{{ .Release.Name }}-redis-master-0
- --for=condition=ready
- --timeout=180s
{{ end }}
{{ if .Values.minio.enabled }}
{{ end }}
{{ if .Values.minio.enabled }}
- name: wait-for-minio
image: "docker.io/bitnami/kubectl:{{ include "kubectlVersion" . }}"
args:
- wait
- pod/{{ .Release.Name }}-minio-0
- --for=condition=ready
- --timeout=180s
{{ end }}
{{ end }}
- name: wait-for-migrations
image: "docker.io/bitnami/kubectl:{{ include "kubectlVersion" . }}"
args:
Expand All @@ -61,178 +73,12 @@ spec:
containers:
- args: ["bundle", "exec", "rails", "s", "-b", "::"]
env:
- name: RAILS_ENV
value: {{ .Values.api.rails.env }}
- name: DATABASE_URL
valueFrom:
secretKeyRef:
name: {{ include "secret-path" . }}
key: databaseUrl
- name: REDIS_URL
valueFrom:
secretKeyRef:
name: {{ include "secret-path" . }}
key: redisUrl
- name: LAGO_REDIS_CACHE_URL
valueFrom:
secretKeyRef:
name: {{ include "secret-path" . }}
key: redisUrl
- name: LAGO_PDF_URL
{{- $pdfHost := printf "%s-pdf-svc.%s" .Release.Name .Release.Namespace}}
value: {{ printf "http://%s:%v" $pdfHost .Values.pdf.service.port | quote }}
- name: LAGO_API_URL
value: {{ required "apiUrl value is required" .Values.apiUrl | quote }}
- name: LAGO_FRONT_URL
value: {{ required "frontUrl value is required" .Values.frontUrl | quote }}
- name: LAGO_SIDEKIQ_WEB
value: {{ .Values.api.sidekiqWeb.enabled | quote }}
- name: RAILS_LOG_TO_STDOUT
value: {{ .Values.api.rails.logStdout | quote }}
- name: LAGO_RSA_PRIVATE_KEY
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-secrets
key: rsaPrivateKey
- name: SECRET_KEY_BASE
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-secrets
key: secretKeyBase
- name: ENCRYPTION_DETERMINISTIC_KEY
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-secrets
key: encryptionDeterministicKey
- name: ENCRYPTION_KEY_DERIVATION_SALT
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-secrets
key: encryptionKeyDerivationSalt
- name: ENCRYPTION_PRIMARY_KEY
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-secrets
key: encryptionPrimaryKey
- name: LAGO_DISABLE_SEGMENT
value: {{ not .Values.global.segment.enabled | quote }}
- name: LAGO_DISABLE_SIGNUP
value: {{ not .Values.global.signup.enabled | quote }}
- name: DATABASE_POOL
value: {{ mul .Values.api.rails.maxThreads .Values.api.rails.webConcurrency | quote }}
- name: RAILS_MAX_THREADS
value: {{ .Values.api.rails.maxThreads | quote }}
- name: RAILS_MIN_THREADS
value: "0"
- name: SIDEKIQ_EVENTS
value: "true"
- name: WEB_CONCURRENCY
value: {{ .Values.api.rails.webConcurrency | quote }}
- name: LAGO_LOG_LEVEL
value: {{ .Values.api.rails.logLevel | quote }}
{{- with .Values.api.extraEnv }}
{{- range $key, $value := . }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
{{ if .Values.global.license }}
- name: LAGO_LICENSE
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-secrets
key: license
{{ end }}


{{ if or .Values.global.s3.enabled .Values.minio.enabled }}
- name: LAGO_USE_AWS_S3
value: "true"
{{- if .Values.minio.enabled }}
- name: LAGO_AWS_S3_PATH_STYLE
value: "true"
{{- end }}
{{ if or .Values.global.s3.endpoint .Values.minio.endpoint }}
- name: LAGO_AWS_S3_ENDPOINT
value: {{ if .Values.minio.enabled }}
{{ .Values.minio.endpoint | quote }}
{{ else }}
{{ .Values.global.s3.endpoint | quote }}
{{ end }}
{{ end }}

{{ if or .Values.global.s3.accessKeyId .Values.minio.enabled .Values.global.existingSecret }}
- name: LAGO_AWS_S3_ACCESS_KEY_ID
valueFrom:
secretKeyRef:
name: {{ if .Values.minio.enabled }}
{{ .Release.Name }}-minio
{{ else }}
{{ include "secret-path" . }}
{{ end }}
key: {{ if .Values.minio.enabled }}
rootUser
{{ else }}
awsS3AccessKeyId
{{ end }}
{{ end }}

{{ if or .Values.global.s3.secretAccessKey .Values.minio.enabled .Values.global.existingSecret }}
- name: LAGO_AWS_S3_SECRET_ACCESS_KEY
valueFrom:
secretKeyRef:
name: {{ if .Values.minio.enabled }}
{{ .Release.Name }}-minio
{{ else }}
{{ include "secret-path" . }}
{{ end }}
key: {{ if .Values.minio.enabled }}
rootPassword
{{ else }}
awsS3SecretAccessKey
{{ end }}
{{ end }}


- name: LAGO_AWS_S3_BUCKET
value: {{ if .Values.minio.enabled }}
{{ (index .Values.minio.buckets 0).name | quote }}
{{ else }}
{{ .Values.global.s3.bucket | quote }}
{{ end }}
- name: LAGO_AWS_S3_REGION
value: {{ if .Values.global.s3.enabled }}
{{ .Values.global.s3.region | quote }}
{{ else if .Values.minio.enabled }}
{{ default "us-east-1" .Values.minio.region | quote }}
{{ end }}
{{ end }}

{{ if .Values.global.smtp.enabled }}
- name: LAGO_FROM_EMAIL
value: {{ .Values.global.smtp.fromEmail }}
- name: LAGO_SMTP_ADDRESS
value: {{ .Values.global.smtp.address }}
- name: LAGO_SMTP_USERNAME
valueFrom:
secretKeyRef:
name: {{ include "secret-path" . }}
key: smtpUsername
- name: LAGO_SMTP_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "secret-path" . }}
key: smtpPassword
- name: LAGO_SMTP_PORT
value: "{{ .Values.global.smtp.port }}"
{{ end }}
{{ if .Values.global.newRelic.enabled }}
- name: NEW_RELIC_KEY
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-secrets
key: newRelicKey
{{ end }}
image: getlago/api:v{{ .Values.version }}
name: {{ .Release.Name }}-api
ports:
Expand Down
26 changes: 19 additions & 7 deletions templates/clock-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ spec:
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
{{- with .Values.clock.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.clock.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.clock.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
initContainers:
{{ if .Values.redis.enabled }}
- name: wait-for-redis
Expand Down Expand Up @@ -51,12 +63,6 @@ spec:
key: redisUrl
- name: RAILS_LOG_TO_STDOUT
value: {{ .Values.clock.rails.logStdout | quote }}
{{- with .Values.clock.extraEnv }}
{{- range $key, $value := . }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
- name: LAGO_RSA_PRIVATE_KEY
valueFrom:
secretKeyRef:
Expand Down Expand Up @@ -84,6 +90,12 @@ spec:
key: encryptionPrimaryKey
- name: LAGO_LOG_LEVEL
value: {{ .Values.clock.rails.logLevel | quote }}
{{- with .Values.clock.extraEnv }}
{{- range $key, $value := . }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
{{ if .Values.global.newRelic.enabled }}
- name: NEW_RELIC_KEY
valueFrom:
Expand All @@ -95,7 +107,7 @@ spec:
name: {{ .Release.Name }}-clock
{{- with .Values.clock.resources }}
resources:
{{- toYaml . | nindent 12}}
{{- toYaml . | nindent 12 }}
{{- end }}
restartPolicy: Always
serviceAccountName: {{ .Values.global.serviceAccountName | default (printf "%s-serviceaccount" .Release.Name) }}
32 changes: 22 additions & 10 deletions templates/events-worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,18 @@ spec:
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
{{- with .Values.eventsWorker.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.eventsWorker.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.eventsWorker.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
initContainers:
{{ if .Values.redis.enabled }}
- name: wait-for-redis
Expand Down Expand Up @@ -63,12 +75,6 @@ spec:
key: redisUrl
- name: RAILS_LOG_TO_STDOUT
value: {{ .Values.eventsWorker.rails.logStdout | quote }}
{{- with .Values.eventsWorker.extraEnv }}
{{- range $key, $value := . }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
- name: LAGO_RSA_PRIVATE_KEY
valueFrom:
secretKeyRef:
Expand All @@ -95,11 +101,17 @@ spec:
name: {{ .Release.Name }}-secrets
key: encryptionPrimaryKey
- name: DATABASE_POOL
value: {{ .Values.worker.rails.sidekiqConcurrency | quote }}
value: {{ .Values.eventsWorker.rails.sidekiqConcurrency | quote }}
- name: SIDEKIQ_CONCURRENCY
value: {{ .Values.worker.rails.sidekiqConcurrency | quote }}
value: {{ .Values.eventsWorker.rails.sidekiqConcurrency | quote }}
- name: LAGO_LOG_LEVEL
value: {{ .Values.worker.rails.logLevel | quote }}
value: {{ .Values.eventsWorker.rails.logLevel | quote }}
{{- with .Values.eventsWorker.extraEnv }}
{{- range $key, $value := . }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- end }}
{{ if .Values.global.newRelic.enabled }}
- name: NEW_RELIC_KEY
valueFrom:
Expand All @@ -111,7 +123,7 @@ spec:
name: {{ .Release.Name }}-events-worker
{{- with .Values.eventsWorker.resources }}
resources:
{{- toYaml . | nindent 12}}
{{- toYaml . | nindent 12 }}
{{- end }}
livenessProbe:
exec:
Expand Down
14 changes: 13 additions & 1 deletion templates/front-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ metadata:
io.lago.service: {{ .Release.Name }}-front
name: {{ .Release.Name }}-front
spec:
replicas: 1
replicas: {{ .Values.front.replicas }}
selector:
matchLabels:
io.lago.service: {{ .Release.Name }}-front
Expand All @@ -21,6 +21,18 @@ spec:
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
{{- with .Values.front.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.front.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.front.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
containers:
- env:
- name: API_URL
Expand Down
Loading

0 comments on commit f60f759

Please sign in to comment.