Skip to content

Commit c5a28ed

Browse files
prometheus: enable readOnlyRootFilesystem
The Prometheus container previously required readOnlyRootFilesystem: false because prom-wrapper writes the Alertmanager configuration file to /sg_config_prometheus/alertmanager.yml at runtime whenever site config observability.alerts or SMTP settings change. Additionally, Alertmanager stores state (silences, notification log) at /alertmanager/. This change enables readOnlyRootFilesystem: true by: 1. Adding an emptyDir volume mounted at /alertmanager for Alertmanager state storage (--storage.path). 2. Setting ALERTMANAGER_CONFIG_PATH=/alertmanager/alertmanager.yml so prom-wrapper writes the Alertmanager config to the writable emptyDir instead of the read-only image layer at /sg_config_prometheus/. The /prometheus TSDB data path was already handled by the existing PVC, and /sg_prometheus_add_ons is already a ConfigMap mount. The baked-in alert rules at /sg_config_prometheus/ are read-only at runtime (only written at image build time), so they remain accessible on the read-only root filesystem. Resolves: https://github.com/sourcegraph/sourcegraph/issues/34012 Co-authored-by: Amp <amp@ampcode.com> Amp-Thread-ID: https://ampcode.com/threads/T-019dbe72-f13d-7233-aa22-cbeb04d03182
1 parent 96562d4 commit c5a28ed

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

charts/sourcegraph/templates/prometheus/prometheus.Deployment.yaml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,8 @@ spec:
5353
{{- end }}
5454
terminationMessagePolicy: FallbackToLogsOnError
5555
env:
56+
- name: ALERTMANAGER_CONFIG_PATH
57+
value: /alertmanager/alertmanager.yml
5658
{{- range $name, $item := .Values.prometheus.env}}
5759
- name: {{ $name }}
5860
{{- $item | toYaml | nindent 10 }}
@@ -72,6 +74,8 @@ spec:
7274
name: data
7375
- mountPath: /sg_prometheus_add_ons
7476
name: config
77+
- mountPath: /alertmanager
78+
name: alertmanager-data
7579
{{- if .Values.prometheus.extraVolumeMounts }}
7680
{{- toYaml .Values.prometheus.extraVolumeMounts | nindent 8 }}
7781
{{- end }}
@@ -104,6 +108,8 @@ spec:
104108
configMap:
105109
defaultMode: 0777
106110
name: {{ default .Values.prometheus.name .Values.prometheus.existingConfig }}
111+
- name: alertmanager-data
112+
emptyDir: {}
107113
{{- if .Values.prometheus.extraVolumes }}
108114
{{- toYaml .Values.prometheus.extraVolumes | nindent 6 }}
109115
{{- end }}

charts/sourcegraph/values.yaml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -906,8 +906,6 @@ prometheus:
906906
allowPrivilegeEscalation: false
907907
runAsUser: 100
908908
runAsGroup: 100
909-
# Read-only filesystem not supported for the prometheus container,
910-
# see [sourcegraph/issues/34012](https://github.com/sourcegraph/sourcegraph/issues/34012) for more information
911909
readOnlyRootFilesystem: false
912910
# -- Name used by resources. Does not affect service names or PVCs.
913911
name: "prometheus"

0 commit comments

Comments
 (0)