kubernetes Dynamic Informers with client-go
Watching Kubernetes custom resources with dynamic informers & golang
k8s Operator를 만들 때, CRD의 reconcile 로직을 적용하기 위해 Get / List Loop를 쓰는 경우가 있다.
- ineffective / slow way to find changes.
- 예컨대 리소스가 backoff 상태라면 Get / List 요청을 보내는 주기가 갈수록 느려진다.
- 리소스가 많을 경우 pagination 등... 고려할 것들이 늘어남
- client go에서 제공하는 (shared) cache를 사용해서 보완하기도 함
- 위의 방식들보다 더 나은, InformerFactory를 사용해서 Watcher를 만드는 방법
- Watcher: Event Stream that is dynamically connected; like a pipe from API server to your Implementation.
- send back & forth events over GRPC.
- get Real-time updates. Restful Request를 매번 주고받는 게 아니라 single Event Stream을 받는다.
- Watcher: Event Stream that is dynamically connected; like a pipe from API server to your Implementation.
- client go에서 informer 관련 구현체는 문서화가 덜 되어 있는 편임.
https://aly.arriqaaq.com/kubernetes-informers/
A Deep Dive Into Kubernetes Informers
I wanted to understand more about how Kubernetes controllers are implemented. Building controllers with controller-runtime [https://github.com/kubernetes-sigs/kubebuilder] is pretty easy but it masks many details on how the event-oriented architecture of c
aly.arriqaaq.com
구현할 것: Dynamic Shared Informer Factory.
- Dynamic? -> Not using Concrete Type defined in the client.
- k8s go client의 패키지 형태로 제공 https://pkg.go.dev/k8s.io/client-go/dynamic
- 원본 코드: https://github.com/cloud-native-skunkworks/dynamic-informer
더 자세한 내용은 https://blog.dsb.dev/posts/creating-dynamic-informers/ 서 확인할 수 있다.
Go: Creating Dynamic Kubernetes Informers
Introduction Recently, I published v1.0.0 of Kollect, a dynamic Kubernetes informer that publishes changes in cluster resources to a configurable event bus. At the heart of this project is a dynamic informer, a method of handling add/update/delete notifica
blog.dsb.dev