Skip to content

Commit

Permalink
Merge pull request #23 from blockscout/env-from-existing-secrets
Browse files Browse the repository at this point in the history
Env from existing secrets
  • Loading branch information
alik-agaev authored Apr 3, 2024
2 parents d720694 + febcc69 commit 884f7d8
Show file tree
Hide file tree
Showing 7 changed files with 69 additions and 10 deletions.
7 changes: 7 additions & 0 deletions charts/blockscout-stack/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
# ChangeLog

## 1.4.4

### Feature

- Add `extraEnv` and `envFrom` for backend/frontend to refer to an existing Secret/ConfigMap
- Create Secrets for backend/frontend only when data is specified

## 1.4.3

### Fixes
Expand Down
2 changes: 1 addition & 1 deletion charts/blockscout-stack/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,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.4.3
version: 1.4.4

# 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
24 changes: 20 additions & 4 deletions charts/blockscout-stack/templates/blockscout-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,17 @@ spec:
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- range .Values.blockscout.extraEnv }}
- {{ toYaml . | nindent 12 | trim }}
{{- end }}
{{- if or .Values.blockscout.envFromSecret .Values.blockscout.envFrom }}
envFrom:
- secretRef:
name: {{ include "blockscout-stack.fullname" . }}-blockscout-env
- secretRef:
name: {{ include "blockscout-stack.fullname" . }}-blockscout-env
{{- range .Values.blockscout.envFrom }}
- {{ toYaml . | nindent 12 | trim }}
{{- end }}
{{- end }}
{{- end }}
containers:
- name: {{ .Chart.Name }}-blockscout
Expand Down Expand Up @@ -125,9 +133,17 @@ spec:
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- range .Values.blockscout.extraEnv }}
- {{ toYaml . | nindent 12 | trim }}
{{- end }}
{{- if or .Values.blockscout.envFromSecret .Values.blockscout.envFrom }}
envFrom:
- secretRef:
name: {{ include "blockscout-stack.fullname" . }}-blockscout-env
- secretRef:
name: {{ include "blockscout-stack.fullname" . }}-blockscout-env
{{- range .Values.blockscout.envFrom }}
- {{ toYaml . | nindent 12 | trim }}
{{- end }}
{{- end }}
{{- if .Values.blockscout.readinessProbe.enabled }}
readinessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion charts/blockscout-stack/templates/blockscout-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.blockscout.enabled }}
{{- if and .Values.blockscout.enabled .Values.blockscout.envFromSecret }}
apiVersion: v1
kind: Secret
metadata:
Expand Down
12 changes: 10 additions & 2 deletions charts/blockscout-stack/templates/frontend-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -80,9 +80,17 @@ spec:
- name: {{ $key }}
value: {{ $value | quote }}
{{- end }}
{{- range .Values.frontend.extraEnv }}
- {{ toYaml . | nindent 12 | trim }}
{{- end }}
{{- if or .Values.frontend.envFromSecret .Values.frontend.envFrom }}
envFrom:
- secretRef:
name: {{ include "blockscout-stack.fullname" . }}-frontend-env
- secretRef:
name: {{ include "blockscout-stack.fullname" . }}-frontend-env
{{- range .Values.frontend.envFrom }}
- {{ toYaml . | nindent 12 | trim }}
{{- end }}
{{- end }}
{{- if .Values.frontend.readinessProbe.enabled }}
readinessProbe:
httpGet:
Expand Down
2 changes: 1 addition & 1 deletion charts/blockscout-stack/templates/frontend-secret.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{{- if .Values.frontend.enabled }}
{{- if and .Values.frontend.enabled .Values.frontend.envFromSecret }}
apiVersion: v1
kind: Secret
metadata:
Expand Down
30 changes: 29 additions & 1 deletion charts/blockscout-stack/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,10 +60,24 @@ blockscout:
##
env: []
# NAME: VALUE
## Set ENV vars via secret, this can be usefull for DB connection params, api keys, etc.
# Refer to an existing Secret/ConfigMap
extraEnv: []
# - name: DATABASE_URL
# valueFrom:
# secretKeyRef:
# name: blockscout-secret
# key: DATABASE_URL
## Set ENV vars via secret, this can be useful for DB connection params, api keys, etc.
##
# This will create a Secret with the specified data
envFromSecret: []
# NAME: VALUE
# Refer to an existing Secret/ConfigMap
envFrom: []
# - secretRef:
# name: blockscout-secret
# - configMapRef:
# name: blockscout-config
## Command to start blockscout instance
##
command:
Expand Down Expand Up @@ -202,8 +216,22 @@ frontend:
##
env: []
# NAME: VALUE
# Refer to an existing Secret/ConfigMap
extraEnv: []
# - name: FAVICON_GENERATOR_API_KEY
# valueFrom:
# secretKeyRef:
# name: blockscout-frontend-secret
# key: FAVICON_GENERATOR_API_KEY
# This will create a Secret with the specified data
envFromSecret: []
# NAME: VALUE
# Refer to an existing Secret/ConfigMap
envFrom: []
# - secretRef:
# name: blockscout-frontend-secret
# - configMapRef:
# name: blockscout-frontend-config

stats:
enabled: false
Expand Down

0 comments on commit 884f7d8

Please sign in to comment.