Skip to content

Commit 8db73b5

Browse files
Merge pull request #156 from nrwl/steve/chore/enable-custom-volumes-and-mounts
chore(nx-cloud): ensure custom volumes and mounts can be used
2 parents 39bafb1 + df19fd0 commit 8db73b5

7 files changed

Lines changed: 234 additions & 77 deletions

File tree

charts/nx-cloud/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ apiVersion: v2
22
name: nx-cloud
33
description: Nx Cloud Helm Chart
44
type: application
5-
version: 0.15.15
5+
version: 0.15.16
66
maintainers:
77
- name: nx
88
url: "https://nx.app/"
Lines changed: 135 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,135 @@
1+
global:
2+
imageTag: '2405.02.15'
3+
4+
nxCloudAppURL: 'URL_TO_ACCESS_INGRESS_FROM_DEV_MACHINES'
5+
6+
secret:
7+
name: 'cloudsecret'
8+
nxCloudMongoServerEndpoint: 'NX_CLOUD_MONGO_SERVER_ENDPOINT'
9+
adminPassword: 'ADMIN_PASSWORD'
10+
11+
# Test for volume helpers
12+
# This test file adds custom volumes and volumeMounts to each component
13+
# to verify that the volume helper functions work correctly
14+
# Also tests resource class configuration to ensure helpers work correctly
15+
# when multiple volume sources are combined
16+
17+
# Resource class configuration for testing
18+
resourceClassConfiguration:
19+
name: "resource-class-config"
20+
path: "agentConfigs.yaml"
21+
22+
frontend:
23+
serviceAccountName: 'nx-cloud-sa'
24+
deployment:
25+
volumes:
26+
- name: test-volume
27+
emptyDir: {}
28+
volumeMounts:
29+
- name: test-volume
30+
mountPath: /test-mount
31+
env:
32+
- name: TEST_VARIABLE
33+
value: 'test'
34+
service:
35+
annotations:
36+
my.special-annotation: "annotated"
37+
resources:
38+
requests:
39+
memory: '0.5Mi'
40+
cpu: '0.1'
41+
42+
nxApi:
43+
serviceAccountName: 'nx-cloud-sa'
44+
deployment:
45+
volumes:
46+
- name: test-volume
47+
emptyDir: {}
48+
volumeMounts:
49+
- name: test-volume
50+
mountPath: /test-mount
51+
env:
52+
- name: TEST_VARIABLE
53+
value: 'test'
54+
service:
55+
annotations:
56+
my.special-annotation: "annotated"
57+
resources:
58+
requests:
59+
memory: '0.5Mi'
60+
cpu: '0.1'
61+
62+
aggregator:
63+
serviceAccountName: 'nx-cloud-sa'
64+
schedule: "*/10 * * * *"
65+
volumes:
66+
- name: test-volume
67+
emptyDir: {}
68+
volumeMounts:
69+
- name: test-volume
70+
mountPath: /test-mount
71+
env:
72+
- name: TEST_VARIABLE
73+
value: 'test'
74+
resources:
75+
requests:
76+
memory: '0.5Mi'
77+
cpu: '0.1'
78+
79+
# Reduced resource requirements for test environment
80+
fileServer:
81+
serviceAccountName: 'nx-cloud-sa'
82+
deployment:
83+
env:
84+
- name: TEST_VARIABLE
85+
value: 'test'
86+
port: 5000
87+
service:
88+
port: 5000
89+
annotations:
90+
my.special-annotation: "annotated"
91+
resources:
92+
requests:
93+
memory: '0.5Mi'
94+
cpu: '0.1'
95+
96+
messagequeue:
97+
serviceAccountName: 'nx-cloud-sa'
98+
deployment:
99+
port: 61616
100+
service:
101+
port: 61616
102+
103+
extraManifests:
104+
# Required service account
105+
serviceAccount:
106+
apiVersion: v1
107+
kind: ServiceAccount
108+
metadata:
109+
name: nx-cloud-sa
110+
namespace: default
111+
112+
# Required secret
113+
secret:
114+
apiVersion: v1
115+
kind: Secret
116+
metadata:
117+
name: cloudsecret
118+
namespace: default
119+
type: Opaque
120+
stringData:
121+
NX_CLOUD_MONGO_SERVER_ENDPOINT: "mongodb://127.0.0.1"
122+
ADMIN_PASSWORD: "SOME_ADMIN_PASSWORD"
123+
124+
# Resource class configmap for testing
125+
resourceClassConfig:
126+
apiVersion: v1
127+
kind: ConfigMap
128+
metadata:
129+
name: resource-class-config
130+
namespace: default
131+
data:
132+
agentConfigs.yaml: |
133+
resourceClasses:
134+
- identifier: test-resource-class
135+
architecture: amd64

charts/nx-cloud/templates/_helpers.tpl

Lines changed: 86 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -116,4 +116,89 @@ Below are various little env snippets that multiple mainifests make use of
116116
value: '4203'
117117
- name: NX_API_INTERNAL_BASE_URL
118118
value: http://nx-cloud-nx-api-service
119-
{{- end }}
119+
{{- end }}
120+
121+
{{/*
122+
Volume Mounts Helper - combines standard mounts with custom mounts from values
123+
Usage: {{ include "nxCloud.volumeMounts" (dict "component" .Values.componentName "selfSigned" .Values.selfSignedCertConfigMap "resourceClass" (and .Values.resourceClassConfiguration.name .Values.resourceClassConfiguration.path)) }}
124+
*/}}
125+
{{- define "nxCloud.volumeMounts" -}}
126+
{{- $component := .component -}}
127+
{{- $selfSigned := .selfSigned -}}
128+
{{- $resourceClass := .resourceClass -}}
129+
{{- $hasCustomMounts := false -}}
130+
{{- if $component.deployment -}}
131+
{{- if $component.deployment.volumeMounts -}}
132+
{{- $hasCustomMounts = true -}}
133+
{{- end -}}
134+
{{- else if $component.volumeMounts -}}
135+
{{- $hasCustomMounts = true -}}
136+
{{- end -}}
137+
138+
{{- if or $selfSigned $resourceClass $hasCustomMounts }}
139+
volumeMounts:
140+
{{- if $selfSigned }}
141+
- mountPath: /usr/lib/jvm/java-17-amazon-corretto/jre/lib/security
142+
name: cacerts
143+
subPath: security
144+
- mountPath: /self-signed-certs
145+
name: self-signed-certs-volume
146+
{{- end }}
147+
{{- if $resourceClass }}
148+
- mountPath: /opt/nx-cloud/resource-classes
149+
name: resource-class-config-volume
150+
{{- end }}
151+
{{- if $component.deployment }}
152+
{{- if $component.deployment.volumeMounts }}
153+
{{- toYaml $component.deployment.volumeMounts | nindent 2 }}
154+
{{- end }}
155+
{{- else if $component.volumeMounts }}
156+
{{- toYaml $component.volumeMounts | nindent 2 }}
157+
{{- end }}
158+
{{- end }}
159+
{{- end -}}
160+
161+
{{/*
162+
Volumes Helper - combines standard volumes with custom volumes from values
163+
Usage: {{ include "nxCloud.volumes" (dict "component" .Values.componentName "selfSigned" .Values.selfSignedCertConfigMap "resourceClass" (and .Values.resourceClassConfiguration.name .Values.resourceClassConfiguration.path) "resourceClassConfig" .Values.resourceClassConfiguration) }}
164+
*/}}
165+
{{- define "nxCloud.volumes" -}}
166+
{{- $component := .component -}}
167+
{{- $selfSigned := .selfSigned -}}
168+
{{- $resourceClass := .resourceClass -}}
169+
{{- $resourceClassConfig := .resourceClassConfig -}}
170+
{{- $hasCustomVolumes := false -}}
171+
{{- if $component.deployment -}}
172+
{{- if $component.deployment.volumes -}}
173+
{{- $hasCustomVolumes = true -}}
174+
{{- end -}}
175+
{{- else if $component.volumes -}}
176+
{{- $hasCustomVolumes = true -}}
177+
{{- end -}}
178+
179+
{{- if or $selfSigned $resourceClass $hasCustomVolumes }}
180+
volumes:
181+
{{- if $selfSigned }}
182+
- emptyDir: {}
183+
name: cacerts
184+
- configMap:
185+
name: {{ $selfSigned }}
186+
name: self-signed-certs-volume
187+
{{- end }}
188+
{{- if $resourceClass }}
189+
- configMap:
190+
name: {{ $resourceClassConfig.name }}
191+
items:
192+
- key: {{ $resourceClassConfig.path }}
193+
path: agentConfigs.yaml
194+
name: resource-class-config-volume
195+
{{- end }}
196+
{{- if $component.deployment }}
197+
{{- if $component.deployment.volumes }}
198+
{{- toYaml $component.deployment.volumes | nindent 2 }}
199+
{{- end }}
200+
{{- else if $component.volumes }}
201+
{{- toYaml $component.volumes | nindent 2 }}
202+
{{- end }}
203+
{{- end }}
204+
{{- end -}}

charts/nx-cloud/templates/nx-cloud-aggregator-cron.yaml

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -32,20 +32,7 @@ spec:
3232
securityContext:
3333
{{- toYaml .Values.aggregator.securityContext | nindent 12 }}
3434
{{- end }}
35-
{{- if or .Values.selfSignedCertConfigMap (and .Values.resourceClassConfiguration.name .Values.resourceClassConfiguration.path) }}
36-
volumeMounts:
37-
{{- if .Values.selfSignedCertConfigMap }}
38-
- mountPath: /usr/lib/jvm/java-17-amazon-corretto/jre/lib/security
39-
name: cacerts
40-
subPath: security
41-
- mountPath: /self-signed-certs
42-
name: self-signed-certs-volume
43-
{{- end }}
44-
{{- if and .Values.resourceClassConfiguration.name .Values.resourceClassConfiguration.path }}
45-
- mountPath: /opt/nx-cloud/resource-classes
46-
name: resource-class-config-volume
47-
{{- end }}
48-
{{- end}}
35+
{{ include "nxCloud.volumeMounts" (dict "component" .Values.aggregator "selfSigned" .Values.selfSignedCertConfigMap "resourceClass" (and .Values.resourceClassConfiguration.name .Values.resourceClassConfiguration.path)) | indent 10 }}
4936
env:
5037
{{- include "nxCloud.env.mongoSecrets" . | indent 12 }}
5138
{{- include "nxCloud.env.verboseLogging" . | indent 12 }}
@@ -79,24 +66,7 @@ spec:
7966
- name: NX_CLOUD_USE_MONGO42
8067
value: 'false'
8168
{{- end }}
82-
{{- if or .Values.selfSignedCertConfigMap (and .Values.resourceClassConfiguration.name .Values.resourceClassConfiguration.path) }}
83-
volumes:
84-
{{- if .Values.selfSignedCertConfigMap }}
85-
- emptyDir: { }
86-
name: cacerts
87-
- configMap:
88-
name: {{ .Values.selfSignedCertConfigMap }}
89-
name: self-signed-certs-volume
90-
{{- end }}
91-
{{- if and .Values.resourceClassConfiguration.name .Values.resourceClassConfiguration.path }}
92-
- configMap:
93-
name: {{ .Values.resourceClassConfiguration.name }}
94-
items:
95-
- key: {{ .Values.resourceClassConfiguration.path }}
96-
path: agentConfigs.yaml
97-
name: resource-class-config-volume
98-
{{- end }}
99-
{{- end }}
69+
{{ include "nxCloud.volumes" (dict "component" .Values.aggregator "selfSigned" .Values.selfSignedCertConfigMap "resourceClass" (and .Values.resourceClassConfiguration.name .Values.resourceClassConfiguration.path) "resourceClassConfig" .Values.resourceClassConfiguration) | indent 6 }}
10070
restartPolicy: OnFailure
10171
{{- end }}
10272
---

charts/nx-cloud/templates/nx-cloud-frontend-deployment.yaml

Lines changed: 2 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,7 @@ spec:
5151
securityContext:
5252
{{- toYaml .Values.frontend.securityContext | nindent 12 }}
5353
{{- end }}
54-
{{- if .Values.selfSignedCertConfigMap }}
55-
volumeMounts:
56-
- mountPath: /self-signed-certs
57-
name: self-signed-certs-volume
58-
{{- end}}
54+
{{ include "nxCloud.volumeMounts" (dict "component" .Values.frontend "selfSigned" .Values.selfSignedCertConfigMap) | indent 10 }}
5955
env:
6056
{{- include "nxCloud.env.verboseLogging" . | indent 12 }}
6157
{{- include "nxCloud.env.mode" . | indent 12 }}
@@ -73,9 +69,4 @@ spec:
7369
- name: NODE_EXTRA_CA_CERTS
7470
value: /self-signed-certs/self-signed-cert.crt
7571
{{- end}}
76-
{{- if .Values.selfSignedCertConfigMap }}
77-
volumes:
78-
- configMap:
79-
name: {{ .Values.selfSignedCertConfigMap }}
80-
name: self-signed-certs-volume
81-
{{- end }}
72+
{{ include "nxCloud.volumes" (dict "component" .Values.frontend "selfSigned" .Values.selfSignedCertConfigMap) | indent 6 }}

charts/nx-cloud/templates/nx-cloud-nx-api-deployment.yaml

Lines changed: 2 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -60,20 +60,7 @@ spec:
6060
securityContext:
6161
{{- toYaml .Values.nxApi.securityContext | nindent 12 }}
6262
{{- end }}
63-
{{- if or .Values.selfSignedCertConfigMap (and .Values.resourceClassConfiguration.name .Values.resourceClassConfiguration.path) }}
64-
volumeMounts:
65-
{{- if .Values.selfSignedCertConfigMap }}
66-
- mountPath: /usr/lib/jvm/java-17-amazon-corretto/jre/lib/security
67-
name: cacerts
68-
subPath: security
69-
- mountPath: /self-signed-certs
70-
name: self-signed-certs-volume
71-
{{- end }}
72-
{{- if and .Values.resourceClassConfiguration.name .Values.resourceClassConfiguration.path }}
73-
- mountPath: /opt/nx-cloud/resource-classes
74-
name: resource-class-config-volume
75-
{{- end }}
76-
{{- end}}
63+
{{ include "nxCloud.volumeMounts" (dict "component" .Values.nxApi "selfSigned" .Values.selfSignedCertConfigMap "resourceClass" (and .Values.resourceClassConfiguration.name .Values.resourceClassConfiguration.path)) | indent 10 }}
7764
startupProbe:
7865
httpGet:
7966
path: /nx-cloud/uptime-check
@@ -162,21 +149,4 @@ spec:
162149
- name: NX_CLOUD_USE_MONGO42
163150
value: 'false'
164151
{{- end }}
165-
{{- if or .Values.selfSignedCertConfigMap (and .Values.resourceClassConfiguration.name .Values.resourceClassConfiguration.path) }}
166-
volumes:
167-
{{- if .Values.selfSignedCertConfigMap }}
168-
- emptyDir: { }
169-
name: cacerts
170-
- configMap:
171-
name: {{ .Values.selfSignedCertConfigMap }}
172-
name: self-signed-certs-volume
173-
{{- end }}
174-
{{- if and .Values.resourceClassConfiguration.name .Values.resourceClassConfiguration.path }}
175-
- configMap:
176-
name: {{ .Values.resourceClassConfiguration.name }}
177-
items:
178-
- key: {{ .Values.resourceClassConfiguration.path }}
179-
path: agentConfigs.yaml
180-
name: resource-class-config-volume
181-
{{- end }}
182-
{{- end }}
152+
{{ include "nxCloud.volumes" (dict "component" .Values.nxApi "selfSigned" .Values.selfSignedCertConfigMap "resourceClass" (and .Values.resourceClassConfiguration.name .Values.resourceClassConfiguration.path) "resourceClassConfig" .Values.resourceClassConfiguration) | indent 6 }}

charts/nx-cloud/values.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,8 @@ frontend:
3131
replicas: 1
3232
port: 4202
3333
env: []
34+
volumes: []
35+
volumeMounts: []
3436
service:
3537
name: nx-cloud-frontend-service
3638
type: ClusterIP
@@ -56,6 +58,8 @@ nxApi:
5658
port: 4203
5759
env: []
5860
readinessProbe: {}
61+
volumes: []
62+
volumeMounts: []
5963
service:
6064
name: nx-cloud-nx-api-service
6165
type: ClusterIP
@@ -107,6 +111,8 @@ aggregator:
107111
digest: ''
108112
pullPolicy: Always
109113
env: []
114+
volumes: []
115+
volumeMounts: []
110116
resources:
111117
limits: {}
112118
requests:

0 commit comments

Comments
 (0)