{{- /*
Copyright Broadcom, Inc. All Rights Reserved.
SPDX-License-Identifier: APACHE-2.0
*/}}

{{- if .Values.prometheus.enabled }}
apiVersion: monitoring.coreos.com/v1
kind: Prometheus
metadata:
  name: {{ template "kube-prometheus.prometheus.fullname" . }}
  namespace: {{ include "common.names.namespace" . | quote }}
  labels: {{- include "kube-prometheus.prometheus.labels" . | nindent 4 }}
  {{- if .Values.commonAnnotations }}
  annotations: {{- include "common.tplvalues.render" ( dict "value" .Values.commonAnnotations "context" $ ) | nindent 4 }}
  {{- end }}
spec:
  replicas: {{ .Values.prometheus.replicaCount }}
  shards: {{ .Values.prometheus.shards }}
  serviceAccountName: {{ template "kube-prometheus.prometheus.serviceAccountName" . }}
  {{- if .Values.prometheus.serviceMonitorSelector }}
  serviceMonitorSelector: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.serviceMonitorSelector "context" $) | nindent 4 }}
  {{- else }}
  serviceMonitorSelector: {}
  {{- end }}
  {{- if .Values.prometheus.podMonitorSelector }}
  podMonitorSelector: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.podMonitorSelector "context" $) | nindent 4 }}
  {{- else }}
  podMonitorSelector: {}
  {{- end }}
  {{- if .Values.prometheus.probeSelector }}
  probeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.probeSelector "context" $) | nindent 4 }}
  {{- else }}
  probeSelector: {}
  {{- end }}
  {{- if .Values.prometheus.scrapeConfigSelector }}
  scrapeConfigSelector: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.scrapeConfigSelector "context" $) | nindent 4 }}
  {{- else }}
  scrapeConfigSelector: {}
  {{- end }}
  alerting:
    alertmanagers:
    {{- if .Values.prometheus.alertingEndpoints }}
    {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.alertingEndpoints "context" $) | nindent 6 }}
    {{- else if .Values.alertmanager.enabled }}
      - namespace: {{ include "common.names.namespace" . | quote }}
        name: {{ template "kube-prometheus.alertmanager.fullname" . }}
        port: http
        pathPrefix: "{{ .Values.alertmanager.routePrefix }}"
    {{- else }}
      []
    {{- end }}
  {{- if .Values.prometheus.image }}
  image: {{ template "kube-prometheus.prometheus.image" . }}
  imagePullPolicy: {{ .Values.prometheus.image.pullPolicy }}
  {{- end }}
  {{- if .Values.prometheus.additionalArgs }}
  additionalArgs: {{- toYaml .Values.prometheus.additionalArgs | nindent 4 }}
  {{- end -}}
  {{- if .Values.prometheus.externalLabels }}
  externalLabels: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.externalLabels "context" $) | nindent 4 }}
  {{- end }}
  {{- if .Values.prometheus.prometheusExternalLabelNameClear }}
  prometheusExternalLabelName: ""
  {{- else if .Values.prometheus.prometheusExternalLabelName }}
  prometheusExternalLabelName: "{{ .Values.prometheus.prometheusExternalLabelName }}"
  {{- end }}
  {{- if .Values.prometheus.replicaExternalLabelNameClear }}
  replicaExternalLabelName: ""
  {{- else if .Values.prometheus.replicaExternalLabelName }}
  replicaExternalLabelName: "{{ .Values.prometheus.replicaExternalLabelName }}"
  {{- end }}
  {{- if index .Values.prometheus "externalUrl" }}
  externalUrl: "{{ .Values.prometheus.externalUrl }}"
  {{- else if and .Values.prometheus.ingress.enabled }}
  externalUrl: {{ printf "%s://%s%s" (ternary "https" "http" .Values.prometheus.ingress.tls) .Values.prometheus.ingress.hostname .Values.prometheus.routePrefix }}
  {{- else }}
  externalUrl: http://{{ template "kube-prometheus.prometheus.fullname" . }}.{{ include "common.names.namespace" . }}:9090{{ .Values.prometheus.routePrefix }}
  {{- end }}
  paused: {{ .Values.prometheus.paused }}
  logLevel: {{ .Values.prometheus.logLevel }}
  logFormat: {{ .Values.prometheus.logFormat }}
  listenLocal: {{ .Values.prometheus.listenLocal }}
  nameValidationScheme: {{ .Values.prometheus.nameValidationScheme }}
  enableAdminAPI: {{ .Values.prometheus.enableAdminAPI }}
  {{- if .Values.prometheus.enableFeatures }}
  enableFeatures:
    {{- range .Values.prometheus.enableFeatures }}
    - {{ . | quote }}
    {{- end }}
  {{- end }}
  {{- if .Values.prometheus.scrapeInterval }}
  scrapeInterval: {{ .Values.prometheus.scrapeInterval }}
  {{- end }}
  {{- if .Values.prometheus.evaluationInterval }}
  evaluationInterval: {{ .Values.prometheus.evaluationInterval }}
  {{- end }}
  {{- if .Values.prometheus.scrapeTimeout }}
  scrapeTimeout: {{ .Values.prometheus.scrapeTimeout }}
  {{- end }}
  {{- if .Values.prometheus.sampleLimit }}
  sampleLimit: {{ .Values.prometheus.sampleLimit }}
  {{- end }}
  {{- if .Values.prometheus.enforcedSampleLimit }}
  enforcedSampleLimit: {{ .Values.prometheus.enforcedSampleLimit }}
  {{- end }}
  {{- if .Values.prometheus.keepDroppedTargets }}
  keepDroppedTargets: {{ .Values.prometheus.keepDroppedTargets }}
  {{- end }}
  {{- if .Values.prometheus.resources }}
  resources: {{- toYaml .Values.prometheus.resources | nindent 4 }}
  {{- else if ne .Values.prometheus.resourcesPreset "none" }}
  resources: {{- include "common.resources.preset" (dict "type" .Values.prometheus.resourcesPreset) | nindent 4 }}
  {{- end }}
  retention: {{ .Values.prometheus.retention }}
  {{- if .Values.prometheus.retentionSize }}
  retentionSize: {{ .Values.prometheus.retentionSize }}
  {{- end }}
  {{- if .Values.prometheus.disableCompaction }}
  disableCompaction: {{ .Values.prometheus.disableCompaction }}
  {{- end }}
  {{- if .Values.prometheus.walCompression }}
  walCompression: {{ .Values.prometheus.walCompression }}
  {{- end }}
  portName: "{{ .Values.prometheus.portName }}"
  routePrefix: "{{ .Values.prometheus.routePrefix }}"
  {{- if .Values.prometheus.secrets }}
  secrets: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.secrets "context" $) | nindent 4 }}
  {{- end }}
  {{- if .Values.prometheus.configMaps }}
  configMaps: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.configMaps "context" $) | nindent 4 }}
  {{- end }}
  {{- if .Values.prometheus.serviceMonitorNamespaceSelector }}
  serviceMonitorNamespaceSelector: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.serviceMonitorNamespaceSelector "context" $) | nindent 4 }}
  {{- else }}
  serviceMonitorNamespaceSelector: {}
  {{- end }}
  {{- if .Values.prometheus.podMonitorNamespaceSelector }}
  podMonitorNamespaceSelector: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.podMonitorNamespaceSelector "context" $) | nindent 4 }}
  {{- else }}
  podMonitorNamespaceSelector: {}
  {{- end }}
  {{- if .Values.prometheus.probeNamespaceSelector }}
  probeNamespaceSelector: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.probeNamespaceSelector "context" $) | nindent 4 }}
  {{- else }}
  probeNamespaceSelector: {}
  {{- end }}
  {{- if .Values.prometheus.scrapeConfigNamespaceSelector }}
  scrapeConfigNamespaceSelector: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.scrapeConfigNamespaceSelector "context" $) | nindent 4 }}
  {{- else }}
  scrapeConfigNamespaceSelector: {}
  {{- end }}
  {{- if .Values.prometheus.scrapeClasses }}
  scrapeClasses: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.scrapeClasses "context" $) | nindent 4 }}
  {{- end }}
  enableRemoteWriteReceiver: {{ .Values.prometheus.enableRemoteWriteReceiver }}
  {{- if .Values.prometheus.remoteRead }}
  remoteRead: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.remoteRead "context" $) | nindent 4 }}
  {{- end }}
  {{- if .Values.prometheus.remoteWrite }}
  remoteWrite: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.remoteWrite "context" $) | nindent 4 }}
  {{- end }}
  {{- if .Values.prometheus.podSecurityContext.enabled }}
  securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.prometheus.podSecurityContext "context" $) | nindent 4 }}
  {{- end }}
  {{- if .Values.prometheus.ruleNamespaceSelector }}
  ruleNamespaceSelector: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.ruleNamespaceSelector "context" $) | nindent 4 }}
  {{- else }}
  ruleNamespaceSelector: {}
  {{- end }}
  {{- if .Values.prometheus.ruleSelector }}
  ruleSelector: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.ruleSelector "context" $) | nindent 4 }}
  {{- else }}
  ruleSelector: {}
  {{- end }}
  {{- if .Values.prometheus.storageSpec }}
  storage: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.storageSpec "context" $) | nindent 4 }}
  {{- else if .Values.prometheus.persistence.enabled }}
  storage:
    volumeClaimTemplate:
      {{- if or .Values.prometheus.persistence.annotations .Values.commonAnnotations .Values.commonLabels }}
      metadata:
        {{- if or .Values.prometheus.persistence.annotations .Values.commonAnnotations }}
        {{- $claimAnnotations := include "common.tplvalues.merge" ( dict "values" ( list .Values.prometheus.persistence.annotations .Values.commonAnnotations ) "context" . ) }}
        annotations: {{- include "common.tplvalues.render" ( dict "value" $claimAnnotations "context" $ ) | nindent 10 }}
        {{- end }}
        {{- if .Values.commonLabels }}
        labels: {{- include "common.tplvalues.render" (dict "value" .Values.commonLabels "context" $) | nindent 10 }}
        {{- end }}
      {{- end }}
      spec:
        accessModes:
          {{- range .Values.prometheus.persistence.accessModes }}
          - {{ . | quote }}
          {{- end }}
        resources:
          requests:
            storage: {{ .Values.prometheus.persistence.size | quote }}
        {{- include "common.storage.class" (dict "persistence" .Values.prometheus.persistence "global" .Values.global) | nindent 8 }}
  {{- end }}
  podMetadata:
    labels: {{- include "kube-prometheus.prometheus.matchLabels" . | nindent 6 }}
    {{- if .Values.prometheus.podMetadata.annotations }}
    annotations: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.podMetadata.annotations "context" $) | nindent 6 }}
    {{- end }}
  {{- if .Values.prometheus.querySpec }}
  query: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.querySpec "context" $) | nindent 4 }}
  {{- end }}
  {{- if .Values.prometheus.affinity }}
  affinity: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.affinity "context" $) | nindent 4 }}
  {{- else }}
  affinity:
    {{- if not (empty .Values.prometheus.podAffinityPreset) }}
    podAffinity: {{- include "common.affinities.pods" (dict "type" .Values.prometheus.podAffinityPreset "component" "prometheus" "context" $) | nindent 6 }}
    {{- end }}
    {{- if not (empty .Values.prometheus.podAntiAffinityPreset) }}
    podAntiAffinity: {{- include "common.affinities.pods" (dict "type" .Values.prometheus.podAntiAffinityPreset "component" "prometheus" "context" $) | nindent 6 }}
    {{- end }}
    {{- if not (empty .Values.prometheus.nodeAffinityPreset.values) }}
    nodeAffinity: {{- include "common.affinities.nodes" (dict "type" .Values.prometheus.nodeAffinityPreset.type "key" .Values.prometheus.nodeAffinityPreset.key "values" .Values.prometheus.nodeAffinityPreset.values) | nindent 6 }}
    {{- end }}
  {{- end }}
  {{- if .Values.prometheus.nodeSelector }}
  nodeSelector: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.nodeSelector "context" $) | nindent 4 }}
  {{- end }}
  {{- if .Values.prometheus.tolerations }}
  tolerations: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.tolerations "context" $) | nindent 4 }}
  {{- end }}
  {{- if .Values.prometheus.topologySpreadConstraints }}
  topologySpreadConstraints: {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.topologySpreadConstraints "context" $) | nindent 4 }}
  {{- end }}
  volumes:
    - name: empty-dir
      emptyDir: {}
    {{- if .Values.prometheus.volumes }}
    {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.volumes "context" $) | nindent 4 }}
    {{- end }}
  volumeMounts:
    - name: empty-dir
      mountPath: /tmp
      subPath: tmp-dir
    {{- if .Values.prometheus.volumeMounts }}
    {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.volumeMounts "context" $) | nindent 4 }}
    {{- end }}
  {{- if .Values.prometheus.additionalScrapeConfigs.enabled }}
  additionalScrapeConfigs:
    {{- if and .Values.prometheus.additionalScrapeConfigs.enabled (eq .Values.prometheus.additionalScrapeConfigs.type "external") }}
    name: {{ .Values.prometheus.additionalScrapeConfigs.external.name }}
    key: {{ .Values.prometheus.additionalScrapeConfigs.external.key }}
    {{- else if and .Values.prometheus.additionalScrapeConfigs.enabled (eq .Values.prometheus.additionalScrapeConfigs.type "internal") }}
    name: additional-scrape-jobs-{{ template "kube-prometheus.prometheus.fullname" . }}
    key: scrape-jobs.yaml
    {{- end }}
  {{- end }}
  {{- if .Values.prometheus.additionalAlertRelabelConfigsExternal.enabled }}
  additionalAlertRelabelConfigs:
    name: {{ .Values.prometheus.additionalAlertRelabelConfigsExternal.name }}
    key: {{ .Values.prometheus.additionalAlertRelabelConfigsExternal.key }}
  {{- end }}
  {{- if .Values.prometheus.additionalAlertManagerExternal.enabled }}
  additionalAlertManagerConfigs:
    name: {{ .Values.prometheus.additionalAlertManagerExternal.name }}
    key: {{ .Values.prometheus.additionalAlertManagerExternal.key }}
  {{- end -}}
{{- include "kube-prometheus.imagePullSecrets" . | nindent 2 }}
  {{- if or .Values.prometheus.containers .Values.prometheus.thanos.create .Values.prometheus.containerSecurityContext.enabled .Values.prometheus.containerSecurityContext.enabled .Values.operator.prometheusConfigReloader.containerSecurityContext.enabled }}
  {{- if .Values.prometheus.initContainers }}
  initContainers:
    {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.initContainers "context" $) | nindent 4 }}
  {{- end }}
  containers:
    {{- if .Values.prometheus.thanos.create }}
    - name: thanos-sidecar
      image: {{ template "kube-prometheus.prometheus.thanosImage" . }}
      imagePullPolicy: {{ .Values.prometheus.thanos.image.pullPolicy }}
      args:
        - sidecar
        - --prometheus.url={{ default "http://localhost:9090" .Values.prometheus.thanos.prometheusUrl }}
        - --grpc-address=0.0.0.0:{{ .Values.prometheus.thanos.containerPorts.grpc }}
        - --http-address=0.0.0.0:{{ .Values.prometheus.thanos.containerPorts.http }}
        - --tsdb.path=/prometheus/
        {{- if .Values.prometheus.thanos.objectStorageConfig.secretName }}
        - --objstore.config=$(OBJSTORE_CONFIG)
        {{- end }}
        {{- if .Values.prometheus.thanos.extraArgs }}
        {{ toYaml .Values.prometheus.thanos.extraArgs | indent 8  | trim }}
        {{- end }}
      env:
        {{- if .Values.prometheus.thanos.objectStorageConfig.secretName }}
        - name: OBJSTORE_CONFIG
          valueFrom:
            secretKeyRef:
              name: {{ .Values.prometheus.thanos.objectStorageConfig.secretName }}
              key: {{ .Values.prometheus.thanos.objectStorageConfig.secretKey | default "thanos.yaml" }}
        {{- end }}
        {{- if .Values.prometheus.thanos.extraEnvVars }}
        {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.thanos.extraEnvVars "context" $) | nindent 8 }}
        {{- end }}
      {{- if or .Values.prometheus.thanos.extraEnvVarsCM .Values.prometheus.thanos.extraEnvVarsSecret }}
      envFrom:
        {{- if .Values.prometheus.thanos.extraEnvVarsCM }}
        - configMapRef:
            name: {{ include "common.tplvalues.render" (dict "value" .Values.prometheus.thanos.extraEnvVarsCM "context" $) }}
        {{- end }}
        {{- if .Values.prometheus.thanos.extraEnvVarsSecret }}
        - secretRef:
            name: {{ include "common.tplvalues.render" (dict "value" .Values.prometheus.thanos.extraEnvVarsSecret "context" $) }}
        {{- end }}
      {{- end}}
      {{- if .Values.prometheus.thanos.resources }}
      resources: {{- toYaml .Values.prometheus.thanos.resources | nindent 8 }}
      {{- else if ne .Values.prometheus.thanos.resourcesPreset "none" }}
      resources: {{- include "common.resources.preset" (dict "type" .Values.prometheus.thanos.resourcesPreset) | nindent 8 }}
      {{- end }}
      ports:
        - name: grpc
          containerPort: {{ .Values.prometheus.thanos.containerPorts.grpc }}
          protocol: TCP
        - name: http
          containerPort: {{ .Values.prometheus.thanos.containerPorts.http }}
          protocol: TCP
      volumeMounts:
        - mountPath: /prometheus
          name: prometheus-{{ template "kube-prometheus.prometheus.fullname" . }}-db
          {{- if not (.Values.prometheus.storageSpec.disableMountSubPath | default (not .Values.prometheus.persistence.enabled)) }}
          subPath: prometheus-db
          {{- end }}
        {{- if .Values.prometheus.thanos.extraVolumeMounts }}
        {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.thanos.extraVolumeMounts "context" $) | nindent 8 }}
        {{- end }}
      {{- if .Values.prometheus.thanos.containerSecurityContext.enabled }}
      # yamllint disable rule:indentation
      securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.prometheus.thanos.containerSecurityContext "context" $) | nindent 8 }}
      # yamllint enable rule:indentation
      {{- end }}
      {{- if .Values.prometheus.thanos.livenessProbe.enabled }}
      livenessProbe:
        httpGet:
          path: {{ .Values.prometheus.thanos.livenessProbe.path }}
          port: http
          scheme: HTTP
        initialDelaySeconds: {{ .Values.prometheus.thanos.livenessProbe.initialDelaySeconds }}
        periodSeconds: {{ .Values.prometheus.thanos.livenessProbe.periodSeconds }}
        timeoutSeconds: {{ .Values.prometheus.thanos.livenessProbe.timeoutSeconds }}
        failureThreshold: {{ .Values.prometheus.thanos.livenessProbe.failureThreshold }}
        successThreshold: {{ .Values.prometheus.thanos.livenessProbe.successThreshold }}
      {{- end }}
      {{- if .Values.prometheus.thanos.readinessProbe.enabled }}
      readinessProbe:
        httpGet:
          path: {{ .Values.prometheus.thanos.readinessProbe.path }}
          port: http
          scheme: HTTP
        initialDelaySeconds: {{ .Values.prometheus.thanos.readinessProbe.initialDelaySeconds }}
        periodSeconds: {{ .Values.prometheus.thanos.readinessProbe.periodSeconds }}
        timeoutSeconds: {{ .Values.prometheus.thanos.readinessProbe.timeoutSeconds }}
        failureThreshold: {{ .Values.prometheus.thanos.readinessProbe.failureThreshold }}
        successThreshold: {{ .Values.prometheus.thanos.readinessProbe.successThreshold }}
      {{- end }}
    {{- end }}
    {{- if or .Values.prometheus.containerSecurityContext.enabled .Values.prometheus.livenessProbe.enabled .Values.prometheus.readinessProbe.enabled }}
    ## This monkey patching is needed until the securityContexts are
    ## directly patchable via the CRD.
    ## ref: https://github.com/prometheus-operator/prometheus-operator/issues/3947
    ## currently implemented with strategic merge
    ## ref: https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/user-guides/strategic-merge-patch.md
    - name: prometheus
      {{- if .Values.prometheus.containerSecurityContext.enabled }}
      securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.prometheus.containerSecurityContext "context" $) | nindent 8 }}
      {{- end }}
      {{- if .Values.prometheus.livenessProbe.enabled }}
      livenessProbe:
        httpGet:
          path: {{ .Values.prometheus.livenessProbe.path }}
          port: web
          scheme: HTTP
        initialDelaySeconds: {{ .Values.prometheus.livenessProbe.initialDelaySeconds }}
        periodSeconds: {{ .Values.prometheus.livenessProbe.periodSeconds }}
        timeoutSeconds: {{ .Values.prometheus.livenessProbe.timeoutSeconds }}
        failureThreshold: {{ .Values.prometheus.livenessProbe.failureThreshold }}
        successThreshold: {{ .Values.prometheus.livenessProbe.successThreshold }}
      {{- end }}
      {{- if .Values.prometheus.readinessProbe.enabled }}
      readinessProbe:
        httpGet:
          path: {{ .Values.prometheus.readinessProbe.path }}
          port: web
          scheme: HTTP
        initialDelaySeconds: {{ .Values.prometheus.readinessProbe.initialDelaySeconds }}
        periodSeconds: {{ .Values.prometheus.readinessProbe.periodSeconds }}
        timeoutSeconds: {{ .Values.prometheus.readinessProbe.timeoutSeconds }}
        failureThreshold: {{ .Values.prometheus.readinessProbe.failureThreshold }}
        successThreshold: {{ .Values.prometheus.readinessProbe.successThreshold }}
      {{- end }}
      {{- if .Values.prometheus.startupProbe.enabled }}
      startupProbe:
        httpGet:
          path: {{ .Values.prometheus.startupProbe.path }}
          port: web
          scheme: HTTP
        initialDelaySeconds: {{ .Values.prometheus.startupProbe.initialDelaySeconds }}
        periodSeconds: {{ .Values.prometheus.startupProbe.periodSeconds }}
        timeoutSeconds: {{ .Values.prometheus.startupProbe.timeoutSeconds }}
        failureThreshold: {{ .Values.prometheus.startupProbe.failureThreshold }}
        successThreshold: {{ .Values.prometheus.startupProbe.successThreshold }}
      {{- end }}
    {{- end }}
    {{- if or .Values.operator.prometheusConfigReloader.containerSecurityContext.enabled .Values.operator.prometheusConfigReloader.livenessProbe.enabled .Values.operator.prometheusConfigReloader.readinessProbe.enabled }}
    ## This monkey patching is needed until the securityContexts are
    ## directly patchable via the CRD.
    ## ref: https://github.com/prometheus-operator/prometheus-operator/issues/3947
    ## currently implemented with strategic merge
    ## ref: https://github.com/prometheus-operator/prometheus-operator/blob/master/Documentation/user-guides/strategic-merge-patch.md
    - name: config-reloader
      {{- if .Values.operator.prometheusConfigReloader.containerSecurityContext.enabled }}
      securityContext: {{- include "common.compatibility.renderSecurityContext" (dict "secContext" .Values.operator.prometheusConfigReloader.containerSecurityContext "context" $) | nindent 8 }}
      {{- end }}
      {{- if .Values.operator.prometheusConfigReloader.livenessProbe.enabled }}
      livenessProbe:
        tcpSocket:
          port: reloader-web
        initialDelaySeconds: {{ .Values.operator.prometheusConfigReloader.livenessProbe.initialDelaySeconds }}
        periodSeconds: {{ .Values.operator.prometheusConfigReloader.livenessProbe.periodSeconds }}
        timeoutSeconds: {{ .Values.operator.prometheusConfigReloader.livenessProbe.timeoutSeconds }}
        failureThreshold: {{ .Values.operator.prometheusConfigReloader.livenessProbe.failureThreshold }}
        successThreshold: {{ .Values.operator.prometheusConfigReloader.livenessProbe.successThreshold }}
      {{- end }}
      {{- if .Values.operator.prometheusConfigReloader.readinessProbe.enabled }}
      readinessProbe:
        tcpSocket:
          port: reloader-web
        initialDelaySeconds: {{ .Values.operator.prometheusConfigReloader.readinessProbe.initialDelaySeconds }}
        periodSeconds: {{ .Values.operator.prometheusConfigReloader.readinessProbe.periodSeconds }}
        timeoutSeconds: {{ .Values.operator.prometheusConfigReloader.readinessProbe.timeoutSeconds }}
        failureThreshold: {{ .Values.operator.prometheusConfigReloader.readinessProbe.failureThreshold }}
        successThreshold: {{ .Values.operator.prometheusConfigReloader.readinessProbe.successThreshold }}
      {{- end }}
    {{- end }}
    {{- if .Values.prometheus.containers }}
    {{- include "common.tplvalues.render" (dict "value" .Values.prometheus.containers "context" $) | nindent 4 }}
    {{- end }}
  {{- end }}
  {{- if .Values.prometheus.priorityClassName }}
  priorityClassName: {{ .Values.prometheus.priorityClassName }}
  {{- end }}
{{- end }}
