kind: ConfigMap
apiVersion: v1
metadata:
  name: alertmanager
  namespace: sock-shop
data:
  config.yml: |-
    global:
      slack_api_url: https://hooks.slack.com/services/API_URL_SECRET

    route:
      group_by: [cluster]
      # If an alert isn't caught by a route, send it slack.
      receiver: slack-all
      routes:
        - match:
            severity: slack
          receiver: slack-all


    receivers:
    - name: 'slack-all'
      slack_configs:
      - channel: '#sockshop-ops'
        send_resolved: true
        title: "{{ range .Alerts }}{{ .Annotations.summary }}\n{{ end }}"
        text: "{{ range .Alerts }}{{ .Annotations.description }}\n{{ end }}"
        api_url: https://hooks.slack.com/services/API_URL_SECRET
  configure_secret.sh: |-
    echo 'Configuring Slack hook url.'
    sed -i -e s,API_URL_SECRET,"$SLACK_HOOK_URL",g /etc/alertmanager/config.yml
    exec /bin/alertmanager $*
