Questo contenuto non è disponibile nella lingua selezionata.
Chapter 9. Network policy and security
Customize network policies and security hardening measures for network observability components. By default, TLS encryption and network policies are automatically configured to secure traffic between components.
9.1. Network observability security architecture Copia collegamentoCollegamento copiato negli appunti!
Understanding how network observability components communicate helps you configure appropriate network policies and security hardening measures. Components communicate across different namespaces to collect, process, and display network flow data.
9.1.1. Components and security boundaries Copia collegamentoCollegamento copiato negli appunti!
The Network Observability Operator consists of the following components:
- Network Observability Operator
-
Runs in the
openshift-netobserv-operatornamespace. This component manages the deployment and configuration of all other network observability components. It requires egress access to the API server and ingress access for webhooks and metrics. - eBPF agents
-
Run as a
DaemonSeton each node to capture network flow data from the Linux kernel. - FlowLogs Pipeline (FLP)
-
Runs in the
netobservnamespace (configurable). This component receives flow data from the eBPF agents, enriches it with Kubernetes metadata, and forwards it to storage backends such as Loki or exports it to external systems. - Console plugin
-
Runs in the
netobservnamespace and provides the web console interface for viewing network flow data. It requires access to query the storage backend and serves content to the OpenShift web console. - Static console plugin
-
Runs in the
openshift-netobserv-operatornamespace alongside the Operator. This static plugin component serves static assets and requires ingress access from the OpenShift web console.
9.1.2. Network traffic flows Copia collegamentoCollegamento copiato negli appunti!
Understanding the network traffic flows between components helps you configure minimal network policies:
- Agent to FlowLogs Pipeline
- If not configured with Kafka, eBPF agents send flow data to the FLP over gRPC. This connection can be secured with TLS or mTLS. The default configuration uses automatic TLS with OpenShift service CA annotations.
- Agent to Kafka
- If configured with Kafka, eBPF agents send flow data to Kafka. This connection can be secured with TLS, mTLS, or Simple Authentication and Security Layer (SASL).
- FlowLogs Pipeline to Loki
- If using Loki as the storage backend, FLP sends enriched flow data to Loki over HTTP or HTTPS. When using the Loki Operator, HTTPS is enforced.
- FlowLogs Pipeline to Kafka
- If using Kafka as a buffer, FLP pulls flow data from Kafka brokers. This connection can be secured with TLS, mTLS, or SASL.
- FlowLogs Pipeline to API Server
- FLP watches Pods, Nodes, Services and other cluster data from the API Server to enrich flow data. This connection uses TLS.
- Console plugin to Loki
- The console plugin queries Loki directly to retrieve and display flow data in the web console. When using the Loki Operator, HTTPS is enforced.
- Console plugin to OpenShift web console
- The OpenShift web console loads the network observability plugin to display the network flow visualization interface.
- Network Observability Operator to API server
- The Network Observability Operator communicates with the Kubernetes API server to manage resources, watch for configuration changes, and perform reconciliation.
- All components to DNS
- All components require access to DNS for service discovery and name resolution.
9.1.3. Security model Copia collegamentoCollegamento copiato negli appunti!
The network observability security model uses the following mechanisms:
- Network policies
-
Control ingress and egress traffic for components. The Network Observability Operator can deploy network policies automatically by using the
FlowCollectorcustom resource, or you can create custom policies manually. - Automatic network policy deployment
The Network Observability Operator automatically deploys network policies at runtime. This is controlled by the
OPERATOR_NETWORK_POLICYenvironment variable in the Cluster Service Version (CSV), which defaults totrue. The StaticReconciler deploys and owns the following policies in theopenshift-netobserv-operatornamespace:- Operator network policy with egress rules for DNS, API server access, and ingress rules for webhooks and metrics endpoints
- Static plugin network policy with egress rules for DNS and ingress rules to allow the OpenShift web console to access the static plugin
Once a
FlowCollectorresource is installed, the NetPol Controller deploys network policies for the two operand namespaces (netobservandnetobserv-privilegedby default). This is controlled by thespec.networkPolicy.enablesetting inFlowCollector. These policies are automatically restored if manually deleted.- Transport Layer Security (TLS)
- Secure communications between eBPF agents and the FlowLogs Pipeline by using TLS or mutual TLS. The default configuration uses automatic TLS with zero configuration required.
- Pod Security Standards
- Network observability components follow OpenShift Container Platform pod security standards and use Security Context Constraints (SCCs) appropriately.
- Service accounts
- Each component uses dedicated service accounts with minimal required permissions following the principle of least privilege.
9.1.4. Network policy integration considerations Copia collegamentoCollegamento copiato negli appunti!
If you have installed Loki, Kafka, or any exporter in a different namespace that also has a network policy, you must ensure that the network observability components can communicate with them. Consider the following integration points when configuring network policies:
-
Connection to Loki (as defined in the
FlowCollectorCRspec.lokiparameter) -
Connection to Kafka (as defined in the
FlowCollectorCRspec.kafkaparameter) -
Connection to any exporter (as defined in the
FlowCollectorCRspec.exportersparameter) -
Connection to external object storage (as defined in your
LokiStackrelatedSecret) when using Loki
9.2. Configure network policy by using the FlowCollector custom resource Copia collegamentoCollegamento copiato negli appunti!
Configure ingress and egress network policies to control pod traffic for network observability components. Network policies enhance security, reduce noise, support compliance, and improve visibility into network communication.
You can configure the FlowCollector custom resource (CR) to deploy network policies for network observability. By default, network policy management is enabled.
Prerequisites
- You have installed the Network Observability Operator.
- You have cluster administrator permissions.
Procedure
-
In the web console, go to Ecosystem
Installed Operators page. - Under the Provided APIs heading for Network Observability, select Flow Collector.
- Select cluster then select the YAML tab.
Configure the
FlowCollectorCR. A sample configuration is as follows:Example
FlowCollectorCR for network policyapiVersion: flows.netobserv.io/v1beta2 kind: FlowCollector metadata: name: cluster spec: namespace: netobserv networkPolicy: enable: true additionalNamespaces: ["my-kafka-exporter"] # ...where:
spec.networkPolicy.enable-
Specifies whether to enable network policy management. The default value is
true. spec.networkPolicy.additionalNamespaces-
Specifies additional namespaces to include in the network policy. Use this parameter to add namespaces where flows are exported. For example, if you configured
spec.exportersto a Kafka broker in a namespace such asmy-kafka-exporter, you should include that namespace in the list.
9.3. Configure secure communications between the agent and the FlowLogs Pipeline Copia collegamentoCollegamento copiato negli appunti!
Configure Transport Layer Security (TLS) or mutual TLS (mTLS) to secure communications between eBPF agents and the FlowLogs Pipeline.
By default, communications are secured automatically by using OpenShift service Certificate Authority (CA) annotations with zero configuration required.
The following example demonstrates how to provide your own certificates rather than relying on automatic TLS configuration. This configuration applies only when the deployment model is set to Service mode.
Prerequisites
- You have installed the Network Observability Operator.
- You have cluster administrator permissions.
Procedure
-
In the web console, go to Ecosystem
Installed Operators page. - Under the Provided APIs heading for Network Observability, select Flow Collector.
- Select cluster then select the YAML tab.
Configure the
FlowCollectorCR for agent TLS settings. A sample configuration is as follows:Example
FlowCollectorCR for provided certificates modeapiVersion: flows.netobserv.io/v1beta2 kind: FlowCollector metadata: name: cluster spec: processor: service: tlsType: Provided providedCertificates: caFile: type: configmap name: my-ca-configmap file: service-ca.crt serverCert: type: secret name: my-server-cert-secret certFile: tls.crt certKey: tls.key clientCert: {} # ...where:
spec.processor.service.tlsType-
Specifies the TLS configuration mode. The default value,
Auto, secures communications automatically by using OpenShift service CA annotations with zero configuration required.Disabledturns off TLS encryption; use only in development or testing environments.Providedlets you supply your own certificates for TLS or mutual TLS by using thecaFile,serverCert, andclientCertfields. WhenclientCertis omitted, TLS is configured rather than mTLS spec.processor.service.providedCertificates.caFile.type-
Specifies how the CA certificate is provided. Valid values are
configmaporsecret. spec.processor.service.providedCertificates.caFile.name-
Name of the
configmaporsecret. spec.processor.service.providedCertificates.caFile.file-
Name of the CA file within the
configmaporsecret. spec.processor.service.providedCertificates.serverCert.type-
Specifies how the server (FLP) certificate is provided for both TLS and mutual TLS. Valid values are
configmaporsecret. spec.processor.service.providedCertificates.serverCert.name-
Name of the
configmaporsecret. spec.processor.service.providedCertificates.serverCert.certFile-
Name of the server certificate file within the
configmaporsecret. spec.processor.service.providedCertificates.serverCert.certKey-
Name of the server certificate key file within the
configmaporsecret. spec.processor.service.providedCertificates.clientCert.type-
Specifies how the client (eBPF Agent) certificate is provided when using mutual TLS. Valid values are
configmaporsecret. spec.processor.service.providedCertificates.clientCert.name-
Name of the
configmaporsecret. spec.processor.service.providedCertificates.clientCert.certFile-
Name of the client certificate file within the
configmaporsecret. spec.processor.service.providedCertificates.clientCert.certKey-
Name of the client certificate key file within the
configmaporsecret.
Verification
After configuring TLS, verify that the agents are communicating securely with FLP by running the following command:
$ oc logs -n netobserv-privileged ds/netobserv-ebpf-agent | grep -i "starting grpc"Example output
time="2026-09-30T07:19:14Z" level=info msg="Starting GRPC client with TLS" component=grpc.ClientNoteUsing the
Automode provides the best balance of security and ease of use for most deployments. Consider usingProvidedmode only if you have specific certificate requirements or are integrating with an existing Public Key Infrastructure (PKI).When using mutual TLS (mTLS) with the
Providedmode, both the CA certificate and user certificate must be configured. The FLP verifies the agent certificate, and the agent verifies the FLP certificate.
9.4. Example NetworkPolicy manifests for network observability Copia collegamentoCollegamento copiato negli appunti!
You can use these example NetworkPolicy manifests as a starting point for securing network observability components. Customize these examples based on your specific environment and security requirements.
These examples provide a foundation for securing network observability. You might need to add additional egress rules for Kafka exporters, external storage, or other integrations based on your specific deployment.
For security best practices, avoid using allow-all CIDR rules such as 0.0.0.0/0 or ::/0 in network policies. Instead, use specific namespace selectors and pod selectors to limit traffic to only required destinations.
9.4.1. Default deny policy for the netobserv namespace Copia collegamentoCollegamento copiato negli appunti!
This policy sets a default deny for all ingress and egress traffic in the netobserv namespace. Apply this first, then add specific allow policies for required traffic.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: default-deny
namespace: netobserv
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
9.4.2. Allow DNS for all pods Copia collegamentoCollegamento copiato negli appunti!
This policy allows all pods in the netobserv namespace to access DNS for name resolution.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-to-dns
namespace: netobserv
spec:
podSelector: {}
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-dns
ports:
- protocol: TCP
port: 5353
- protocol: UDP
port: 5353
policyTypes:
- Egress
9.4.3. Allow FlowLogs pipeline to access Loki Copia collegamentoCollegamento copiato negli appunti!
This policy allows the FlowLogs Pipeline to send flow data to Loki.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-flp-to-loki
namespace: netobserv
spec:
podSelector:
matchLabels:
app: flowlogs-pipeline
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-netobserv
ports:
- protocol: TCP
port: 3100
policyTypes:
- Egress
where:
kubernetes.io/metadata.name: openshift-netobserv- Replace with the namespace where Loki is deployed in your environment.
port: 3100- Adjust the port number if Loki uses a different port.
9.4.4. Allow console plugin to query Loki Copia collegamentoCollegamento copiato negli appunti!
This policy allows the console plugin to query Loki for displaying flow data in the web console.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-plugin-to-loki
namespace: netobserv
spec:
podSelector:
matchLabels:
app: netobserv-plugin
egress:
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-netobserv
ports:
- protocol: TCP
port: 3100
policyTypes:
- Egress
where:
kubernetes.io/metadata.name: openshift-netobserv- Replace with the namespace where Loki is deployed in your environment.
port: 3100- Adjust the port number if Loki uses a different port.
9.4.5. Allow console plugin ingress from OpenShift web console Copia collegamentoCollegamento copiato negli appunti!
This policy allows the OpenShift Console to access the Network Observability console plugin.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-console-to-plugin
namespace: netobserv
spec:
podSelector:
matchLabels:
app: netobserv-plugin
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-console
ports:
- protocol: TCP
port: 9001
policyTypes:
- Ingress
9.4.6. Allow metrics scraping from monitoring Copia collegamentoCollegamento copiato negli appunti!
This policy allows Prometheus in the openshift-monitoring namespace to scrape metrics from network observability components.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-metrics-scraping
namespace: netobserv
spec:
podSelector:
matchLabels:
app: flowlogs-pipeline
ingress:
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-monitoring
ports:
- protocol: TCP
port: 9102
policyTypes:
- Ingress
where:
app: flowlogs-pipeline- Adjust the label selector to match your component. Apply similar policies for other components that expose metrics.
port: 9102- Adjust the port number based on your metrics endpoint configuration.
9.4.7. Allow agent to FlowLogs pipeline communication Copia collegamentoCollegamento copiato negli appunti!
This policy allows eBPF agents running on nodes to send flow data to the FlowLogs Pipeline.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: allow-agents-to-flp
namespace: netobserv
spec:
podSelector:
matchLabels:
app: flowlogs-pipeline
ingress:
- from:
- namespaceSelector:
matchLabels:
policy-group.network.openshift.io/host-network: ""
ports:
- protocol: TCP
port: 2055
policyTypes:
- Ingress
where:
policy-group.network.openshift.io/host-network: ""- This namespace selector allows traffic from host-networked pods, which includes the eBPF agents.
port: 2055- Adjust the port number based on your FlowCollector configuration for agent-to-FLP communication.
9.4.8. Complete example for standard deployment Copia collegamentoCollegamento copiato negli appunti!
This example combines multiple policies for a standard Network Observability Operator deployment with Loki storage.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: netobserv-policies
namespace: netobserv
spec:
podSelector: {}
policyTypes:
- Ingress
- Egress
egress:
# Allow DNS
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-dns
ports:
- protocol: TCP
port: 5353
- protocol: UDP
port: 5353
# Allow access to Loki
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-netobserv
ports:
- protocol: TCP
port: 3100
ingress:
# Allow from OpenShift Console
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-console
ports:
- protocol: TCP
port: 9001
# Allow from monitoring
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-monitoring
ports:
- protocol: TCP
port: 9102
# Allow from agents
- from:
- namespaceSelector:
matchLabels:
policy-group.network.openshift.io/host-network: ""
ports:
- protocol: TCP
port: 2055
9.4.9. Operator network policy Copia collegamentoCollegamento copiato negli appunti!
This example shows the automatically deployed network policy for the Network Observability Operator in the openshift-netobserv-operator namespace. This policy is deployed by the StaticReconciler when OPERATOR_NETWORK_POLICY is set to true in the CSV.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: netobserv-operator
namespace: openshift-netobserv-operator
spec:
podSelector:
matchLabels:
app: netobserv-operator
policyTypes:
- Ingress
- Egress
egress:
# Allow DNS
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-dns
ports:
- protocol: TCP
port: 5353
- protocol: UDP
port: 5353
# Allow API server access
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: default
ports:
- protocol: TCP
port: 6443
ingress:
# Allow webhooks
- from:
- namespaceSelector: {}
ports:
- protocol: TCP
port: 9443
# Allow metrics scraping
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-monitoring
ports:
- protocol: TCP
port: 8443
where:
app: netobserv-operator- Pod selector that targets the Network Observability Operator pods.
port: 6443- API server port for Kubernetes API access.
port: 9443- Webhook server port for admission webhooks.
port: 8443- Metrics endpoint port for Prometheus scraping.
9.4.10. Static plugin network policy Copia collegamentoCollegamento copiato negli appunti!
This example shows the automatically deployed network policy for the static console plugin in the openshift-netobserv-operator namespace. This policy is deployed by the StaticReconciler when OPERATOR_NETWORK_POLICY is set to true in the CSV.
apiVersion: networking.k8s.io/v1
kind: NetworkPolicy
metadata:
name: netobserv-plugin-static
namespace: openshift-netobserv-operator
spec:
podSelector:
matchLabels:
app: netobserv-plugin-static
policyTypes:
- Ingress
- Egress
egress:
# Allow DNS
- to:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-dns
ports:
- protocol: TCP
port: 5353
- protocol: UDP
port: 5353
ingress:
# Allow OpenShift Console to access static plugin
- from:
- namespaceSelector:
matchLabels:
kubernetes.io/metadata.name: openshift-console
ports:
- protocol: TCP
port: 9443
where:
app: netobserv-plugin-static- Pod selector that targets the static console plugin pods.
port: 9443- Static plugin server port for serving static assets to the OpenShift web console.