------> 课程视频同步分享在今日头条和B站
大家好,我是博哥爱运维。这节课给大家分析一款K8S上宝藏级秒级事件监控报警的开源软件kube-eventer
,它是由阿里云开源的,并且难得的还一直有在更新。
天下武功,唯快不破。对于报警监控也是一样,我们前面的课程有讲到prometheus这款监控软件,但总还觉得缺了些什么,对了,就是K8S上面无处不在的事件监控,博哥在实际的生产工作中,切身体会到事件监控的重要性,对于事件监控的使用力度更有超过prometheus,能及时灵敏地发现全球各个K8S集群的重要事件报警,使问题能得到及时的处理,维护了K8S集群的稳定性。
下面是kube-eventer
的github开源地址:
https://github.com/AliyunContainerService/kube-eventer
下面是博哥生产中实际在用的完整yaml配置
---
apiVersion: v1
data:
content: >-
{"EventType": "{{ .Type }}","EventNamespace": "{{
.InvolvedObject.Namespace }}","EventKind": "{{ .InvolvedObject.Kind }}","EventObject": "{{
.InvolvedObject.Name }}","EventReason": "{{
.Reason }}","EventTime": "{{ .LastTimestamp }}","EventMessage": "{{ .Message
}}"}
kind: ConfigMap
metadata:
name: kubeeventer-webhook
namespace: kube-system
---
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
name: kube-eventer
name: kube-eventer-webhook
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:v1.2.7-ca03be0-aliyun
# - image: registry.us-west-1.aliyuncs.com/acs/kube-eventer:v1.2.7-ca03be0-aliyun
name: kube-eventer
command:
- "/kube-eventer"
- "--source=kubernetes:https://test-cnk8s.boge.com:6443"
## .e.g,dingtalk sink demo
#- --sink=dingtalk:[your_webhook_url]&label=[your_cluster_id]&level=[Normal or Warning(default)]&namespaces=[kube-system,kae-app(all)]
- --sink=webhook:http://alertmanaer-dingtalk-svc.kube-system/b01bdc063/boge/getjson?level=Warning&kinds=Pod&method=POST&header=Content-Type=application/json&custom_body_configmap=kubeeventer-webhook&custom_body_configmap_namespace=kube-system
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
hostAliases:
- hostnames:
- test-cnk8s.boge.com
ip: 10.0.1.201
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:
- configmaps
- events
verbs:
- get
- list
- watch
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
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