apiVersion: monitoring.coreos.com/v1
kind: Alertmanager
metadata:
  labels:
    alertmanager: '{{ meta.name }}'
  name: '{{ meta.name }}'
  namespace: '{{ meta.namespace }}'
spec:
  replicas: {{ servicetelemetry_vars.alerting.alertmanager.deployment_size }}
  serviceAccountName: alertmanager-stf
  serviceMonitorSelector:
    matchLabels:
      app: smart-gateway
  listenLocal: true
  podMetadata:
    labels:
      alertmanager: '{{ meta.name }}'
  containers:
  - name: oauth-proxy
    image: {{ oauth_proxy_image }}
    args:
    - -https-address=:9095
    - -tls-cert=/etc/tls/private/tls.crt
    - -tls-key=/etc/tls/private/tls.key
    - -upstream=http://localhost:9093/
    - -cookie-secret-file=/etc/proxy/secrets/session_secret
    - -openshift-service-account=alertmanager-stf
    - '-openshift-sar={"resource": "namespaces", "verb": "get"}'
    - '-openshift-delegate-urls={"/": {"resource": "namespaces", "verb": "get"}}'
    ports:
      - containerPort: 9095
        name: https
        protocol: TCP
    volumeMounts:
      - mountPath: /etc/tls/private
        name: secret-{{ meta.name }}-alertmanager-proxy-tls
      - mountPath: /etc/proxy/secrets
        name: secret-{{ meta.name }}-session-secret
  secrets:
    - '{{ meta.name }}-alertmanager-proxy-tls'
    - '{{ meta.name }}-session-secret'
{% if servicetelemetry_vars.alerting.alertmanager.storage.strategy == "persistent" %}
  storage:
    volumeClaimTemplate:
      spec:
        resources:
          requests:
            storage: {{ servicetelemetry_vars.alerting.alertmanager.storage.persistent.pvc_storage_request }}
{% if servicetelemetry_vars.alerting.alertmanager.storage.persistent.storage_selector is defined %}
        selector: {{ servicetelemetry_vars.alerting.alertmanager.storage.persistent.storage_selector }}
{% endif %}
{% if servicetelemetry_vars.alerting.alertmanager.storage.persistent.storage_class | length %}
        storageClassName: {{ servicetelemetry_vars.alerting.alertmanager.storage.persistent.storage_class }}
{% endif %}
{% endif %}
