Further Improvements for Cilium Alerts within KAS/AgentK
The features related to Cilium Alerts within KAS/Agentk has been implemented as part of two epics:
- Initial epic: &3438 (closed)
- Follow-up epic: &5041 (closed)
As a further improvement, there are some refactoring which could be done for improving performance or simplifying logic and code complexity.
Tasks:
-
Refactor existsLabelsInEndpointSelector()
to accept theEndpointSelector
type instead of string -
Refactor Switch CiliumNetworkPolicies(ns).List(ctx, metav1.ListOptions{})
to an informer in order to avoid the expensive calls. ReplacingList
byWatch
would be helpful already.
Related source code
- GitLab K8s Agent: https://gitlab.com/gitlab-org/cluster-integration/gitlab-agent/-/tree/master/internal/module/cilium_alert/agent
- Cilium
Watch
for network policies: https://github.com/cilium/cilium/blob/v1.9/pkg/k8s/client/clientset/versioned/typed/cilium.io/v2/ciliumnetworkpolicy.go#L46 - Cilium
Informer
for network policies: https://github.com/cilium/cilium/blob/v1.9/pkg/k8s/client/informers/externalversions/cilium.io/v2/ciliumnetworkpolicy.go#L35 -
Informer
implementation from within Kubernetes: https://github.com/kubernetes/client-go/blob/master/informers/generic.go
Edited by Adam Cohen