Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use existing betydb password secret #10

Open
wants to merge 5 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
103 changes: 93 additions & 10 deletions templates/_helpers.tpl
Original file line number Diff line number Diff line change
Expand Up @@ -58,19 +58,107 @@ Cluster environment
{{- end }}
{{- end -}}

{{/*
Get the rabbitmq secret.
*/}}
{{- define "pecan.rabbitmq.secretName" -}}
{{- if .Values.rabbitmq.existingPasswordSecret -}}
{{- printf "%s" (tpl .Values.rabbitmq.existingPasswordSecret $) -}}
{{- else -}}
{{ .Release.Name }}-rabbitmq
{{- end -}}
{{- end -}}

{{/*
Get the rabbitmq secret key.
*/}}
{{- define "pecan.rabbitmq.rabbitmqPasswordSecretKey" -}}
{{- if .Values.rabbitmq.existingPasswordSecret }}
{{- if .Values.rabbitmq.secretKeys.rabbitmqPasswordSecretKey }}
{{- printf "%s" (tpl .Values.rabbitmq.secretKeys.rabbitmqPasswordSecretKey $) -}}
{{- else -}}
{{- "rabbitmq-password" }}
{{- end -}}
{{- else -}}
{{- "rabbitmq-password" }}
{{- end -}}
{{- end -}}

{{/*
Get the erlang secret.
*/}}
{{- define "pecam.rabbitmq.secretErlangName" -}}
{{- if .Values.rabbitmq.existingErlangSecret -}}
{{- printf "%s" .Values.rabbitmq.existingErlangSecret -}}
{{- else -}}
{{ .Release.Name }}-rabbitmq
{{- end -}}
{{- end -}}

{{/*
Get the rabbitmq erlangCookie Secret key.
*/}}
{{- define "pecan.rabbitmq.erlangCookieSecretKey" -}}
{{- if .Values.rabbitmq.existingErlangSecret }}
{{- if .Values.rabbitmq.secretKeys.erlangCookieSecretKey }}
{{- printf "%s" (tpl .Values.rabbitmq.secretKeys.erlangCookieSecretKey $) -}}
{{- else -}}
{{- "rabbitmq-erlang-cookie" }}
{{- end -}}
{{- else -}}
{{- "rabbitmq-erlang-cookie" }}
{{- end -}}
{{- end -}}

{{/*
RabbitMQ URI environment
*/}}
{{- define "pecan.env.rabbitmq" -}}
- name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-rabbitmq
key: rabbitmq-password
- name: RABBITMQ_URI
value: "amqp://{{ .Values.rabbitmq.rabbitmq.username }}:$(RABBITMQ_PASSWORD)@{{ .Release.Name }}-rabbitmq/%2F"
{{- end -}}

{{/*
Get the betydb secret.
*/}}
{{- define "pecan.betydb.secretName" -}}
{{- if .Values.betydb.auth.existingSecret -}}
{{- printf "%s" (tpl .Values.betydb.auth.existingSecret $) -}}
{{- else -}}
{{ .Release.Name }}-betydb
{{- end -}}
{{- end -}}

{{/*
Get the betyPassword key.
*/}}
{{- define "pecan.betydb.betydbPasswordKey" -}}
{{- if .Values.betydb.auth.existingSecret }}
{{- if .Values.betydb.auth.secretKeys.betydbPasswordKey }}
{{- printf "%s" (tpl .Values.betydb.auth.secretKeys.betydbPasswordKey $) -}}
{{- else -}}
{{- "betyPassword" }}
{{- end -}}
{{- else -}}
{{- "betyPassword" }}
{{- end -}}
{{- end -}}

{{/*
Get the betydb encryption secret key.
*/}}
{{- define "pecan.betydb.betydbEncryptionSecretKey" -}}
{{- if .Values.betydb.auth.existingSecret }}
{{- if .Values.betydb.auth.secretKeys.betydbEncryptionKey }}
{{- printf "%s" (tpl .Values.betydb.auth.secretKeys.betydbEncryptionKey $) -}}
{{- else -}}
{{- "secretKey" }}
{{- end -}}
{{- else -}}
{{- "secretKey" }}
{{- end -}}
{{- end -}}

{{/*
Postgresql Environment for postgres
*/}}
Expand All @@ -92,11 +180,6 @@ Postgresql Environment for postgres
key: postgresql-password
- name: BETYUSER
value: {{ .Values.betydb.betyUser | quote }}
- name: BETYPASSWORD
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-betydb
key: betyPassword
- name: BETYDATABASE
value: {{ .Values.betydb.betyDatabase | quote }}
{{- end -}}
Expand Down
10 changes: 10 additions & 0 deletions templates/add-data.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,11 @@ spec:
value: {{ .Values.betydb.betyDatabase | quote }}
- name: PG_TABLE
value: "yields"
- name: BETYPASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.betydb.secretName" . }}
key: {{ include "pecan.betydb.betydbPasswordKey" . }}
containers:
- name: add-data
image: "{{ .Values.image.project }}/data:{{ .Values.image.tag | default .Chart.AppVersion }}"
Expand All @@ -41,6 +46,11 @@ spec:
{{- include "pecan.env.cluster" . | nindent 12 }}
- name: PSQL
value: "psql -d {{ .Values.betydb.betyDatabase }} -q -t -c"
- name: BETYPASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.betydb.secretName" . }}
key: {{ include "pecan.betydb.betydbPasswordKey" . }}
volumes:
- name: data
persistentVolumeClaim:
Expand Down
24 changes: 22 additions & 2 deletions templates/executor/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- include "pecan.env.rabbitmq" . | nindent 12 }}
- name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.rabbitmq.secretName" . }}
key: {{ include "pecan.rabbitmq.rabbitmqPasswordSecretKey" . }}
- name: check-postgresql
image: "{{ $.Values.image.checks }}"
imagePullPolicy: {{ $.Values.image.pullPolicy }}
Expand All @@ -35,6 +40,11 @@ spec:
value: {{ .Values.betydb.betyDatabase | quote }}
- name: PG_TABLE
value: "yields"
- name: BETYPASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.betydb.secretName" . }}
key: {{ include "pecan.betydb.betydbPasswordKey" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.project }}/executor:{{ .Values.image.tag | default .Chart.AppVersion }}"
Expand All @@ -46,11 +56,21 @@ spec:
{{- include "pecan.env.rabbitmq" . | nindent 12 }}
{{- include "pecan.env.postgresql" . | nindent 12 }}
{{- include "pecan.env.cluster" . | nindent 12 }}
- name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.rabbitmq.secretName" . }}
key: {{ include "pecan.rabbitmq.rabbitmqPasswordSecretKey" . }}
- name: SECRET_KEY_BASE
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-betydb
key: secretKey
name: {{ include "pecan.betydb.secretName" . }}
key: {{ include "pecan.betydb.betydbEncryptionSecretKey" . }}
- name: BETYPASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.betydb.secretName" . }}
key: {{ include "pecan.betydb.betydbPasswordKey" . }}
resources:
{{- toYaml .Values.executor.resources | nindent 12 }}
volumes:
Expand Down
5 changes: 5 additions & 0 deletions templates/models/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,11 @@ spec:
mountPath: /data
env:
{{ $rabbitmqEnv | nindent 12 }}
- name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.rabbitmq.secretName" . }}
key: {{ include "pecan.rabbitmq.rabbitmqPasswordSecretKey" . }}
{{- if .env }}
{{- toYaml .env | nindent 12 }}
{{- end }}
Expand Down
20 changes: 20 additions & 0 deletions templates/monitor/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- include "pecan.env.rabbitmq" . | nindent 12 }}
- name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.rabbitmq.secretName" . }}
key: {{ include "pecan.rabbitmq.rabbitmqPasswordSecretKey" . }}
- name: check-postgresql
image: "{{ $.Values.image.checks }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
Expand All @@ -35,6 +40,11 @@ spec:
value: {{ .Values.betydb.betyDatabase | quote }}
- name: PG_TABLE
value: "yields"
- name: BETYPASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.betydb.secretName" . }}
key: {{ include "pecan.betydb.betydbPasswordKey" . }}
containers:
- name: {{ .Chart.Name }}
image: "{{ .Values.image.project }}/monitor:{{ .Values.image.tag | default .Chart.AppVersion }}"
Expand All @@ -45,6 +55,16 @@ spec:
{{- include "pecan.env.cluster" . | nindent 12 }}
- name: RABBITMQ_MGMT_PATH
value: {{ .Values.rabbitmq.ingress.path | default "/" | quote }}
- name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.rabbitmq.secretName" . }}
key: {{ include "pecan.rabbitmq.rabbitmqPasswordSecretKey" . }}
- name: BETYPASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.betydb.secretName" . }}
key: {{ include "pecan.betydb.betydbPasswordKey" . }}
ports:
- name: pecan-monitor
containerPort: 9999
Expand Down
20 changes: 20 additions & 0 deletions templates/rstudio/statefulset.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,11 @@ spec:
imagePullPolicy: {{ $.Values.image.pullPolicy }}
env:
{{- $rabbitmq | nindent 12 }}
- name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.rabbitmq.secretName" . }}
key: {{ include "pecan.rabbitmq.rabbitmqPasswordSecretKey" . }}
- name: check-postgresql
image: "{{ $.Values.image.checks }}"
imagePullPolicy: {{ $.Values.image.pullPolicy }}
Expand All @@ -45,6 +50,11 @@ spec:
value: {{ $betydb }}
- name: PG_TABLE
value: "yields"
- name: BETYPASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.betydb.secretName" . }}
key: {{ include "pecan.betydb.betydbPasswordKey" . }}
containers:
- name: rstudio
image: "{{ $.Values.image.project }}/base:{{ $.Values.image.tag | default $.Chart.AppVersion }}"
Expand All @@ -57,12 +67,22 @@ spec:
{{- $env | nindent 12 }}
- name: RABBITMQ_MGMT_PATH
value: {{ $.Values.rabbitmq.ingress.path | default "/" | quote }}
- name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.rabbitmq.secretName" . }}
key: {{ include "pecan.rabbitmq.rabbitmqPasswordSecretKey" . }}
- name: USER
value: {{ .username }}
- name: PASSWORD
value: {{ .password | quote }}
- name: KEEP_ENV
value: "RABBITMQ_URI RABBITMQ_PREFIX RABBITMQ_PORT FQDN NAME"
- name: BETYPASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.betydb.secretName" . }}
key: {{ include "pecan.betydb.betydbPasswordKey" . }}
ports:
- name: rstudio
containerPort: 8787
Expand Down
24 changes: 22 additions & 2 deletions templates/web/deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,11 @@ spec:
imagePullPolicy: {{ .Values.image.pullPolicy }}
env:
{{- include "pecan.env.rabbitmq" . | nindent 12 }}
- name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.rabbitmq.secretName" . }}
key: {{ include "pecan.rabbitmq.rabbitmqPasswordSecretKey" . }}
- name: check-postgresql
image: "{{ $.Values.image.checks }}"
imagePullPolicy: {{ $.Values.image.pullPolicy }}
Expand All @@ -35,6 +40,11 @@ spec:
value: {{ .Values.betydb.betyDatabase | quote }}
- name: PG_TABLE
value: "yields"
- name: BETYPASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.betydb.secretName" . }}
key: {{ include "pecan.betydb.betydbPasswordKey" . }}
- name: check-betydb
image: "{{ $.Values.image.checks }}"
imagePullPolicy: {{ .Values.image.pullPolicy }}
Expand All @@ -55,11 +65,21 @@ spec:
{{- include "pecan.env.rabbitmq" . | nindent 12 }}
{{- include "pecan.env.postgresql" . | nindent 12 }}
{{- include "pecan.env.cluster" . | nindent 12 }}
- name: RABBITMQ_PASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.rabbitmq.secretName" . }}
key: {{ include "pecan.rabbitmq.rabbitmqPasswordSecretKey" . }}
- name: SECRET_KEY_BASE
valueFrom:
secretKeyRef:
name: {{ .Release.Name }}-betydb
key: secretKey
name: {{ include "pecan.betydb.secretName" . }}
key: {{ include "pecan.betydb.betydbEncryptionSecretKey" . }}
- name: BETYPASSWORD
valueFrom:
secretKeyRef:
name: {{ include "pecan.betydb.secretName" . }}
key: {{ include "pecan.betydb.betydbPasswordKey" . }}
livenessProbe:
tcpSocket:
port: pecan-web
Expand Down
12 changes: 12 additions & 0 deletions values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,13 @@ betydb:
## path prefix for all applications (betydb is set below)
path: /bety/

## Use existing bety password as secret
## Create secret pecan-betydb-old with key betyPassword
auth:
existingSecret: ""
secretKeys:
betydbPasswordKey: ""
betydbEncryptionKey: ""
## -------------------------------------------------------------------------------
## RABBITMQ APPLICATION
## -------------------------------------------------------------------------------
Expand All @@ -105,6 +112,11 @@ rabbitmq:
enabled: false
hostName: rabbitmq.localhost
path: /
existingErlangSecret: ""
existingPasswordSecret: ""
secretKeys:
erlangCookieSecretKey: ""
rabbitmqPasswordSecretKey: ""

## -------------------------------------------------------------------------------
## INGRESS RULES
Expand Down