Strategic Merge Patch

This document describes how to overwrite the configuration generated by the operator using strategic merge patches.

When users need to apply a specific configuration to the containers that is either not exposed in the custom resource definitions or already defined by the operator, strategic merge patch can be used.

How does it work?

The Prometheus, Alertmanager, and ThanosRuler CRDs expose a spec.containers field which allows to:

  • Override fields for the containers generated by the operator.
  • Inject additional containers.

Merging patch for Prometheus

The following manifest overwrites the failureThreshold value of startup probe of the Prometheus container:

apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
  labels:
    prometheus: self
  name: self
  namespace: default
spec:
  containers:
  - name: prometheus
    startupProbe:
      failureThreshold: 500

Merging patch for Alertmanager

The following manifest overwrites the failureThreshold values of the readiness and liveness probes for the Alertmanager container.

apiVersion: monitoring.coreos.com/v1
kind: Alertmanager
metadata:
  labels:
    alertmanager: main
  name: main
  namespace: monitoring
spec:
  containers:
  - name: alertmanager
    livenessProbe:
      failureThreshold: 5
    readinessProbe:
      failureThreshold: 5