k8s system, abnormal notification docking nail system

1: First, customize the robot in the DingTalk system to remember the webhoodk address and custom keywords, and click Finish
Insert picture description here
2: Create the test.ymal file, copy the following content, modify the webhook address, and bring the following parameters—
sink=dingtalk: https:************&label=cluster1&level=Warning#Dingding docking call interface
label is the corresponding keyword, and levle is the corresponding message level. If you need to monitor a specific namespace, you can bring &namespaces="the resource space to be monitored"


apiVersion: apps/v1
kind: Deployment
metadata:
  labels:
    name: kube-eventer
  name: kube-eventer
  namespace: kube-system
spec:
  replicas: 1
  selector:
    matchLabels:
      app: kube-eventer
  template:
    metadata:
      labels:
        app: kube-eventer
      annotations:
        scheduler.alpha.kubernetes.io/critical-pod: ''
    spec:
      dnsPolicy: ClusterFirstWithHostNet
      serviceAccount: kube-eventer
      containers:
        - image: registry.aliyuncs.com/acs/kube-eventer-amd64:v1.1.0-63e7f98-aliyun
          name: kube-eventer
          command:
            - "/kube-eventer"
            - "--source=kubernetes:https://kubernetes.default"
            ## .e.g,dingtalk sink demo
            - --sink=dingtalk:https://oapi.dingtalk.com/robot/send?access_token=340accbd0a10c1517ac511f9b0944b3f3c20d8cd7b319116xxxxxxxxxxxx&label=cluster1&level=Warning#钉钉对接的调用接口
          env:
          # If TZ is assigned, set the TZ value as the time zone
          - name: TZ
            value: Asia/Shanghai
          volumeMounts:
            - name: localtime
              mountPath: /etc/localtime
              readOnly: true
            - name: zoneinfo
              mountPath: /usr/share/zoneinfo
              readOnly: true
          resources:
            requests:
              cpu: 100m
              memory: 100Mi
            limits:
              cpu: 500m
              memory: 250Mi
      volumes:
        - name: localtime
          hostPath:
            path: /etc/localtime
        - name: zoneinfo
          hostPath:
            path: /usr/share/zoneinfo
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
  name: kube-eventer
rules:
  - apiGroups:
      - ""
    resources:
      - events
    verbs:
      - get
      - list
      - watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
  annotations:
  name: kube-eventer
roleRef:
  apiGroup: rbac.authorization.k8s.io
  kind: ClusterRole
  name: kube-eventer
subjects:
  - kind: ServiceAccount
    name: kube-eventer
    namespace: kube-system
---
apiVersion: v1
kind: ServiceAccount
metadata:
  name: kube-eventer
  namespace: kube-system

3: Log in to the background of the k8s server, transfer the file to the server, and enter the command
kubectl apply -f test.yaml
Insert picture description here

4: When a node is abnormal, a message will be automatically pushed. Push once by viewing about 30 seconds.
k8s trace log
Insert picture description here

Insert picture description here

Guess you like

Origin blog.csdn.net/qq_34237321/article/details/110849458