Optimizing flowlogs-pipeline resource consumption in large clusters¶
Use the shared cache architecture to reduce Kubernetes API server load and resource consumption in large-scale flowlogs-pipeline deployments while maintaining network flow visibility.
Performance challenges in large-scale deployments¶
In large-scale deployments, each flowlogs-pipeline instance independently queries the Kubernetes API server to enrich flows with metadata, resulting in a linear increase in API queries as instances scale.
The flowlogs-pipeline component enriches network flow data with Kubernetes metadata, such as pod names, labels, and namespace information. To retrieve this metadata, each flowlogs-pipeline instance independently queries the Kubernetes API server using informers that watch for resource changes.
API server load at scale¶
In the default deployment model, the number of API queries increases linearly with the number of flowlogs-pipeline instances:
- Each
flowlogs-pipelinepod maintains separate informers for pods, nodes, services, and other Kubernetes resources. - Every informer establishes a watch connection to the API server.
- Resource updates are sent independently to each
flowlogs-pipelineinstance.
For example, in a cluster with 10 flowlogs-pipeline processor pods, the API server handles 10 times the watch connections and update notifications compared to a single instance. As you scale flowlogs-pipeline horizontally to handle increased network traffic, the API server load multiplies accordingly.
Resource consumption patterns¶
This architecture creates several performance challenges:
- Memory footprint
- Each
flowlogs-pipelineinstance maintains a full in-memory cache of all watched Kubernetes resources. In large clusters with thousands of pods and services, this cache can consume significant memory per instance. - CPU utilization
- Processing redundant API server updates and maintaining separate caches increases CPU usage across all
flowlogs-pipelinepods. - API server impact
- The cumulative load from multiple
flowlogs-pipelineinstances can degrade API server performance, potentially affecting other cluster components that depend on the API server for critical operations. - Network bandwidth
- Duplicate resource updates consume network bandwidth between the API server and
flowlogs-pipelineinstances.
These resource consumption patterns become particularly pronounced in clusters with:
- High pod churn rates where applications frequently scale up and down
- Large numbers of namespaces and services
- Multiple
flowlogs-pipelineinstances deployed to handle high network traffic volumes
How the shared cache improves cluster stability¶
The flowlogs-pipeline shared cache architecture improves cluster stability and performance in large-scale deployments by centralizing metadata retrieval.
In the default deployment model, each flowlogs-pipeline (flowlogs-pipeline) instance independently queries the Kubernetes API server to enrich network flows with cluster metadata, such as pod names and labels. At scale, this can result in a high volume of redundant requests that impact the API server performance.
When you enable the shared cache, a centralized component queries the API server and shares the cached metadata with all flowlogs-pipeline instances.
High availability with leader election¶
The shared cache architecture uses leader election to ensure continuous operation when multiple replicas are deployed. Among the cache replicas, one pod is elected as the active leader that queries the Kubernetes API server and distributes updates. The remaining replicas remain on standby.
If the leader pod fails or is terminated, the remaining replicas automatically elect a new leader, typically within seconds. During this change, flow enrichment continues using cached metadata, though new resource changes might not be reflected until the new leader is established.
The Operator enforces a minimum of 2 replicas to ensure high availability. Deploying only a single replica creates a single point of failure where flow enrichment would be lost if that pod becomes unavailable.
When to use the shared cache¶
Enable the shared cache architecture in environments with any of the following characteristics:
- High pod churn rates where applications scale often.
- Large numbers of namespaces and services.
- Many
flowlogs-pipelineinstances deployed to handle high network traffic volumes.
Considerations¶
Before modifying the shared cache configuration, consider the following trade-offs:
- Data freshness: There might be a minor delay in flow enrichment updates as metadata propagates from the API server through the cache to the
flowlogs-pipelineinstances. - Cluster-wide memory: While individual
flowlogs-pipelinepods consume fewer resources, the addition of shared cache replicas increases the total memory allocated to the network observability namespace. - Port allocation: The shared cache uses port
9402for internal gRPC communication between the informer cache proxy andflowlogs-pipelineinstances.
Reduce API server load in large clusters¶
To reduce Kubernetes API server load and optimize resource consumption in large clusters, enable the flowlogs-pipeline shared cache. The shared cache is recommended for clusters with more than 3 flowlogs-pipeline replicas, especially when API server load becomes a performance concern.
Prerequisites
- The Network Observability Operator is installed.
- Access to the cluster as a user with the
cluster-adminrole.
Procedure
-
In the OpenShift Container Platform web console, navigate to Operators → Installed Operators.
-
Select the Network Observability Operator, and then click the
FlowCollectortab. -
Click the
clusterinstance, and then click the YAML tab. -
In the
spec.processorsection, set theinformerCacheProxyconfiguration to enable the shared cache by using the following example:apiVersion: flows.netobserv.io/v1beta2 kind: FlowCollector metadata: name: cluster spec: processor: informerCacheProxy: enabled: true replicas: 2where:
spec.processor.informerCacheProxy.enabled- Set to
trueto enable the informer cache proxy. The default value isfalse. spec.processor.informerCacheProxy.replicas- Specifies the number of replicas. For high availability in production environments, the minimum is
2. The Operator enforces this requirement with leader election to prevent a single point of failure.
-
Click Save.
Verification
- Navigate to Workloads → Pods.
- Ensure that the pods beginning with
flowlogs-pipeline-informersare in the Running state. - Verify that one pod shows as the active leader by checking the pod logs for leader election messages.
- Confirm that the
flowlogs-pipelinepods remain Running and show decreased CPU and memory use in the Metrics tab.
Shared cache configuration parameters¶
Use the FlowCollector informer parameters to configure how the flowlogs-pipeline queries metadata from the Kubernetes API server, including cache settings and resource selection.
Note
The shared cache feature uses centralized Kubernetes informers. Configure this feature in the spec.processor.informerCacheProxy field of the FlowCollector custom resource.
Shared cache parameters
| Parameter | Type | Default | Description |
|---|---|---|---|
enabled |
Boolean | false |
Enables the shared cache architecture to centralize Kubernetes API metadata retrieval. When enabled, a dedicated flowlogs-pipeline-informers deployment queries the Kubernetes API server and distributes cached metadata to all flowlogs-pipeline instances through gRPC on port 9402. |
replicas |
Integer | 2 |
The number of shared cache pods to deploy. The minimum value is 2 to ensure high availability with leader election. The Operator enforces this requirement. |
resources |
Object | See FlowCollector API |
Configures CPU and memory resource requests and limits for the shared cache pods. Specify requests.cpu, requests.memory, limits.cpu, and limits.memory according to your cluster size and performance requirements. |
advanced.resyncInterval |
Duration | 60 |
The interval, in seconds, at which the informer cache proxy rediscovers flowlogs-pipeline processor pods and synchronizes their state. |
advanced.batchSize |
Integer | 100 |
The number of cache update events to batch together before sending to flowlogs-pipeline instances. Larger batches improve efficiency but increase latency for metadata updates. |
advanced.sendTimeout |
Duration | 10 |
The maximum time to wait when sending cache updates to flowlogs-pipeline instances. If a send operation exceeds this timeout, the system retries the update. |
advanced.updateBufferSize |
Integer | 100 |
The size of the internal buffer queue for cache updates. Increase this value in high-churn environments where Kubernetes resources change often. |
Resolve shared cache performance issues¶
Troubleshoot shared cache component failures by verifying pod health, reviewing system logs, and confirming leader election status to restore cluster performance.
Prerequisites
- You have installed the Network Observability Operator.
- You have access to the cluster as a user with the
cluster-adminrole. - The shared cache architecture is enabled in your
FlowCollectorconfiguration.
Procedure
-
Check the status of the shared cache pods by running the following command:
Example outputNAME READY STATUS RESTARTS AGE flowlogs-pipeline-informers-7d9f8b5c4d-abc12 1/1 Running 0 5m flowlogs-pipeline-informers-7d9f8b5c4d-xyz34 1/1 Running 0 5mEnsure all pods show
Runningstatus. If pods are inCrashLoopBackOfforErrorstatus, proceed to examine the logs. -
Identify the current leader pod:
Look for log entries indicating leader election status. Ensure that only one pod reports itself as the active leader.
-
View detailed logs from the leader pod to diagnose issues:
Common issues to look for:
- API server connection failures: Error messages indicating inability to connect to the Kubernetes API server suggest network or RBAC permission issues.
- gRPC communication errors: Messages about failed connections on port
9402indicateflowlogs-pipelineinstances cannot reach the shared cache. - Leader election conflicts: If multiple pods claim to be the leader, there might be a configuration issue with leader election.
-
Verify that
flowlogs-pipelineinstances are receiving cache updates:flowlogs-pipelinepods show successful connection messages to the shared cache on port9402. -
Check the shared cache service:
Verify that the service exists and is routing to the correct pods.
-
If the shared cache is not functioning correctly, check for RBAC permission issues:
The
ClusterRoleBindinggrants theflowlogs-pipeline-informersServiceAccountthe necessary permissions to watch Kubernetes resources.
Verification
-
After you resolve issues, complete the following verification steps:
- Confirm all shared cache pods are running and healthy.
- Verify that one pod shows as the active leader in the logs.
- Check that
flowlogs-pipelinepods successfully connect to the shared cache. - Monitor flow enrichment in the network observability console to ensure metadata is displayed correctly on network flows.
Additional resources