apiVersion: v1
kind: ConfigMap
metadata:
  name: alertmanager-config
  namespace: vortex
data:
  alertmanager.yml: |-
    global:
      smtp_smarthost: 'smtp.sendgrid.net:587'
      smtp_from: 'vortex@linkernetworks.com'
      smtp_auth_username: 'apikey'
      smtp_auth_password: 'key'

    route:
      group_by: ['admin', 'email_account', 'email_domain']
      receiver: admin
      routes:
      - match:
          admin: true
        receiver: admin
      - match:
          admin: false
        receiver: email_router

    receivers:
    - name: admin
      email_configs:
      - to: "vortex@linkernetworks.com"
        headers: { Subject: "[WARN] Alert Email From Vortex Alertmanager" }
        html: '{{ template "email.html" . }}'
    - name: email_router
      email_configs:
      - to: "{{ .GroupLabels.email_account }}@{{ .GroupLabels.email_domain }}"
        headers: { Subject: "[WARN] Alert Email From Vortex Alertmanager" }
        html: '{{ template "email.html" . }}'

    templates:
      - '/etc/email-template/email.tmpl'
