Get the App
SLTechnology News&Howtos  ›  Servers  › 

The use of event listeners in K8S

Shulou Source: shulou.com Published: 2022-06-01 06:47:00 10月03日 Update

K8S in the use of event listeners, I believe that many inexperienced people do nothing about this, this article summarizes the causes of the problem and solutions, through this article I hope you can solve this problem.

overview

Based on client-go, gorm implementation, real-time monitoring & parsing into DB a variety of events. Simple code, easy to expand

Real-time monitoring of k8s events and namespace, pod and other events, can be used as monitoring, system docking access

the portal

Use go mod tidygo run K8S-Eventlet.goFAQ

Go mod automatic dependency may be problematic if

# k8s.io/client-go/tools/clientcmd/api/v1/go/pkg/mod/k8s.io/client-go@v12.0.0+incompatible/tools/clientcmd/api/v1/conversion.go:29:15: scheme.AddConversionFuncs undefined (type *runtime.Scheme has no field or method AddConversionFuncs)/go/pkg/mod/k8s.io/client-go@v12.0.0+incompatible/tools/clientcmd/api/v1/conversion.go:31:12: s.DefaultConvert undefined (type conversion.Scope has no field or method DefaultConvert)

Change the contents of go.mod:

k8s.io\client-go@v11.0.0+incompatible replaced by k8s.io/client-go v0.18.2 or k8s.io\client-go@v12.0.0+incompatible replaced by k8s.io/client-go v0.18.2 Supplementary Notes

Code is relatively simple, suitable for learning, easy to expand, need to pay attention to is, also lack of queue support, to duplicate mechanism.

In addition, go can spit out the disguised realization of factory mode.

After reading the above, do you know how to use the event listener in K8S? If you still want to learn more skills or want to know more related content, welcome to pay attention to the industry information channel, thank you for reading!

Tags: Events monitoring content problems listeners conciseness code real-time methods more helpless for this reasons multiple for this factories skills mechanisms patterns articles Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno NVidia MySQL Docker macOS Huawei