diff --git a/charts/open-notificaties/Chart.lock b/charts/open-notificaties/Chart.lock deleted file mode 100644 index e29e189..0000000 --- a/charts/open-notificaties/Chart.lock +++ /dev/null @@ -1,12 +0,0 @@ -dependencies: -- name: postgresql - repository: https://charts.bitnami.com/bitnami - version: 10.2.0 -- name: redis - repository: https://charts.bitnami.com/bitnami - version: 12.2.3 -- name: rabbitmq - repository: https://charts.bitnami.com/bitnami - version: 8.6.0 -digest: sha256:631d9cae1a713ca18c60d165e5b049451418fa67cac2ff6e038cb1c5110d4624 -generated: "2020-12-20T15:00:36.966697+01:00" diff --git a/charts/open-notificaties/Chart.yaml b/charts/open-notificaties/Chart.yaml index 02894ca..9bd9dc4 100644 --- a/charts/open-notificaties/Chart.yaml +++ b/charts/open-notificaties/Chart.yaml @@ -3,7 +3,7 @@ name: open-notificaties description: API voor het routeren van notificaties type: application -version: 0.2.1 +version: 0.3.0 appVersion: 1.1.0 dependencies: diff --git a/charts/open-notificaties/templates/_helpers.tpl b/charts/open-notificaties/templates/_helpers.tpl index 68c31c5..2d1f7e5 100644 --- a/charts/open-notificaties/templates/_helpers.tpl +++ b/charts/open-notificaties/templates/_helpers.tpl @@ -33,15 +33,22 @@ Create chart name and version as used by the chart label. {{/* Common labels */}} -{{- define "open-notificaties.labels" -}} +{{- define "open-notificaties.commonLabels" -}} helm.sh/chart: {{ include "open-notificaties.chart" . }} -{{ include "open-notificaties.selectorLabels" . }} {{- if .Chart.AppVersion }} app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} {{- end }} app.kubernetes.io/managed-by: {{ .Release.Service }} {{- end }} +{{/* +Labels +*/}} +{{- define "open-notificaties.labels" -}} +{{ include "open-notificaties.commonLabels" . }} +{{ include "open-notificaties.selectorLabels" . }} +{{- end }} + {{/* Selector labels */}} @@ -60,3 +67,35 @@ Create the name of the service account to use {{- default "default" .Values.serviceAccount.name }} {{- end }} {{- end }} + +{{/* +Create a name for the worker +We truncate at 56 chars in order to provide space for the "-worker" suffix +*/}} +{{- define "open-notificaties.workerName" -}} +{{ include "open-notificaties.name" . | trunc 56 | trimSuffix "-" }}-worker +{{- end }} + +{{/* +Create a default fully qualified name for the worker. +We truncate at 56 chars in order to provide space for the "-worker" suffix +*/}} +{{- define "open-notificaties.workerFullname" -}} +{{ include "open-notificaties.fullname" . | trunc 56 | trimSuffix "-" }}-worker +{{- end }} + +{{/* +Worker labels +*/}} +{{- define "open-notificaties.workerLabels" -}} +{{ include "open-notificaties.commonLabels" . }} +{{ include "open-notificaties.workerSelectorLabels" . }} +{{- end }} + +{{/* +Worker selector labels +*/}} +{{- define "open-notificaties.workerSelectorLabels" -}} +app.kubernetes.io/name: {{ include "open-notificaties.workerName" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} diff --git a/charts/open-notificaties/templates/configmap.yaml b/charts/open-notificaties/templates/configmap.yaml index e34ae24..5cb3d35 100644 --- a/charts/open-notificaties/templates/configmap.yaml +++ b/charts/open-notificaties/templates/configmap.yaml @@ -20,4 +20,5 @@ data: {{- if .Values.settings.email.useTLS }} EMAIL_USE_TLS: "True" {{- end }} - IS_HTTPS: {{ if .Values.settings.isHttps }}"True"{{ else }}"False"{{ end }} \ No newline at end of file + IS_HTTPS: {{ if .Values.settings.isHttps }}"True"{{ else }}"False"{{ end }} + RABBITMQ_HOST: {{ .Values.settings.messageBroker.host }} \ No newline at end of file diff --git a/charts/open-notificaties/templates/deployment.yaml b/charts/open-notificaties/templates/deployment.yaml index ab669eb..a1d869d 100644 --- a/charts/open-notificaties/templates/deployment.yaml +++ b/charts/open-notificaties/templates/deployment.yaml @@ -85,3 +85,63 @@ spec: tolerations: {{- toYaml . | nindent 8 }} {{- end }} +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "open-notificaties.workerFullname" . }} + labels: + {{- include "open-notificaties.workerLabels" . | nindent 4 }} +spec: + {{- if not .Values.worker.autoscaling.enabled }} + replicas: {{ .Values.worker.replicaCount }} + {{- end }} + selector: + matchLabels: + {{- include "open-notificaties.workerSelectorLabels" . | nindent 6 }} + template: + metadata: + annotations: + checksum/configmap: {{ include (print $.Template.BasePath "/configmap.yaml") . | sha256sum }} + checksum/secret: {{ include (print $.Template.BasePath "/secret.yaml") . | sha256sum }} + {{- with .Values.podAnnotations }} + {{- toYaml . | nindent 8 }} + {{- end }} + labels: + {{- include "open-notificaties.workerSelectorLabels" . | nindent 8 }} + spec: + {{- with .Values.imagePullSecrets }} + imagePullSecrets: + {{- toYaml . | nindent 8 }} + {{- end }} + serviceAccountName: {{ include "open-notificaties.serviceAccountName" . }} + securityContext: + {{- toYaml .Values.podSecurityContext | nindent 8 }} + containers: + - name: {{ .Chart.Name }}-worker + securityContext: + {{- toYaml .Values.securityContext | nindent 12 }} + image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}" + imagePullPolicy: {{ .Values.image.pullPolicy }} + envFrom: + - secretRef: + name: {{ include "open-notificaties.fullname" . }} + - configMapRef: + name: {{ include "open-notificaties.fullname" . }} + resources: + {{- toYaml .Values.workerResources | nindent 12 }} + command: + - /celery_worker.sh + {{- with .Values.nodeSelector }} + nodeSelector: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.affinity }} + affinity: + {{- toYaml . | nindent 8 }} + {{- end }} + {{- with .Values.tolerations }} + tolerations: + {{- toYaml . | nindent 8 }} + {{- end }} + diff --git a/charts/open-notificaties/templates/hpa.yaml b/charts/open-notificaties/templates/hpa.yaml index 6d56af1..044a370 100644 --- a/charts/open-notificaties/templates/hpa.yaml +++ b/charts/open-notificaties/templates/hpa.yaml @@ -26,3 +26,32 @@ spec: targetAverageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }} {{- end }} {{- end }} +--- +{{- if .Values.worker.autoscaling.enabled }} +apiVersion: autoscaling/v2beta1 +kind: HorizontalPodAutoscaler +metadata: + name: {{ include "open-notificaties.workerFullname" . }} + labels: + {{- include "open-notificaties.workerLabels" . | nindent 4 }} +spec: + scaleTargetRef: + apiVersion: apps/v1 + kind: Deployment + name: {{ include "open-notificaties.workerFullname" . }} + minReplicas: {{ .Values.worker.autoscaling.minReplicas }} + maxReplicas: {{ .Values.worker.autoscaling.maxReplicas }} + metrics: + {{- if .Values.worker.autoscaling.targetCPUUtilizationPercentage }} + - type: Resource + resource: + name: cpu + targetAverageUtilization: {{ .Values.worker.autoscaling.targetCPUUtilizationPercentage }} + {{- end }} + {{- if .Values.worker.autoscaling.targetMemoryUtilizationPercentage }} + - type: Resource + resource: + name: memory + targetAverageUtilization: {{ .Values.worker.autoscaling.targetMemoryUtilizationPercentage }} + {{- end }} +{{- end }} diff --git a/charts/open-notificaties/templates/secret.yaml b/charts/open-notificaties/templates/secret.yaml index 0b35835..f16dec0 100644 --- a/charts/open-notificaties/templates/secret.yaml +++ b/charts/open-notificaties/templates/secret.yaml @@ -6,13 +6,14 @@ metadata: {{- include "open-notificaties.labels" . | nindent 4 }} type: Opaque data: - CELERY_BROKER_URL: {{ .Values.settings.celeryBrokerUrl | toString | b64enc | quote }} - CELERY_RESULT_BACKEND: {{ .Values.settings.celeryResultBackend | toString | b64enc | quote }} + {{ $rabbitmq_url := printf "amqp://%s:%s@%s:5672" .Values.rabbitmq.auth.username .Values.rabbitmq.auth.password .Values.settings.messageBroker.host -}} + CELERY_BROKER_URL: {{ print $rabbitmq_url "//" | b64enc | quote }} + CELERY_RESULT_BACKEND: {{ print $rabbitmq_url "//" | b64enc | quote }} DB_PASSWORD: {{ .Values.settings.database.password | toString | b64enc | quote }} {{- if .Values.settings.email.password }} EMAIL_PASSWORD: {{ .Values.settings.email.password | toString | b64enc | quote }} {{- end }} - PUBLISHER_BROKER_URL: {{ .Values.settings.publisherBrokerUrl | toString | b64enc | quote }} + PUBLISHER_BROKER_URL: {{ print $rabbitmq_url "/%2F" | b64enc | quote }} SECRET_KEY: {{ .Values.settings.secretKey | toString | b64enc | quote }} {{- if .Values.settings.sentry.dsn }} SENTRY_DSN: {{ .Values.settings.sentry.dsn | toString | b64enc | quote }} diff --git a/charts/open-notificaties/values.yaml b/charts/open-notificaties/values.yaml index 6d7c01e..4c7b32a 100644 --- a/charts/open-notificaties/values.yaml +++ b/charts/open-notificaties/values.yaml @@ -92,6 +92,16 @@ persistence: size: 1Gi existingClaim: null +worker: + replicaCount: 1 + resources: {} + autoscaling: + enabled: false + minReplicas: 1 + maxReplicas: 100 + targetCPUUtilizationPercentage: 80 + # targetMemoryUtilizationPercentage: 80 + settings: allowedHosts: open-notificaties.gemeente.nl @@ -118,9 +128,8 @@ settings: sentry: dsn: "" - publisherBrokerUrl: amqp://guest:guest@open-notificaties-rabbitmq:5672/%2F - celeryBrokerUrl: amqp://guest:guest@open-notificaties-rabbitmq:5672// - celeryResultBackend: amqp://guest:guest@open-notificaties-rabbitmq:5672// + messageBroker: + host: open-notificaties-rabbitmq isHttps: true diff --git a/charts/open-zaak/Chart.lock b/charts/open-zaak/Chart.lock deleted file mode 100644 index f443524..0000000 --- a/charts/open-zaak/Chart.lock +++ /dev/null @@ -1,9 +0,0 @@ -dependencies: -- name: postgresql - repository: https://charts.bitnami.com/bitnami - version: 10.2.0 -- name: redis - repository: https://charts.bitnami.com/bitnami - version: 12.2.2 -digest: sha256:16a08ffd3a03cb2410415d090889ea07584977d3f19eef94d2df7daa35317f8b -generated: "2020-12-15T13:23:50.038387+01:00"