Skip to content

Commit 5cdf45f

Browse files
authored
Allow running with read only file system (#1884)
* Allow running with read only file system * CR fixes Support rendering graphs images from DD toolset * CR fixes
1 parent 4476346 commit 5cdf45f

3 files changed

Lines changed: 47 additions & 2 deletions

File tree

helm/robusta/templates/runner.yaml

Lines changed: 44 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,24 @@ spec:
4141
securityContext:
4242
{{- toYaml . | nindent 8 }}
4343
{{- end }}
44+
{{- if .Values.runner.hardenedFs }}
45+
initContainers:
46+
- name: setup-venv
47+
{{- if .Values.runner.image }}
48+
image: {{ .Values.runner.image }}
49+
{{ else }}
50+
image: {{ .Values.image.registry }}/{{ .Values.runner.imageName }}
51+
{{- end }}
52+
command:
53+
- sh
54+
- -c
55+
- >
56+
SRC="/venv/lib/$(python -V | cut -d' ' -f2 | cut -d. -f1,2)/site-packages" &&
57+
cp -a "${SRC}/." /venv-writable/
58+
volumeMounts:
59+
- name: venv-lib-volume
60+
mountPath: /venv-writable
61+
{{- end }}
4462
containers:
4563
- name: runner
4664
{{- if .Values.runner.image }}
@@ -51,7 +69,12 @@ spec:
5169
imagePullPolicy: {{ .Values.runner.imagePullPolicy }}
5270
{{- with .Values.runner.securityContext.container }}
5371
securityContext:
54-
{{- toYaml . | nindent 12 }}
72+
{{- if $.Values.runner.hardenedFs }}
73+
{{- $hardened := merge (dict "readOnlyRootFilesystem" true) . }}
74+
{{- toYaml $hardened | nindent 12 }}
75+
{{- else }}
76+
{{- toYaml . | nindent 12 }}
77+
{{- end }}
5578
{{- end }}
5679
env:
5780
- name: PLAYBOOKS_CONFIG_FILE_PATH
@@ -129,6 +152,16 @@ spec:
129152
- name: persistent-playbooks-storage
130153
mountPath: /etc/robusta/playbooks/storage
131154
{{- end }}
155+
{{- if .Values.runner.hardenedFs }}
156+
- name: tmp-volume
157+
mountPath: /tmp
158+
- name: app-git-volume
159+
mountPath: /app/robusta-git
160+
- name: cache-volume
161+
mountPath: /root/.cache
162+
- name: venv-lib-volume
163+
mountPath: /venv/lib/python3.11/site-packages
164+
{{- end }}
132165
{{- with .Values.runner.extraVolumeMounts }}
133166
{{- toYaml . | nindent 10 }}
134167
{{- end }}
@@ -182,6 +215,16 @@ spec:
182215
persistentVolumeClaim:
183216
claimName: persistent-playbooks-pv-claim
184217
{{- end }}
218+
{{- if .Values.runner.hardenedFs }}
219+
- name: tmp-volume
220+
emptyDir: {}
221+
- name: app-git-volume
222+
emptyDir: {}
223+
- name: cache-volume
224+
emptyDir: {}
225+
- name: venv-lib-volume
226+
emptyDir: {}
227+
{{- end }}
185228
{{- with .Values.runner.extraVolumes }}
186229
{{- toYaml . | nindent 8 }}
187230
{{- end }}

helm/robusta/values.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -706,6 +706,8 @@ runner:
706706
privileged: false
707707
readOnlyRootFilesystem: false
708708
pod: {}
709+
# Enable hardened filesystem security (read-only root filesystem with writable volume mounts)
710+
hardenedFs: false
709711

710712
kube-prometheus-stack:
711713
alertmanager:

src/robusta/core/playbooks/internal/ai_integration.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ def holmes_chat(event: ExecutionBaseEvent, params: HolmesChatParams):
359359
if params.render_graph_images:
360360
try:
361361
for tool in holmes_result.tool_calls:
362-
if tool.tool_name != "execute_prometheus_range_query":
362+
if tool.tool_name not in ["execute_prometheus_range_query", "query_datadog_metrics"]:
363363
continue
364364
holmes_result.analysis = re.sub(r"<<.*?>>", "", holmes_result.analysis).strip()
365365
json_content = json.loads(tool.result["data"])

0 commit comments

Comments
 (0)