• Stars
    star
    224
  • Rank 177,792 (Top 4 %)
  • Language
    Go
  • License
    Apache License 2.0
  • Created over 4 years ago
  • Updated 5 months ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

K8s native notification management with multi-tenancy support

Notification Manager

Overview

Notification Manager manages notifications in multi-tenant K8s environment. It receives alerts, cloud event, and others (such as auditing, k8s events) from different senders and then send notifications to various tenant receivers based on tenant label like namespace or user.

Supported senders includes:

  • Prometheus Alertmanager
  • Custom sender
  • Prometheus (Coming soon)
  • Cloud Event (Coming soon)

Supported receivers includes:

Architecture

Notification Manager uses Receiver and Config CRDs to store notification configs like email, WeChat and slack. It also includes an operator to create and reconcile NotificationManager CRD which watches all receivers and configs, updates notification settings accordingly and sends notifications to users.

Architecture

Process

The incoming data (alert, cloud event and others) will cache in the cache firstly, then goes through steps such as silence, inhibit (coming soon), route, filter, aggregation, etc. Notifications will generate from data using template, then send to receivers and history webhook (if set).

Architecture

Silence

Silence is a straightforward way to simply mute notifications for a given time. It uses Silence CRD to define the silence policy. If incoming data matches an active silence, no notifications will be sent out for that data.

Route

Route find all receivers the notifications will send to. There are two ways to determine which receivers the notifications will send to, one is via Router CRD, and the other is auto-matching via the namespace label in the notification.

Usually the incoming data contains a namespace label, Notification Manager uses this label to decide which receiver to use for sending notifications:

  • For KubeSphere, Notification Manager will try to find tenants with the right to access the namespace from sidecar and then find receivers with user = xxx label.
  • For Kubernetes, Notification Manager will try to find receivers with namespace = xxx label.

For data without a namespace label, for example alerts of node or kubelet, user can set up a receiver with type = global label to receive notifications without a namespace label. A global receiver sends notifications for all notifications received regardless any label. A global receiver usually set for an admin role.

How the two methods work together is determined by the routePolicy.

Filter

Filter filters the notifications sent to receivers. There are two ways to filter notifications. One is using alertSelector in the receiver, the other is using tenant silence.

Aggregation

Aggregation groups notifications by groupLabels. Notifications in the same group will send together.

History

History is a webhook used to collect all notifications sent to receivers, it can be set via history.

QuickStart

Install

We assume you already have a Kubernetes cluster (v1.16+). You can install one using KubeKey if you haven't.

Install with yaml

# Deploy CRDs and the Notification Manager Operator:
kubectl apply -f https://github.com/kubesphere/notification-manager/releases/download/v2.3.0/bundle.yaml
# Deploy default template:
kubectl apply -f https://github.com/kubesphere/notification-manager/releases/download/v2.3.0/template.yaml
# Deploy built-in language packs.
kubectl apply -f https://github.com/kubesphere/notification-manager/releases/download/v2.3.0/zh-cn.yaml

Install with helm

helm install notification-manager --create-namespace -n kubesphere-monitoring-system https://github.com/kubesphere/notification-manager/releases/download/v2.3.0/notification-manager.tgz

Configure NotificationManager

NotificationManager CRD Defines the desired notification manager deployment. The Notification Manager Operator ensures a deployment meeting the resource requirements is running.

We should create a NotificationManager CR first, skip this when using helm install.

kubectl apply -f https://github.com/kubesphere/notification-manager/releases/download/v2.3.0/notification_manager.yaml

Configure sender

Notification Manager uses port 19093 and API path /api/v2/alerts to receive alerts sent from Alertmanager.

Config Alertmanager to send alerts to Notification Manager

To receive Alertmanager alerts, add webhook config like below to the receivers section of Alertmanager configuration file:

    "receivers":
     - "name": "notification-manager"
       "webhook_configs":
       - "url": "http://notification-manager-svc.kubesphere-monitoring-system.svc:19093/api/v2/alerts"

Customize sender

Below is the data structure passed to the notification manager, please refer to Data for more details.

{
  "alerts": [
    {
      "status": "firing",
      "labels": {
        "alertname": "KubePodCrashLooping",
        "container": "busybox-3jb7u6",
        "instance": "10.233.71.230:8080",
        "job": "kube-state-metrics",
        "namespace": "pp1",
        "pod": "dd1-0",
        "prometheus": "kubesphere-monitoring-system/k8s",
        "severity": "critical"
      },
      "annotations": {
        "message": "Pod pp1/dd1-0 (busybox-3jb7u6) is restarting 1.07 times / 5 minutes.",
      },
      "startsAt": "2020-02-26T07:05:04.989876849Z",
      "endsAt": "0001-01-01T00:00:00Z",
    }
  ],
}

A custom senders can send notifications using notification manager simply by sending data to http://notification-manager-svc.kubesphere-monitoring-system.svc:19093/api/v2/alerts.

Create receiver and config

Now it's time to create the receiver and config to receive notifications, you can find guides to create them in receiver and config.

Customize template

To customize the notification template, please refer to template.

Development

# Build notification-manager-operator and notification-manager docker images
make build 
# Push built docker images to docker registry
make push

Documentation

More Repositories

1

kubesphere

The container platform tailored for Kubernetes multi-cloud, datacenter, and edge management ⎈ 🖥 ☁️
Go
12,855
star
2

kubekey

Install Kubernetes/K3s only, both Kubernetes/K3s and KubeSphere, and related cloud-native add-ons, it supports all-in-one, multi-node, and HA 🔥 ⎈ 🐳
Go
2,027
star
3

kubeeye

KubeEye aims to find various problems on Kubernetes, such as application misconfiguration, unhealthy cluster components and node problems.
Go
800
star
4

console

KubeSphere Console is the web-based UI for KubeSphere clusters.
JavaScript
567
star
5

ks-installer

Install KubeSphere on existing Kubernetes cluster
Jinja
531
star
6

kube-events

K8s Event Exporting, Filtering and Alerting in Multi-Tenant Environment
Go
180
star
7

ks-devops

This is a cloud-native application that focuses on the DevOps area.
Go
158
star
8

community

KubeSphere Community
125
star
9

devops-java-sample

SpringBoot demo for DevOps on KubeSphere
Java
117
star
10

helm-charts

Source & Repo of https://charts.kubesphere.io/main & https://charts.kubesphere.io/test
Mustache
97
star
11

kube-design

Kube Design for KubeSphere Console
JavaScript
96
star
12

tower

Proxy for multiple Kubernetes cluster communication
Go
92
star
13

website

KubeSphere website and documentation
SCSS
80
star
14

devops-agent

Agents for Kubesphere DevOps
Dockerfile
66
star
15

s2ioperator

Operator for Source to image
Go
41
star
16

devops-maven-sample

Java
36
star
17

alert

Go
27
star
18

logsidecar-injector

A MutatingAdmissionWebhook that adds a sidecar to your pod. This sidecar is just for forwarding file log on the volume.
Go
26
star
19

ks-jenkins

Jenkins distribution for Kubesphere
Python
24
star
20

dev-guide

A set of development guidelines for KubeSphere developers.
HTML
19
star
21

s2irun

Run s2i in pod
Go
18
star
22

monitoring-dashboard

Custom Metrics Monitoring Dashboard for Apps on KubeSphere
Go
16
star
23

s2i-java-container

Java S2I Builder image
Shell
15
star
24

event-rule-engine

Go
12
star
25

storageclass-accessor

The storageclass-accessor webhook is an HTTP callback which responds to admission requests.
Go
10
star
26

tutorial

KubeSphere tutorial repo, include samples code, docs etc.
Shell
10
star
27

client-go

Go
9
star
28

devops-go-sample

Go
8
star
29

image-sync-config

8
star
30

im

A general identity management system
Go
8
star
31

api

Go
7
star
32

ksbuilder

A CLI tool helps you to manage the development of kubesphere extensions
Go
7
star
33

s2i-java-runtimeImage

a java runtime image for s2i
Shell
5
star
34

alert-adapter

Go
5
star
35

s2i-python-container

Shell
5
star
36

pvc-autoresizer

pvc-autoresizer resizes PersistentVolumeClaims (PVCs) when the free amount of storage is below the threshold.
Go
5
star
37

test-infra

Dockerfile
4
star
38

prometheus-example-app

Smarty
4
star
39

devops-python-sample

devops-python-sample for Kubesphere
Python
4
star
40

kubeeye-console

TypeScript
3
star
41

sonargo

Go
3
star
42

cluster-api-provider-qingcloud

The QingCloud provider implementation of the Cluster Management API
Go
3
star
43

create-ks-project

A CLI tool enables you to quickly set up a KubeSphere Console extension project.
TypeScript
3
star
44

s2i-nodejs-container

Shell
3
star
45

alertmanager-kit

alertmanager-kit encapsulates the interface to alertmanager in a neat way.
Go
3
star
46

ks-prometheus

Jsonnet
2
star
47

aks-kubesphere-linux

KubeSphere on Azure AKS
2
star
48

openpitrix-jobs

Go
2
star
49

container-common-scripts

Shell
2
star
50

s2i-binary-container

Dockerfile
1
star
51

devops-docs-sample

JavaScript
1
star
52

springboot-sample

Java
1
star
53

extension-samples

JavaScript
1
star
54

s2i-base-container

Shell
1
star
55

artwork

🎨KubeSphere-related logos and artwork
1
star
56

.github

1
star
57

kubeocean-api

Go
1
star
58

kubectl

kubectl docker image used in kubesphere.
Dockerfile
1
star
59

design-prototypes

Design prototypes for kubesphere console.
HTML
1
star