Skip to content

Commit 326ff55

Browse files
feedback addressed
1 parent 79953b0 commit 326ff55

19 files changed

Lines changed: 1011 additions & 18 deletions

api/flowcollector/v1beta2/flowcollector_types.go

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -736,13 +736,78 @@ type FlowCollectorFLP struct {
736736
// +optional
737737
Service *ProcessorServiceConfig `json:"service,omitempty"`
738738

739+
// `informers` configuration for centralized Kubernetes informers that push cache updates to flowlogs-pipeline processors.
740+
// This reduces load on the Kubernetes API server by having a single component (flp-informers) query the API instead of N FLP processors.
741+
// When enabled, a dedicated `flp-informers` deployment is created that watches Kubernetes resources and pushes updates via gRPC.
742+
// +optional
743+
Informers *FlowCollectorInformers `json:"informers,omitempty"`
744+
739745
// `advanced` allows setting some aspects of the internal configuration of the flow processor.
740746
// This section is aimed mostly for debugging and fine-grained performance optimizations,
741747
// such as `GOGC` and `GOMAXPROCS` environment variables. Set these values at your own risk.
742748
// +optional
743749
Advanced *AdvancedProcessorConfig `json:"advanced,omitempty"`
744750
}
745751

752+
// `FlowCollectorInformers` defines the configuration for centralized Kubernetes informers
753+
type FlowCollectorInformers struct {
754+
// `enabled` controls whether to deploy centralized Kubernetes informers.
755+
// When `true`, a dedicated `flp-informers` deployment watches K8s resources and pushes cache updates via gRPC to FLP processors.
756+
// When `false`, each FLP processor uses local informers (previous behavior).
757+
// +kubebuilder:default:=true
758+
Enabled *bool `json:"enabled,omitempty"`
759+
760+
// `replicas` defines the number of replicas for the flp-informers deployment.
761+
// For high availability, a minimum of 2 replicas is required when `enabled` is `true`.
762+
// +kubebuilder:validation:Minimum=1
763+
// +kubebuilder:default:=2
764+
Replicas *int32 `json:"replicas,omitempty"`
765+
766+
// `resources` are the compute resources required by the informers container.
767+
// For more information, see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
768+
// +kubebuilder:default:={requests:{memory:"128Mi",cpu:"50m"},limits:{memory:"256Mi",cpu:"200m"}}
769+
// +optional
770+
Resources corev1.ResourceRequirements `json:"resources,omitempty" protobuf:"bytes,8,opt,name=resources"`
771+
772+
// `advanced` allows setting some technical parameters of the informers component.
773+
// +optional
774+
Advanced *AdvancedInformersConfig `json:"advanced,omitempty"`
775+
}
776+
777+
// `AdvancedInformersConfig` defines advanced configuration for the informers component
778+
type AdvancedInformersConfig struct {
779+
// `resyncInterval` defines the interval in seconds to rediscover processors and sync state.
780+
// +kubebuilder:validation:Minimum=1
781+
// +kubebuilder:default:=60
782+
// +optional
783+
ResyncInterval *int `json:"resyncInterval,omitempty"`
784+
785+
// `batchSize` defines the maximum number of cache entries to send in a single update batch.
786+
// +kubebuilder:validation:Minimum=1
787+
// +kubebuilder:default:=100
788+
// +optional
789+
BatchSize *int `json:"batchSize,omitempty"`
790+
791+
// `sendTimeout` defines the timeout in seconds for sending updates to processors.
792+
// +kubebuilder:validation:Minimum=1
793+
// +kubebuilder:default:=10
794+
// +optional
795+
SendTimeout *int `json:"sendTimeout,omitempty"`
796+
797+
// `updateBufferSize` defines the size of the internal update channel buffer.
798+
// +kubebuilder:validation:Minimum=1
799+
// +kubebuilder:default:=100
800+
// +optional
801+
UpdateBufferSize *int `json:"updateBufferSize,omitempty"`
802+
803+
// `processorPort` defines the gRPC port where flowlogs-pipeline processors listen for k8s cache updates.
804+
// +kubebuilder:validation:Minimum=1
805+
// +kubebuilder:validation:Maximum=65535
806+
// +kubebuilder:default:=9090
807+
// +optional
808+
ProcessorPort *int32 `json:"processorPort,omitempty"`
809+
}
810+
746811
type FLPDeduperMode string
747812

748813
const (

api/flowcollector/v1beta2/flowcollector_validation_webhook.go

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -261,6 +261,7 @@ func (v *validator) validateFLP() {
261261
v.validateFLPAlerts()
262262
v.validateFLPMetricsForAlerts()
263263
v.validateFLPTLS()
264+
v.validateInformers()
264265
}
265266

266267
func (v *validator) validateScheduling() {
@@ -456,6 +457,29 @@ func (v *validator) validateFLPTLS() {
456457
}
457458
}
458459

460+
func (v *validator) validateInformers() {
461+
if v.fc.Processor.Informers == nil {
462+
return
463+
}
464+
465+
// Check if enabled
466+
enabled := v.fc.Processor.Informers.Enabled != nil && *v.fc.Processor.Informers.Enabled
467+
468+
if enabled {
469+
// When enabled, replicas must be at least 2 for high availability
470+
replicas := int32(2) // default
471+
if v.fc.Processor.Informers.Replicas != nil {
472+
replicas = *v.fc.Processor.Informers.Replicas
473+
}
474+
if replicas < 2 {
475+
v.errors = append(
476+
v.errors,
477+
fmt.Errorf("spec.processor.informers.replicas must be at least 2 when informers are enabled (got %d). Centralized informers require high availability to avoid losing the entire flow collection pipeline in case of failure", replicas),
478+
)
479+
}
480+
}
481+
}
482+
459483
func GetFirstRequiredMetrics(anyRequired, actual []string) string {
460484
for _, m := range anyRequired {
461485
if slices.Contains(actual, m) {

api/flowcollector/v1beta2/zz_generated.deepcopy.go

Lines changed: 76 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

bundle/manifests/flows.netobserv.io_flowcollectors.yaml

Lines changed: 127 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5499,6 +5499,133 @@ spec:
54995499
- Always
55005500
- Never
55015501
type: string
5502+
informers:
5503+
description: |-
5504+
`informers` configuration for centralized Kubernetes informers that push cache updates to flowlogs-pipeline processors.
5505+
This reduces load on the Kubernetes API server by having a single component (flp-informers) query the API instead of N FLP processors.
5506+
When enabled, a dedicated `flp-informers` deployment is created that watches Kubernetes resources and pushes updates via gRPC.
5507+
properties:
5508+
advanced:
5509+
description: '`advanced` allows setting some technical parameters
5510+
of the informers component.'
5511+
properties:
5512+
batchSize:
5513+
default: 100
5514+
description: '`batchSize` defines the maximum number of
5515+
cache entries to send in a single update batch.'
5516+
minimum: 1
5517+
type: integer
5518+
processorPort:
5519+
default: 9090
5520+
description: '`processorPort` defines the gRPC port where
5521+
flowlogs-pipeline processors listen for k8s cache updates.'
5522+
format: int32
5523+
maximum: 65535
5524+
minimum: 1
5525+
type: integer
5526+
resyncInterval:
5527+
default: 60
5528+
description: '`resyncInterval` defines the interval in
5529+
seconds to rediscover processors and sync state.'
5530+
minimum: 1
5531+
type: integer
5532+
sendTimeout:
5533+
default: 10
5534+
description: '`sendTimeout` defines the timeout in seconds
5535+
for sending updates to processors.'
5536+
minimum: 1
5537+
type: integer
5538+
updateBufferSize:
5539+
default: 100
5540+
description: '`updateBufferSize` defines the size of the
5541+
internal update channel buffer.'
5542+
minimum: 1
5543+
type: integer
5544+
type: object
5545+
enabled:
5546+
default: true
5547+
description: |-
5548+
`enabled` controls whether to deploy centralized Kubernetes informers.
5549+
When `true`, a dedicated `flp-informers` deployment watches K8s resources and pushes cache updates via gRPC to FLP processors.
5550+
When `false`, each FLP processor uses local informers (previous behavior).
5551+
type: boolean
5552+
replicas:
5553+
default: 2
5554+
description: |-
5555+
`replicas` defines the number of replicas for the flp-informers deployment.
5556+
For high availability, a minimum of 2 replicas is required when `enabled` is `true`.
5557+
format: int32
5558+
minimum: 1
5559+
type: integer
5560+
resources:
5561+
default:
5562+
limits:
5563+
cpu: 200m
5564+
memory: 256Mi
5565+
requests:
5566+
cpu: 50m
5567+
memory: 128Mi
5568+
description: |-
5569+
`resources` are the compute resources required by the informers container.
5570+
For more information, see https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
5571+
properties:
5572+
claims:
5573+
description: |-
5574+
Claims lists the names of resources, defined in spec.resourceClaims,
5575+
that are used by this container.
5576+
5577+
This field depends on the
5578+
DynamicResourceAllocation feature gate.
5579+
5580+
This field is immutable. It can only be set for containers.
5581+
items:
5582+
description: ResourceClaim references one entry in PodSpec.ResourceClaims.
5583+
properties:
5584+
name:
5585+
description: |-
5586+
Name must match the name of one entry in pod.spec.resourceClaims of
5587+
the Pod where this field is used. It makes that resource available
5588+
inside a container.
5589+
type: string
5590+
request:
5591+
description: |-
5592+
Request is the name chosen for a request in the referenced claim.
5593+
If empty, everything from the claim is made available, otherwise
5594+
only the result of this request.
5595+
type: string
5596+
required:
5597+
- name
5598+
type: object
5599+
type: array
5600+
x-kubernetes-list-map-keys:
5601+
- name
5602+
x-kubernetes-list-type: map
5603+
limits:
5604+
additionalProperties:
5605+
anyOf:
5606+
- type: integer
5607+
- type: string
5608+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
5609+
x-kubernetes-int-or-string: true
5610+
description: |-
5611+
Limits describes the maximum amount of compute resources allowed.
5612+
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
5613+
type: object
5614+
requests:
5615+
additionalProperties:
5616+
anyOf:
5617+
- type: integer
5618+
- type: string
5619+
pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$
5620+
x-kubernetes-int-or-string: true
5621+
description: |-
5622+
Requests describes the minimum amount of compute resources required.
5623+
If Requests is omitted for a container, it defaults to Limits if that is explicitly specified,
5624+
otherwise to an implementation-defined value. Requests cannot exceed Limits.
5625+
More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
5626+
type: object
5627+
type: object
5628+
type: object
55025629
kafkaConsumerAutoscaler:
55035630
description: |-
55045631
`kafkaConsumerAutoscaler` [deprecated (*)] is the spec of a horizontal pod autoscaler to set up for `flowlogs-pipeline-transformer`, which consumes Kafka messages.

bundle/manifests/netobserv-informers_rbac.authorization.k8s.io_v1_clusterrole.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,3 +32,12 @@ rules:
3232
- get
3333
- list
3434
- watch
35+
- apiGroups:
36+
- coordination.k8s.io
37+
resources:
38+
- leases
39+
verbs:
40+
- create
41+
- get
42+
- list
43+
- update

0 commit comments

Comments
 (0)