Skip to content

Commit ffc9be9

Browse files
committed
Configure securityContext for AlertManager statefulset.
AlertManager became a non-root image some time ago. Since in StatefulSet variant it writes some state to an external PV, which is usually ext4-formatted and root-owned, this prevents AM from writing to the PV. Prometheus had a similar issue which has been resolved by adding `securityContext` to the StatefulSet in #244; let's do the same for AlertManager. Signed-off-by: Milan Plzik <[email protected]>
1 parent fbff57b commit ffc9be9

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

prometheus-ksonnet/lib/alertmanager.libsonnet

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,9 @@
150150
], self.alertmanager_pvc) +
151151
statefulset.mixin.spec.withServiceName('alertmanager') +
152152
statefulset.mixin.spec.template.metadata.withAnnotations({ 'prometheus.io.path': '%smetrics' % $._config.alertmanager_path }) +
153+
statefulset.mixin.spec.template.spec.securityContext.withFsGroup(2000) +
154+
statefulset.mixin.spec.template.spec.securityContext.withRunAsUser(1000) +
155+
statefulset.mixin.spec.template.spec.securityContext.withRunAsNonRoot(true) +
153156
$.util.configVolumeMount('alertmanager-config', '/etc/alertmanager/config') +
154157
$.util.podPriority('critical')
155158
else {},

0 commit comments

Comments
 (0)