Skip to content

Commit af1e5e6

Browse files
authored
NX-13810 Added new env, envFrom, secrets & configMaps option for api-… (#5)
* NX-13810 Added new env, envFrom, secrets & configMaps option for api-deployment * 🎨 * 🎨
1 parent badf40e commit af1e5e6

File tree

4 files changed

+117
-15
lines changed

4 files changed

+117
-15
lines changed

charts/api-deployment/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ type: application
1515
# This is the chart version. This version number should be incremented each time you make changes
1616
# to the chart and its templates, including the app version.
1717
# Versions are expected to follow Semantic Versioning (https://semver.org/)
18-
version: 0.3.1
18+
version: 0.4.0
1919

2020
# This is the version number of the application being deployed. This version number should be
2121
# incremented each time you make changes to the application. Versions are not expected to

charts/api-deployment/templates/deployment.yaml

Lines changed: 28 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -42,12 +42,13 @@ spec:
4242
- {{ . | quote }}
4343
{{- end }}
4444
{{- end }}
45+
{{- with .Values.env }}
4546
env:
46-
- name: GOOGLE_APPLICATION_CREDENTIALS
47-
value: /var/run/secret/cloud.google.com/service-account.json
48-
{{- if ne .Values.gcp.projectID "" }}
49-
- name: GOOGLE_CLOUD_PROJECT
50-
value: {{ .Values.gcp.projectID | quote }}
47+
{{- toYaml . | nindent 14 }}
48+
{{- end }}
49+
{{- with .Values.envFrom }}
50+
envFrom:
51+
{{- toYaml . | nindent 14 }}
5152
{{- end }}
5253
ports:
5354
- name: http
@@ -73,11 +74,18 @@ spec:
7374
mountPath: /etc/nx
7475
readOnly: true
7576
{{- end }}
76-
- name: gcp-service-account
77-
mountPath: /var/run/secret/cloud.google.com
78-
readOnly: true
7977
- name: files
8078
mountPath: /mnt/files
79+
{{- range .Values.secrets }}
80+
- name: {{ .name | quote }}
81+
mountPath: {{ .mountPath | quote }}
82+
readOnly: {{ .readOnly | default true }} # Enforce read-only by default to enhance security
83+
{{- end }}
84+
{{- range .Values.configMaps }}
85+
- name: {{ .name | quote }}
86+
mountPath: {{ .mountPath | quote }}
87+
readOnly: {{ .readOnly | default true }} # Enforce read-only by default to enhance security
88+
{{- end }}
8189
{{- with .Values.nodeSelector }}
8290
nodeSelector:
8391
{{- toYaml . | nindent 8 }}
@@ -96,13 +104,22 @@ spec:
96104
configMap:
97105
name: {{ include "api-deployment.fullname" $ }}
98106
{{- end }}
99-
- name: gcp-service-account
100-
secret:
101-
secretName: {{ .Values.gcp.serviceAccount }}
102107
- name: files
103108
{{- with .Values.volume.data.volumeClaim }}
104109
persistentVolumeClaim:
105110
claimName: {{ . }}
106111
{{- else }}
107112
emptyDir: {}
108113
{{- end }}
114+
{{- range .Values.secrets }}
115+
- name: {{ .name | quote }}
116+
secret:
117+
secretName: {{ .secretName | quote }}
118+
optional: {{ .optional | default false }} # Ensure configmap is present by default
119+
{{- end }}
120+
{{- range .Values.configMaps }}
121+
- name: {{ .name | quote }}
122+
configMap:
123+
name: {{ .configMapName | quote }}
124+
optional: {{ .optional | default false }} # Ensure configmap is present by default
125+
{{- end }}
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# Example values.yaml configuration for certificate loading
2+
3+
# Load certificate from a secret and reference it via environment variable
4+
secrets:
5+
- name: tls-cert
6+
secretName: my-tls-certificate
7+
mountPath: /etc/ssl/certs
8+
readOnly: true
9+
10+
env:
11+
# Static environment variables
12+
- name: CERT_PATH
13+
value: "/etc/ssl/certs/tls.crt"
14+
- name: KEY_PATH
15+
value: "/etc/ssl/certs/tls.key"
16+
- name: SSL_VERIFY
17+
value: "true"
18+
19+
# Load environment variable from a secret
20+
- name: DATABASE_PASSWORD
21+
valueFrom:
22+
secretKeyRef:
23+
name: database-secret
24+
key: password
25+
optional: false
26+
27+
# Load environment variable from a configmap
28+
- name: API_BASE_URL
29+
valueFrom:
30+
configMapKeyRef:
31+
name: app-config
32+
key: api-url
33+
optional: false
34+
35+
envFrom:
36+
# Load all environment variables from a secret
37+
- secretRef:
38+
name: app-secrets
39+
optional: false
40+
41+
# Load all environment variables from a configmap
42+
- configMapRef:
43+
name: app-config
44+
optional: false
45+
46+
# Mount additional configmaps
47+
configMaps:
48+
- name: app-config-files
49+
configMapName: application-config
50+
mountPath: /etc/app-config
51+
readOnly: true

charts/api-deployment/values.yaml

Lines changed: 37 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -97,9 +97,43 @@ args: []
9797

9898
config: {}
9999

100-
gcp:
101-
serviceAccount: ""
102-
projectID: ""
100+
env: []
101+
# - name: MY_STATIC_VAR
102+
# value: "my_value"
103+
# - name: MY_CONFIG_VAR
104+
# valueFrom:
105+
# configMapKeyRef:
106+
# name: my-configmap
107+
# key: config-key
108+
# optional: false
109+
# - name: MY_SECRET_VAR
110+
# valueFrom:
111+
# secretKeyRef:
112+
# name: my-secret
113+
# key: secret-key
114+
# optional: false
115+
116+
envFrom: []
117+
# - configMapRef:
118+
# name: my-configmap
119+
# optional: false
120+
# - secretRef:
121+
# name: my-secret
122+
# optional: false
123+
124+
secrets: []
125+
# - name: cert-secret
126+
# secretName: my-certificate-secret
127+
# mountPath: /etc/certs
128+
# readOnly: true
129+
# optional: false
130+
131+
configMaps: []
132+
# - name: app-config
133+
# configMapName: my-app-config
134+
# mountPath: /etc/config
135+
# readOnly: true
136+
# optional: false
103137

104138
volume:
105139
data:

0 commit comments

Comments
 (0)