Skip to content

Commit

Permalink
Helm: allow for using existing secret for RabbitMQ (#761)
Browse files Browse the repository at this point in the history
* init rabbitmq existing secret

Signed-off-by: David van der Spek <vanderspek.david@gmail.com>

* bump chart

Signed-off-by: David van der Spek <vanderspek.david@gmail.com>

Signed-off-by: David van der Spek <vanderspek.david@gmail.com>
  • Loading branch information
davidspek authored Nov 3, 2022
1 parent 1eddc0d commit c010688
Show file tree
Hide file tree
Showing 5 changed files with 33 additions and 4 deletions.
2 changes: 1 addition & 1 deletion helm/oncall/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ type: application
# This is the chart version. This version number should be incremented each time you make changes
# to the chart and its templates, including the app version.
# Versions are expected to follow Semantic Versioning (https://semver.org/)
version: 1.0.7
version: 1.0.8

# This is the version number of the application being deployed. This version number should be
# incremented each time you make changes to the application. Versions are not expected to
Expand Down
5 changes: 5 additions & 0 deletions helm/oncall/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,11 @@ externalRabbitmq:
port:
user:
password:
protocol:
vhost:
existingSecret: ""
passwordKey: password
usernameKey: username
```
### Connect external Redis
Expand Down
20 changes: 19 additions & 1 deletion helm/oncall/templates/_env.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -237,13 +237,21 @@

{{- define "snippet.rabbitmq.env" -}}
{{- if eq .Values.broker.type "rabbitmq" -}}
{{- if and (not .Values.rabbitmq.enabled) (not .Values.externalRabbitmq.existingSecret) (not .Values.externalRabbitmq.usernameKey) .Values.externalRabbitmq.user }}
- name: RABBITMQ_USERNAME
value: {{ include "snippet.rabbitmq.user" . }}
{{- else if and (not .Values.rabbitmq.enabled) .Values.externalRabbitmq.existingSecret .Values.externalRabbitmq.usernameKey (not .Values.externalRabbitmq.user) }}
- name: RABBITMQ_USERNAME
valueFrom:
secretKeyRef:
name: {{ include "snippet.rabbitmq.password.secret.name" . }}
key: {{ .Values.externalRabbitmq.usernameKey }}
{{- end }}
- name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "snippet.rabbitmq.password.secret.name" . }}
key: rabbitmq-password
key: {{ include "snippet.rabbitmq.password.secret.key" . }}
- name: RABBITMQ_HOST
value: {{ include "snippet.rabbitmq.host" . }}
- name: RABBITMQ_PORT
Expand Down Expand Up @@ -298,11 +306,21 @@
{{- define "snippet.rabbitmq.password.secret.name" -}}
{{- if and (not .Values.rabbitmq.enabled) .Values.externalRabbitmq.password -}}
{{ include "oncall.fullname" . }}-rabbitmq-external
{{- else if and (not .Values.rabbitmq.enabled) .Values.externalRabbitmq.existingSecret -}}
{{ .Values.externalRabbitmq.existingSecret }}
{{- else -}}
{{ include "oncall.rabbitmq.fullname" . }}
{{- end -}}
{{- end -}}

{{- define "snippet.rabbitmq.password.secret.key" -}}
{{- if and (not .Values.rabbitmq.enabled) .Values.externalRabbitmq.passwordKey -}}
{{ .Values.externalRabbitmq.passwordKey }}
{{- else -}}
rabbitmq-password
{{- end -}}
{{- end -}}

{{- define "snippet.redis.host" -}}
{{- if and (not .Values.redis.enabled) .Values.externalRedis.host -}}
{{- required "externalRedis.host is required if not redis.enabled" .Values.externalRedis.host | quote }}
Expand Down
4 changes: 2 additions & 2 deletions helm/oncall/templates/secrets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -21,14 +21,14 @@ data:
mariadb-root-password: {{ required "externalMysql.password is required if not mariadb.enabled" .Values.externalMysql.password | b64enc | quote }}
{{- end }}
---
{{ if and (eq .Values.broker.type "rabbitmq") (not .Values.rabbitmq.enabled) -}}
{{ if and (eq .Values.broker.type "rabbitmq") (not .Values.rabbitmq.enabled) (not .Values.externalRabbitmq.existingSecret) -}}
apiVersion: v1
kind: Secret
metadata:
name: {{ include "oncall.fullname" . }}-rabbitmq-external
type: Opaque
data:
rabbitmq-password: {{ required "externalRabbitmq.password is required if not rabbitmq.enabled" .Values.externalRabbitmq.password | b64enc | quote }}
rabbitmq-password: {{ required "externalRabbitmq.password is required if not rabbitmq.enabled and not externalRabbitmq.existingSecret" .Values.externalRabbitmq.password | b64enc | quote }}
{{- end }}
---
{{ if not .Values.redis.enabled -}}
Expand Down
6 changes: 6 additions & 0 deletions helm/oncall/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -239,6 +239,12 @@ externalRabbitmq:
password:
protocol:
vhost:
# use an existing secret for the rabbitmq password
existingSecret: ""
# the key in the secret containing the rabbitmq password
passwordKey: password
# the key in the secret containing the rabbitmq username
usernameKey: username

# Redis is included into this release for the convenience.
# It is recommended to host it separately from this release
Expand Down

0 comments on commit c010688

Please sign in to comment.