Skip to content

Commit bfeb8a8

Browse files
collab, intel: align read-only handling with live legacy chart
Fixes: #174 - Gate all tmp/runtime mounts behind securityContext.readOnlyRootFileSystem - When RO=true, mount emptyDir to /run, /tmp, /var/log/nginx, /var/cache/nginx - Remove readOnlyMode flag and prepare-ro initContainer
1 parent fd6aec4 commit bfeb8a8

4 files changed

Lines changed: 30 additions & 40 deletions

File tree

charts/collab/templates/deployment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,6 +254,7 @@ spec:
254254
emptyDir: {}
255255
- name: codetogether-tmp
256256
emptyDir: {}
257+
medium: Memory
257258
{{- else if .Values.favicon.enabled }}
258259
volumes:
259260
- name: favicon-volume

charts/collab/values.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,13 @@ serviceAccount:
211211

212212
podAnnotations: {}
213213

214-
securityContext: {} #defaults to
214+
securityContext: {} #defaults
215215
# capabilities:
216216
# drop:
217217
# - ALL
218218
# runAsNonRoot: true
219219
# readOnlyRootFilesystem: true # enable for read-only setup
220-
# runAsUser: 0 # Use '0' for root user for read-only setup
220+
# runAsUser: 1000
221221

222222
readinessProbe:
223223
initialDelaySeconds: 60

charts/intel/templates/deployment.yaml

Lines changed: 24 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -26,17 +26,6 @@ spec:
2626
imagePullSecrets:
2727
- name: {{ include "codetogether.fullname" . }}-pull-secret
2828
{{- end }}
29-
{{- if .Values.readOnlyMode.enabled }}
30-
initContainers:
31-
- name: prepare-ro
32-
image: busybox:latest
33-
securityContext:
34-
runAsUser: 0
35-
command: ["sh", "-lc", "mkdir -p /mnt/volatile/var-log-nginx /mnt/volatile/var-cache-nginx /mnt/var/log-codetogether || true"]
36-
volumeMounts:
37-
- name: volatile
38-
mountPath: /mnt/volatile
39-
{{- end }}
4029
serviceAccountName: {{ include "codetogether.serviceAccountName" . }}
4130
containers:
4231
- name: {{ .Chart.Name }}
@@ -110,6 +99,7 @@ spec:
11099
key: apiKey
111100
{{- end }}
112101
{{- end }}
102+
{{- if .Values.securityContext.readOnlyRootFilesystem }}
113103
volumeMounts:
114104
- name: properties-volume
115105
mountPath: /opt/codetogether/runtime/cthq.properties
@@ -119,20 +109,26 @@ spec:
119109
mountPath: /etc/ssl/certs/java/cacerts
120110
subPath: cacerts
121111
{{- end }}
122-
{{- if .Values.readOnlyMode.enabled }}
123-
- name: volatile
124-
mountPath: /run/volatile
125-
- name: run
126-
mountPath: /run
127-
- name: tmp
128-
mountPath: /tmp
129-
- name: volatile
130-
mountPath: /var/log/nginx
131-
subPath: var-log-nginx
132-
- name: volatile
133-
mountPath: /var/cache/nginx
134-
subPath: var-cache-nginx
112+
# Read-only root FS mounts
113+
- mountPath: /run
114+
name: codetogether-runtime
115+
- mountPath: /tmp
116+
name: codetogether-tmp
117+
- mountPath: /var/log/nginx
118+
name: codetogether-runtime
119+
- mountPath: /var/cache/nginx
120+
name: codetogether-runtime
121+
{{- else }}
122+
volumeMounts:
123+
- name: properties-volume
124+
mountPath: /opt/codetogether/runtime/cthq.properties
125+
subPath: cthq.properties
126+
{{- if .Values.java.customCacerts.enabled }}
127+
- name: java-cacerts
128+
mountPath: /etc/ssl/certs/java/cacerts
129+
subPath: cacerts
135130
{{- end }}
131+
{{- end }}
136132
ports:
137133
- name: http
138134
containerPort: 1080
@@ -181,16 +177,13 @@ spec:
181177
secret:
182178
secretName: {{ .Values.java.customCacerts.cacertsSecretName }}
183179
{{- end }}
184-
{{- if .Values.readOnlyMode.enabled }}
185-
- name: volatile
180+
{{- if .Values.securityContext.readOnlyRootFilesystem }}
181+
- name: codetogether-runtime
186182
emptyDir: {}
187-
- name: run
183+
- name: codetogether-tmp
188184
emptyDir:
189185
medium: Memory
190-
- name: tmp
191-
emptyDir:
192-
medium: Memory
193-
{{- end }}
186+
{{- end }}
194187
{{- with .Values.nodeSelector }}
195188
nodeSelector:
196189
{{- toYaml . | nindent 8 }}

charts/intel/values.yaml

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -138,9 +138,8 @@ securityContext: {} #defaults to
138138
# drop:
139139
# - ALL
140140
#readOnlyRootFilesystem: true # enable for read-only setup
141-
#runAsUser: 0 # Use '0' for root user for read-only setup
142-
# runAsNonRoot: true
143-
# runAsUser: 1000
141+
# runAsNonRoot: true # false for non-root user
142+
# runAsUser: 0
144143

145144
ai:
146145
enabled: false
@@ -180,7 +179,4 @@ tolerations: []
180179

181180
affinity: {}
182181

183-
replicaCount: 1
184-
185-
readOnlyMode:
186-
enabled: false # Set to 'true' to enable read-only mode
182+
replicaCount: 1

0 commit comments

Comments
 (0)