Skip to content

Commit

Permalink
feat(worker): Add webhook worker (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
jdenquin authored Dec 26, 2024
1 parent fa196bf commit 7bbd500
Show file tree
Hide file tree
Showing 7 changed files with 179 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Chart.yaml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
apiVersion: v2
appVersion: '1.17.2'
appVersion: '1.17.4'
description: the Lago open source billing app
name: lago
version: 1.17.2
version: 1.17.4
dependencies:
- name: postgresql
version: '13.2.2'
Expand Down
2 changes: 2 additions & 0 deletions templates/api-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -142,6 +142,8 @@ spec:
value: {{ .Values.api.rails.webConcurrency | quote }}
- name: LAGO_LOG_LEVEL
value: {{ .Values.api.rails.logLevel | quote }}
- name: SIDEKIQ_WEBHOOK
value: {{ .Values.webhookWorker.enabled | quote }}
{{- with .Values.api.extraEnv }}
{{- range $key, $value := . }}
- name: {{ $key }}
Expand Down
2 changes: 2 additions & 0 deletions templates/clock-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ spec:
key: encryptionPrimaryKey
- name: LAGO_LOG_LEVEL
value: {{ .Values.clock.rails.logLevel | quote }}
- name: SIDEKIQ_WEBHOOK
value: {{ .Values.webhookWorker.enabled | quote }}
{{- with .Values.clock.extraEnv }}
{{- range $key, $value := . }}
- name: {{ $key }}
Expand Down
2 changes: 2 additions & 0 deletions templates/events-worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -106,6 +106,8 @@ spec:
value: {{ .Values.eventsWorker.rails.sidekiqConcurrency | quote }}
- name: LAGO_LOG_LEVEL
value: {{ .Values.eventsWorker.rails.logLevel | quote }}
- name: SIDEKIQ_WEBHOOK
value: {{ .Values.webhookWorker.enabled | quote }}
{{- with .Values.eventsWorker.extraEnv }}
{{- range $key, $value := . }}
- name: {{ $key }}
Expand Down
140 changes: 140 additions & 0 deletions templates/webhook-worker-deployment.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,140 @@
{{- if .Values.webhookWorker.enabled -}}
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
io.lago.service: {{ .Release.Name }}-webhook-worker
name: {{ .Release.Name }}-webhook-worker
spec:
replicas: {{ .Values.webhookWorker.replicas }}
selector:
matchLabels:
io.lago.service: {{ .Release.Name }}-webhook-worker
strategy:
type: Recreate
template:
metadata:
labels:
io.lago.service: {{ .Release.Name }}-webhook-worker
{{- range $key, $value := .Values.webhookWorker.podLabels }}
{{ $key }}: {{ $value | quote }}
{{- end }}
annotations:
{{- range $key, $value := .Values.webhookWorker.podAnnotations }}
{{ $key }}: {{ $value | quote }}
{{- end }}
spec:
{{- with .Values.webhookWorker.tolerations }}
tolerations:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.webhookWorker.nodeSelector }}
nodeSelector:
{{- toYaml . | nindent 8 }}
{{- end }}
{{- with .Values.webhookWorker.affinity }}
affinity:
{{- toYaml . | nindent 8 }}
{{- end }}
initContainers:
{{ 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 }}
- name: wait-for-migrations
image: "docker.io/bitnami/kubectl:{{ include "kubectlVersion" . }}"
args:
- wait
- job/{{ include "migrateJobName" . }}
- --for=condition=complete
- --timeout=180s
containers:
- args:
- ./scripts/start.webhook.worker.sh
env:
- name: RAILS_ENV
value: {{ .Values.webhookWorker.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: RAILS_LOG_TO_STDOUT
value: {{ .Values.webhookWorker.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: DATABASE_POOL
value: {{ .Values.webhookWorker.rails.sidekiqConcurrency | quote }}
- name: SIDEKIQ_CONCURRENCY
value: {{ .Values.webhookWorker.rails.sidekiqConcurrency | quote }}
- name: SIDEKIQ_WEBHOOK
value: "true"
- name: LAGO_LOG_LEVEL
value: {{ .Values.webhookWorker.rails.logLevel | quote }}
{{- with .Values.webhookWorker.extraEnv }}
{{- range $key, $value := . }}
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- 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 }}-webhook-worker
{{- with .Values.webhookWorker.resources }}
resources:
{{- toYaml . | nindent 12 }}
{{- end }}
livenessProbe:
exec:
command: ["/bin/bash", "-l", "-c", "bundle exec sidekiqmon processes | grep $(hostname) || exit 1"]
initialDelaySeconds: {{ .Values.webhookWorker.livenessProbe.initialDelaySeconds | default 0 }}
periodSeconds: {{ .Values.webhookWorker.livenessProbe.periodSeconds | default 10 }}
timeoutSeconds: {{ .Values.webhookWorker.livenessProbe.timeoutSeconds | default 1 }}
failureThreshold: {{ .Values.webhookWorker.livenessProbe.failureThreshold | default 3 }}
restartPolicy: Always
serviceAccountName: {{ .Values.global.serviceAccountName | default (printf "%s-serviceaccount" .Release.Name) }}
{{- end -}}
2 changes: 2 additions & 0 deletions templates/worker-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -115,6 +115,8 @@ spec:
value: {{ .Values.worker.rails.sidekiqConcurrency | quote }}
- name: LAGO_LOG_LEVEL
value: {{ .Values.worker.rails.logLevel | quote }}
- name: SIDEKIQ_WEBHOOK
value: {{ .Values.webhookWorker.enabled | quote }}
{{- with .Values.worker.extraEnv }}
{{- range $key, $value := . }}
- name: {{ $key }}
Expand Down
39 changes: 29 additions & 10 deletions values.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
version: 1.17.2
version: 1.17.4

# Required: Set the URLs for your API and Frontend services
# Replace these placeholders with the actual domain names.
Expand Down Expand Up @@ -110,7 +110,6 @@ front:
nodeSelector: {}
affinity: {}


api:
replicas: 1
service:
Expand All @@ -137,18 +136,17 @@ api:
nodeSelector: {}
affinity: {}


worker:
replicas: 1
rails:
sidekiqConcurrency: 100
sidekiqConcurrency: 20
env: 'production'
logStdout: true
logLevel: error
resources:
requests:
memory: 1Gi
cpu: '1000m'
cpu: '1100m'
podAnnotations: {}
podLabels: {}
extraEnv: {}
Expand All @@ -161,18 +159,18 @@ worker:
nodeSelector: {}
affinity: {}


eventsWorker:
enabled: true
replicas: 1
rails:
sidekiqConcurrency: 100
sidekiqConcurrency: 20
env: 'production'
logStdout: true
logLevel: error
resources:
requests:
memory: 1Gi
cpu: '1000m'
cpu: '1100m'
podAnnotations: {}
podLabels: {}
extraEnv: {}
Expand All @@ -185,7 +183,6 @@ eventsWorker:
nodeSelector: {}
affinity: {}


clock:
replicas: 1
rails:
Expand All @@ -203,7 +200,6 @@ clock:
nodeSelector: {}
affinity: {}


pdf:
replicas: 1
service:
Expand All @@ -219,6 +215,29 @@ pdf:
nodeSelector: {}
affinity: {}

webhookWorker:
enabled: true
replicas: 1
rails:
sidekiqConcurrency: 20
env: 'production'
logStdout: true
logLevel: info
resources:
requests:
memory: 1Gi
cpu: '1100m'
podAnnotations: {}
podLabels: {}
extraEnv: {}
livenessProbe:
initialDelaySeconds: 0
periodSeconds: 10
timeoutSeconds: 1
failureThreshold: 3
tolerations: []
nodeSelector: {}
affinity: {}

job:
migrate:
Expand Down

0 comments on commit 7bbd500

Please sign in to comment.