Skip to content

Commit f394db4

Browse files
Sara QasmiSara Qasmi
authored andcommitted
feat: Add support for running UI deployment in restrictive environments
Signed-off-by: Sara Qasmi <saraqasmi@Saras-MacBook-Pro.local>
1 parent 9e32d36 commit f394db4

4 files changed

Lines changed: 75 additions & 23 deletions

File tree

helm/kagent/templates/ui-deployment.yaml

Lines changed: 21 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,16 @@ spec:
3030
initContainers:
3131
{{- tpl (toYaml .) $ | nindent 8 }}
3232
{{- end }}
33+
volumes:
34+
- emptyDir: {}
35+
name: tmp
36+
- emptyDir: {}
37+
name: lib-nginx
38+
- emptyDir: {}
39+
name: run-nginx
40+
{{- with .Values.ui.volumes }}
41+
{{- toYaml . | nindent 8 }}
42+
{{- end }}
3343
containers:
3444
- name: ui
3545
securityContext:
@@ -58,4 +68,14 @@ spec:
5868
httpGet:
5969
path: /health
6070
port: http
61-
periodSeconds: 30
71+
periodSeconds: 30
72+
volumeMounts:
73+
- mountPath: /tmp
74+
name: tmp
75+
- mountPath: /var/lib/nginx
76+
name: lib-nginx
77+
- mountPath: /run/nginx
78+
name: run-nginx
79+
{{- with .Values.ui.volumeMounts }}
80+
{{- toYaml . | nindent 12 }}
81+
{{- end }}

helm/kagent/tests/ui-deployment_test.yaml

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -81,14 +81,7 @@ tests:
8181
initContainers:
8282
- name: init-nginx
8383
image: busybox
84-
command:
85-
- sh
86-
- -c
87-
- |
88-
mkdir -p /var/lib/nginx/tmp/client_body
89-
volumeMounts:
90-
- name: nginx-writable
91-
mountPath: /var/lib/nginx
84+
command: []
9285
asserts:
9386
- equal:
9487
path: spec.template.spec.initContainers[0].name
@@ -97,5 +90,26 @@ tests:
9790
path: spec.template.spec.initContainers[0].image
9891
value: busybox
9992
- equal:
100-
path: spec.template.spec.initContainers[0].volumeMounts[0].mountPath
101-
value: /var/lib/nginx
93+
path: spec.template.spec.initContainers[0].command
94+
value: []
95+
96+
- it: should include extra volumes and volumeMounts
97+
set:
98+
ui:
99+
volumeMounts:
100+
- mountPath: /tmp
101+
name: tmp
102+
volumes:
103+
- name: tmp
104+
emptyDir: {}
105+
asserts:
106+
- contains:
107+
path: spec.template.spec.containers[0].volumeMounts
108+
content:
109+
mountPath: /tmp
110+
name: tmp
111+
- contains:
112+
path: spec.template.spec.volumes
113+
content:
114+
name: tmp
115+
emptyDir: {}

helm/kagent/values.yaml

Lines changed: 26 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -117,15 +117,32 @@ ui:
117117
initContainers: []
118118
# - name: init-nginx
119119
# image: busybox
120-
# command:
121-
# - sh
122-
# - -c
123-
# - |
124-
# mkdir -p /var/lib/nginx/tmp/client_body
125-
# volumeMounts:
126-
# - name: nginx-writable
127-
# mountPath: /var/lib/nginx
128-
120+
# command: []
121+
122+
# -- Additional volumeMounts to the UI container
123+
volumeMounts: []
124+
# - mountPath: /tmp
125+
# name: tmp
126+
127+
# -- Additional volumes to the UI pod
128+
volumes: []
129+
# - name: tmp
130+
# emptyDir: {}
131+
132+
securityContext:
133+
allowPrivilegeEscalation: false
134+
capabilities:
135+
drop: ["ALL"]
136+
readOnlyRootFilesystem: false
137+
seccompProfile:
138+
type: RuntimeDefault
139+
140+
podSecurityContext:
141+
runAsUser: 1001
142+
runAsGroup: 1001
143+
runAsNonRoot: true
144+
fsGroup: 1001
145+
129146
# ==============================================================================
130147
# LLM PROVIDERS CONFIGURATION
131148
# ==============================================================================

ui/Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -76,14 +76,15 @@ RUN mkdir -p $BUN_INSTALL \
7676
&& curl -fsSL https://bun.sh/install | bash -s "bun-v$TOOLS_BUN_VERSION" \
7777
&& bun --version
7878

79-
RUN mkdir -p /app/ui/public /run/nginx/ /var/lib/nginx/tmp/ /var/lib/nginx/logs/ \
79+
RUN mkdir -p /app/ui/public /run/nginx/ /var/lib/nginx/tmp/ /var/lib/nginx/tmp/client_body /var/lib/nginx/logs/ \
8080
&& addgroup -g 1001 nginx \
8181
&& adduser -u 1001 -G nginx -s /bin/bash -D nextjs \
8282
&& adduser -u 1002 -G nginx -s /bin/bash -D nginx \
8383
&& chown -vR nextjs:nginx /app/ui \
8484
&& chown -vR nextjs:nginx /run/nginx \
85-
&& chown -vR nextjs:nginx /var/lib/nginx/
86-
85+
&& chown -vR nextjs:nginx /var/lib/nginx/ \
86+
&& touch /var/lib/nginx/logs/error.log
87+
8788
WORKDIR /app
8889
COPY conf/nginx.conf /etc/nginx/nginx.conf
8990
COPY conf/supervisord.conf /etc/supervisor/conf.d/supervisord.conf

0 commit comments

Comments
 (0)