Skip to content

Commit

Permalink
Fixes #3. Move some items back from secret to configMap. Make worker …
Browse files Browse the repository at this point in the history
…pod scalable.
  • Loading branch information
andyverberne committed Apr 14, 2021
1 parent a3f7ca1 commit a5d69d2
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 6 deletions.
4 changes: 0 additions & 4 deletions charts/open-notificaties/templates/configmap.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,9 +8,6 @@ data:
ALLOWED_HOSTS: "{{ include "open-notificaties.fullname" . }},{{ .Values.settings.allowedHosts | toString }}"
CACHE_AXES: {{ .Values.settings.cache.axes | toString | quote }}
CACHE_DEFAULT: {{ .Values.settings.cache.default | toString | quote }}
{{ $rabbitmq_connection := printf "amqp://%s:%s@%s:5672" .Values.rabbitmq.auth.username .Values.rabbitmq.auth.password .Values.settings.messageBroker.host -}}
CELERY_BROKER_URL: {{ print $rabbitmq_connection "//" | quote }}
CELERY_RESULT_BACKEND: {{ print $rabbitmq_connection "//" | quote }}
DB_NAME: {{ .Values.settings.database.name | toString | quote }}
DB_HOST: {{ .Values.settings.database.host | toString | quote }}
DB_PORT: {{ .Values.settings.database.port | toString | quote }}
Expand All @@ -24,5 +21,4 @@ data:
EMAIL_USE_TLS: "True"
{{- end }}
IS_HTTPS: {{ if .Values.settings.isHttps }}"True"{{ else }}"False"{{ end }}
PUBLISHER_BROKER_URL: {{ print $rabbitmq_connection "/%2F" | quote }}
RABBITMQ_HOST: {{ .Values.settings.messageBroker.host }}
4 changes: 3 additions & 1 deletion charts/open-notificaties/templates/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,9 @@ metadata:
labels:
{{- include "open-notificaties.workerLabels" . | nindent 4 }}
spec:
replicas: 1
{{- if not .Values.worker.autoscaling.enabled }}
replicas: {{ .Values.worker.replicaCount }}
{{- end }}
selector:
matchLabels:
{{- include "open-notificaties.workerSelectorLabels" . | nindent 6 }}
Expand Down
29 changes: 29 additions & 0 deletions charts/open-notificaties/templates/hpa.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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 }}
4 changes: 4 additions & 0 deletions charts/open-notificaties/templates/secret.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,14 @@ metadata:
{{- include "open-notificaties.labels" . | nindent 4 }}
type: Opaque
data:
{{ $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: {{ 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 }}
Expand Down
11 changes: 10 additions & 1 deletion charts/open-notificaties/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ ingress:
# - chart-example.local

resources: {}
workerResources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
# choice for the user. This also increases chances charts run on environments with little
# resources, such as Minikube. If you do want to specify resources, uncomment the following
Expand Down Expand Up @@ -93,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

Expand Down

0 comments on commit a5d69d2

Please sign in to comment.