Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

support for restricting k8s discovery with exclusions #4

Open
gberche-orange opened this issue Oct 18, 2024 · 0 comments
Open

support for restricting k8s discovery with exclusions #4

gberche-orange opened this issue Oct 18, 2024 · 0 comments

Comments

@gberche-orange
Copy link

Expected behavior

As a coroot user,
In order to support large mutualized k8s clusters, with many nodes and pods
I need to be able to add some exclusions to the k8s discovery (by node selector, or pod selectors)

Currently, As a 1st step I'm considering not deploying coroot agent on some nodes through
https://github.com/coroot/helm-charts/blob/e9067ce3d486d17f73391b093b8b8c1cd2588944/charts/coroot/templates/cluster-agent.yaml#L109-L119

Current behavior

Coroot agent seems to watch for all pods without possible exclusion

func (k8s *K8S) start() {
watcher := cache.NewListWatchFromClient(k8s.client.CoreV1().RESTClient(), "pods", metav1.NamespaceAll, fields.Everything())
_, informer := cache.NewInformer(watcher, &corev1.Pod{}, 0, cache.ResourceEventHandlerFuncs{
AddFunc: func(obj interface{}) {
pod := podFromObj(obj)
if !pod.Running() {
return
}
k8s.lock.Lock()
defer k8s.lock.Unlock()
k8s.pods[pod.Id] = pod
k8s.sendEvent(PodEvent{Type: PodEventTypeAdd, Curr: pod})
},
UpdateFunc: func(oldObj, newObj interface{}) {
pod := podFromObj(newObj)
prev := podFromObj(oldObj)
if !pod.Running() || pod.Equal(prev) {
return
}
k8s.lock.Lock()
defer k8s.lock.Unlock()
k8s.pods[pod.Id] = pod
k8s.sendEvent(PodEvent{Type: PodEventTypeChange, Curr: pod, Prev: prev})
},
DeleteFunc: func(obj interface{}) {
pod := podFromObj(obj)
k8s.lock.Lock()
defer k8s.lock.Unlock()
delete(k8s.pods, pod.Id)
k8s.sendEvent(PodEvent{Type: PodEventTypeDelete, Curr: pod})
},
})
go informer.Run(k8s.stopCh)
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant