Skip to content

Commit 18b6c5a

Browse files
authoredMar 12, 2025··
Add readOnlyRootFileSystem for the common services: (#867)
- data-prep - retriever-usvc Signed-off-by: Lianhao Lu <[email protected]>
1 parent d838340 commit 18b6c5a

File tree

7 files changed

+39
-14
lines changed

7 files changed

+39
-14
lines changed
 

‎helm-charts/common/data-prep/templates/configmap.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -64,3 +64,6 @@ data:
6464
no_proxy: {{ .Values.global.no_proxy | quote }}
6565
{{- end }}
6666
LOGFLAG: {{ .Values.LOGFLAG | quote }}
67+
NUMBA_CACHE_DIR: "/tmp/numba/cache"
68+
XDG_CACHE_HOME: "/tmp/fontconfig/cache"
69+
MPLCONFIGDIR: "/tmp/matplotlib"

‎helm-charts/common/data-prep/templates/deployment.yaml

+12
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,12 @@ spec:
8282
volumeMounts:
8383
- mountPath: /tmp
8484
name: tmp
85+
- mountPath: /home/user/comps/dataprep/src/uploaded_files
86+
name: uploaded-files
87+
- mountPath: /home/user/nltk_data
88+
name: nltk-data
89+
- mountPath: /home/user/.config
90+
name: user-config-data
8591
{{- if .Values.livenessProbe }}
8692
livenessProbe:
8793
{{- toYaml .Values.livenessProbe | nindent 12 }}
@@ -99,6 +105,12 @@ spec:
99105
volumes:
100106
- name: tmp
101107
emptyDir: {}
108+
- name: uploaded-files
109+
emptyDir: {}
110+
- name: nltk-data
111+
emptyDir: {}
112+
- name: user-config-data
113+
emptyDir: {}
102114
{{- with .Values.nodeSelector }}
103115
nodeSelector:
104116
{{- toYaml . | nindent 8 }}

‎helm-charts/common/data-prep/templates/tests/test-pod.yaml

+15-11
Original file line numberDiff line numberDiff line change
@@ -17,18 +17,22 @@ spec:
1717
command: ['bash', '-c']
1818
args:
1919
- |
20-
echo "test file" > /tmp/file1.txt;
21-
max_retry=20;
22-
echo "test upload...";
23-
for ((i=1; i<=max_retry; i++)); do
24-
curl http://{{ include "data-prep.fullname" . }}:{{ .Values.service.port }}/v1/dataprep/ingest -sS --fail-with-body \
25-
-X POST \
26-
-H "Content-Type: multipart/form-data" \
27-
-F "files=@/tmp/file1.txt" && break;
28-
curlcode=$?
29-
if [[ $curlcode -eq 7 ]]; then sleep 10; else echo "curl failed with code $curlcode"; exit 1; fi;
20+
filetypes=(docx pdf txt xlsx pptx doc);
21+
for type in ${filetypes[@]}; do
22+
echo "Get ingest file of type $type ...";
23+
curl -sLJO "https://github.com/opea-project/GenAIComps/raw/refs/heads/main/tests/dataprep/ingest_dataprep.${type}";
24+
max_retry=20;
25+
echo "Test ingest file of type $type ...";
26+
for ((i=1; i<=max_retry; i++)); do
27+
curl http://{{ include "data-prep.fullname" . }}:{{ .Values.service.port }}/v1/dataprep/ingest -sS --fail-with-body \
28+
-X POST -H "Content-Type: multipart/form-data" \
29+
-F "files=@./ingest_dataprep.${type}" && break;
30+
curlcode=$?;
31+
if [[ $curlcode -eq 7 ]]; then sleep 10; else echo "curl failed with code $curlcode"; exit 1; fi;
32+
done;
33+
if [ $i -gt $max_retry ]; then echo "test failed with maximum retry"; exit 1; fi
34+
echo "";
3035
done;
31-
if [ $i -gt $max_retry ]; then echo "test failed with maximum retry"; exit 1; fi
3236
echo "test delete...";
3337
for ((i=1; i<=max_retry; i++)); do
3438
curl http://{{ include "data-prep.fullname" . }}:{{ .Values.service.port }}/v1/dataprep/delete -sS --fail-with-body \

‎helm-charts/common/data-prep/values.yaml

+1-1
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ podSecurityContext: {}
7777
# fsGroup: 2000
7878

7979
securityContext:
80-
readOnlyRootFilesystem: false
80+
readOnlyRootFilesystem: true
8181
allowPrivilegeEscalation: false
8282
runAsNonRoot: true
8383
runAsUser: 1000

‎helm-charts/common/retriever-usvc/templates/configmap.yaml

+3
Original file line numberDiff line numberDiff line change
@@ -63,3 +63,6 @@ data:
6363
HF_HOME: "/tmp/.cache/huggingface"
6464
HUGGINGFACEHUB_API_TOKEN: {{ .Values.global.HUGGINGFACEHUB_API_TOKEN | quote}}
6565
LOGFLAG: {{ .Values.LOGFLAG | quote }}
66+
NUMBA_CACHE_DIR: "/tmp/numba/cache"
67+
MPLCONFIGDIR: "/tmp/matplotlib"
68+
HAYSTACK_TELEMETRY_ENABLED: "False"

‎helm-charts/common/retriever-usvc/templates/deployment.yaml

+4
Original file line numberDiff line numberDiff line change
@@ -82,6 +82,8 @@ spec:
8282
volumeMounts:
8383
- mountPath: /tmp
8484
name: tmp
85+
- mountPath: /home/user/nltk_data
86+
name: nltk-data
8587
{{- if .Values.livenessProbe }}
8688
livenessProbe:
8789
{{- toYaml .Values.livenessProbe | nindent 12 }}
@@ -99,6 +101,8 @@ spec:
99101
volumes:
100102
- name: tmp
101103
emptyDir: {}
104+
- name: nltk-data
105+
emptyDir: {}
102106
{{- with .Values.nodeSelector }}
103107
nodeSelector:
104108
{{- toYaml . | nindent 8 }}

‎helm-charts/common/retriever-usvc/values.yaml

+1-2
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,7 @@ podSecurityContext: {}
6868
# fsGroup: 2000
6969

7070
securityContext:
71-
# NOTE: many dependent python modules(e.g. numpy, mpl, haystack, etc.) need to write to local disk
72-
readOnlyRootFilesystem: false
71+
readOnlyRootFilesystem: true
7372
allowPrivilegeEscalation: false
7473
runAsNonRoot: true
7574
runAsUser: 1000

0 commit comments

Comments
 (0)
Please sign in to comment.