Skip to content

Commit dc6854c

Browse files
177 collab intel rofs on open shift avoid run as user 0 support fs group (#178)
* OpenShit Teting Commit * Intel Changes * Fixes * Fixes * Fix * feat(charts): OpenShift compatibility + read-only rootfs support for collab & intel Fixes: #177 This change makes the codetogether-collab and codetogether-intel charts work out-of-the-box on both vanilla Kubernetes and OpenShift (restricted-v2 SCC), and adds first-class support for readOnlyRootFilesystem via init containers. Key changes ----------- Collab - Add initContainer `prepare-volatile` to create writable runtime paths when readOnlyRootFilesystem=true (e.g., /run, /var/log/nginx, /var/cache/nginx, and the existing /run/volatile/* tree). - Conditionally handle OpenShift vs vanilla: - OpenShift: do NOT set runAsUser/runAsGroup/fsGroup; let SCC assign UIDs. Keep runAsNonRoot and disallow privilege escalation. Avoid chown. Use `install -d -m 0775/2775` for group-write with sticky set as needed. - Vanilla: init runs as root (UID 0) to chown created dirs to the non-root runtime user (defaults to 1000:1000); main container runs non-root. - When readOnlyRootFilesystem=true: - Mount EmptyDir volumes to /run, /tmp (Memory), /var/log/nginx, /var/cache/nginx. - Add matching volumeMounts. - Keep probes and ports unchanged. - Values: add/clarify `openshift.enabled` flag, securityContext defaults, imageCredentials usage, and sample values for both environments. Intel - Add initContainer `prepare-runtime` to create /var/log/nginx and /var/cache/nginx and make them writable under read-only rootfs. - Same OpenShift vs vanilla split as collab (no explicit UID/GID on OCP; root init + non-root app for vanilla). - Mount EmptyDir + volumeMounts for /run, /tmp (Memory), /var/log/nginx, /var/cache/nginx when readOnlyRootFilesystem=true. - Preserve existing envs (AI mode, HQ base URL, Java options, etc.). Why --- - Fixes SCC denials on OpenShift when explicit runAsUser/fsGroup were set. - Fixes initContainer permission errors (e.g., "Operation not permitted" on /run) by avoiding chown on OpenShift and using 2775 with umask 002. - Enables secure read-only rootfs operation by provisioning necessary writable paths via EmptyDir. Testing ------- - OpenShift 4.x: - `openshift.enabled=true`, remove fsGroup=0, do not set runAsUser/runAsGroup. - initContainers succeed; pods transition to Running. - Vanilla (DigitalOcean Kubernetes): - `openshift.enabled=false`, readOnlyRootFilesystem=true. - init runs as root, chowns to 1000:1000; app runs as non-root. - Pods healthy; readiness/liveness OK. Breaking changes ---------------- - None functionally; however, when enabling readOnlyRootFilesystem, the chart now requires the EmptyDir mounts (added by default when the flag is true). * Testing * fix(openshift): make Intel/Collab charts run on OpenShift; verified in-cluster Fixes: #177 - Validated (same OpenShift env) - This change fixes the customer’s OpenShift issue.
1 parent 75aa28f commit dc6854c

6 files changed

Lines changed: 11 additions & 43 deletions

File tree

charts/collab/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: codetogether-collab
33
description: CodeTogether Collab
44

55
type: application
6-
version: 1.2.4
6+
version: 1.2.5
77
appVersion: "2025.1.0"
88

99
icon: https://www.codetogether.com/wp-content/uploads/2020/02/codetogether-circle-128.png

charts/collab/templates/deployment.yaml

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,6 @@ spec:
194194
name: codetogether-runtime
195195
- mountPath: /tmp
196196
name: codetogether-tmp
197-
- mountPath: /var/log/nginx
198-
name: codetogether-runtime
199-
- mountPath: /var/cache/nginx
200-
name: codetogether-runtime
201197
{{- if .Values.favicon.enabled }}
202198
- mountPath: /opt/volatile-template/nginx/favicon.ico
203199
name: favicon-volume
@@ -248,13 +244,13 @@ spec:
248244

249245
resources:
250246
{{- toYaml .Values.resources | nindent 12 }}
247+
251248
{{- if .Values.securityContext.readOnlyRootFilesystem}}
252249
volumes:
253250
- name: codetogether-runtime
254251
emptyDir: {}
255252
- name: codetogether-tmp
256-
emptyDir:
257-
medium: Memory
253+
emptyDir: {}
258254
{{- else if .Values.favicon.enabled }}
259255
volumes:
260256
- name: favicon-volume

charts/collab/values.yaml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,8 @@ securityContext: {} #defaults
217217
# - ALL
218218
# readOnlyRootFilesystem: true # enable for read-only setup
219219
# runAsNonRoot: true
220-
# runAsUser: 0 # Use '0' for root user for read-only setup
220+
# runAsUser: 1000 # Use '0' for root user, in vanilla k8s you can use any non-root uid
221+
# In openshift, dont set runAsUser, let OpenShift assign the values
221222

222223
readinessProbe:
223224
initialDelaySeconds: 60

charts/intel/Chart.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: codetogether-intel
33
description: CodeTogether Intel provides advanced project insights for developers
44

55
type: application
6-
version: 1.2.7
6+
version: 1.2.8
77
appVersion: "2025.3.0"
88

99
icon: https://www.codetogether.com/wp-content/uploads/2020/02/codetogether-circle-128.png

charts/intel/templates/deployment.yaml

Lines changed: 0 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,6 @@ spec:
9999
key: apiKey
100100
{{- end }}
101101
{{- end }}
102-
{{- if .Values.securityContext.readOnlyRootFilesystem }}
103102
volumeMounts:
104103
- name: properties-volume
105104
mountPath: /opt/codetogether/runtime/cthq.properties
@@ -109,26 +108,6 @@ spec:
109108
mountPath: /etc/ssl/certs/java/cacerts
110109
subPath: cacerts
111110
{{- end }}
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
130-
{{- end }}
131-
{{- end }}
132111
ports:
133112
- name: http
134113
containerPort: 1080
@@ -177,14 +156,6 @@ spec:
177156
secret:
178157
secretName: {{ .Values.java.customCacerts.cacertsSecretName }}
179158
{{- end }}
180-
{{- if .Values.securityContext.readOnlyRootFilesystem }}
181-
- name: codetogether-runtime
182-
emptyDir: {}
183-
- name: codetogether-tmp
184-
emptyDir:
185-
medium: Memory
186-
{{- end }}
187-
188159
{{- with .Values.nodeSelector }}
189160
nodeSelector:
190161
{{- toYaml . | nindent 8 }}

charts/intel/values.yaml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -132,14 +132,14 @@ serviceAccount:
132132

133133
podAnnotations: {}
134134

135-
securityContext: {} #defaults to
136-
135+
securityContext: {} #defaults
137136
# capabilities:
138137
# drop:
139138
# - ALL
140-
#readOnlyRootFilesystem: true # enable for read-only setup
141-
# runAsNonRoot: true # false for non-root user
142-
# runAsUser: 0 # Use '0' for root user for read-only setup
139+
# readOnlyRootFilesystem: true # enable for read-only setup
140+
# runAsNonRoot: true
141+
# runAsUser: 1000 # Use '0' for root user
142+
# In openshift, dont set runAsUser, let OpenShift assign the values
143143

144144
ai:
145145
enabled: false

0 commit comments

Comments
 (0)