apiVersion: monitoring.coreos.com/v1
kind: Alertmanager
metadata:
  name: alert-regional
  namespace: default
  labels:
    app: alert-regional
spec:
  replicas: {{ .Values.replicaCount }}
  logLevel: debug
  containers:
    - name: alertmanager
      env:
      - name: AWS_REGION
        value: {{ .Values.sns.region }}
{{- if ne "aws" .Values.cloudProvider }}
      - name: AWS_ROLE_ARN
        value: {{ .Values.awsRoleArn }}
      - name: AWS_STS_REGIONAL_ENDPOINTS
        value: regional
      - name: AWS_WEB_IDENTITY_TOKEN_FILE
        value: /var/run/secrets/token/aws-iam-token
      volumeMounts:
      - mountPath: /var/run/secrets/token
        name: aws-iam-token
{{- end }}
      resources:
        requests:
          cpu: "50m"
          memory: "256Mi"
        limits:
          cpu: "200m"
          memory: "1024Mi"
    - name: config-reloader
      resources:
        limits:
          cpu: 200m
          memory: 50Mi
        requests:
          cpu: 10m
          memory: 10Mi
  serviceAccountName: alertmanager-regional
  alertmanagerConfigSelector:
    matchExpressions:
      - key: observability.pingcap.com/tenantID
        operator: Exists
{{- if ne "aws" .Values.cloudProvider }}
  volumes:
  - name: aws-iam-token
    projected:
      sources:
      - serviceAccountToken:
          audience: sts.amazonaws.com
          expirationSeconds: 7200
          path: aws-iam-token
{{- end }}
  alertmanagerConfiguration:
    name: observability-alertmanager-config
  topologySpreadConstraints:
    - maxSkew: 1
      topologyKey: topology.kubernetes.io/zone
      whenUnsatisfiable: ScheduleAnyway
      labelSelector:
        matchLabels:
          alertmanager: alert-regional
  storage:
    volumeClaimTemplate:
      spec:
        accessModes: ["ReadWriteOnce"]
        resources:
          requests:
            storage: 1Gi
  retention: 120h