Description
Currently alerting via Slack/MS Teams can be configured globally with Flagger command flags. This approach has several limitations as it's not possible to specify different channels (ref: #128 #242) or configure the verbosity (ref: #427) on a per canary basis.
To make the alerting move flexible, the canary analysis could be extended with a list of alerts that would reference an alert provider, for each alert users can configure the severity level. The alerts section would override the global setting.
Alert provider specifications
Kubernetes custom resource:
type AlertProviderSpec struct {
// Type of provider
Type string `json:"type"`
// Alert channel for this provider
// +optional
Channel string `json:"channel,omitempty"`
// Bot username for this provider
// +optional
Username string `json:"username,omitempty"`
// HTTP(S) webhook address of this provider
// +optional
Address string `json:"address,omitempty"`
// Secret reference containing the provider webhook URL
// +optional
SecretRef *corev1.LocalObjectReference `json:"secretRef,omitempty"`
}
The alert provider type can be: slack
, msteams
, rocket
or discord
. When set to discord
, Flagger will use Slack formatting and will append /slack
to the Discord address.
When not specified, channel defaults to general
and username defaults to flagger
.
When secretRef is specified, the Kubernetes secret must contain a data field named address
, the address in the secret will take precedence over the address field in the provider spec.
Slack example:
apiVersion: flagger.app/v1beta1
kind: AlertProvider
metadata:
name: dev-slack
namespace: flagger
spec:
type: slack
channel: dev-alerts
username: flagger
# webhook address (ignored if secretRef is specified)
address: https://hooks.slack.com/services/YOUR/SLACK/WEBHOOK
# secret containing the webhook address (optional)
secretRef:
name: dev-slack-url
---
apiVersion: v1
kind: Secret
metadata:
name: dev-slack-url
namespace: flagger
data:
address: <encoded-url>
Canary analysis specifications
The canary analysis can have a list of alerts, each alert referencing an alert provider:
apiVersion: flagger.app/v1beta1
kind: Canary
metadata:
name: app
namespace: staging
spec:
canaryAnalysis:
alerts:
- name: "dev team Slack"
severity: error
providerRef:
name: dev-slack
namespace: flagger
- name: "qa team Discord"
severity: warn
providerRef:
name: qa-discord
- name: "on-call MS Teams"
severity: info
providerRef:
name: on-call-msteams
Alert fields:
- name (required)
- severity levels:
info
,warn
,error
(default info) - providerRef.name alert provider name (required)
- providerRef.namespace alert provider namespace (defaults to the canary namespace)
When the severity is set to warn
, Flagger will alert when waiting on manual confirmation or if the analysis fails.
When the severity is set to error
, Flagger will alert only if the canary analysis fails.