Skip to main content
Redhat Developers  Logo
  • Products

    Featured

    • Red Hat Enterprise Linux
      Red Hat Enterprise Linux Icon
    • Red Hat OpenShift AI
      Red Hat OpenShift AI
    • Red Hat Enterprise Linux AI
      Linux icon inside of a brain
    • Image mode for Red Hat Enterprise Linux
      RHEL image mode
    • Red Hat OpenShift
      Openshift icon
    • Red Hat Ansible Automation Platform
      Ansible icon
    • Red Hat Developer Hub
      Developer Hub
    • View All Red Hat Products
    • Linux

      • Red Hat Enterprise Linux
      • Image mode for Red Hat Enterprise Linux
      • Red Hat Universal Base Images (UBI)
    • Java runtimes & frameworks

      • JBoss Enterprise Application Platform
      • Red Hat build of OpenJDK
    • Kubernetes

      • Red Hat OpenShift
      • Microsoft Azure Red Hat OpenShift
      • Red Hat OpenShift Virtualization
      • Red Hat OpenShift Lightspeed
    • Integration & App Connectivity

      • Red Hat Build of Apache Camel
      • Red Hat Service Interconnect
      • Red Hat Connectivity Link
    • AI/ML

      • Red Hat OpenShift AI
      • Red Hat Enterprise Linux AI
    • Automation

      • Red Hat Ansible Automation Platform
      • Red Hat Ansible Lightspeed
    • Developer tools

      • Red Hat Trusted Software Supply Chain
      • Podman Desktop
      • Red Hat OpenShift Dev Spaces
    • Developer Sandbox

      Developer Sandbox
      Try Red Hat products and technologies without setup or configuration fees for 30 days with this shared Openshift and Kubernetes cluster.
    • Try at no cost
  • Technologies

    Featured

    • AI/ML
      AI/ML Icon
    • Linux
      Linux Icon
    • Kubernetes
      Cloud icon
    • Automation
      Automation Icon showing arrows moving in a circle around a gear
    • View All Technologies
    • Programming Languages & Frameworks

      • Java
      • Python
      • JavaScript
    • System Design & Architecture

      • Red Hat architecture and design patterns
      • Microservices
      • Event-Driven Architecture
      • Databases
    • Developer Productivity

      • Developer productivity
      • Developer Tools
      • GitOps
    • Secure Development & Architectures

      • Security
      • Secure coding
    • Platform Engineering

      • DevOps
      • DevSecOps
      • Ansible automation for applications and services
    • Automated Data Processing

      • AI/ML
      • Data Science
      • Apache Kafka on Kubernetes
      • View All Technologies
    • Start exploring in the Developer Sandbox for free

      sandbox graphic
      Try Red Hat's products and technologies without setup or configuration.
    • Try at no cost
  • Learn

    Featured

    • Kubernetes & Cloud Native
      Openshift icon
    • Linux
      Rhel icon
    • Automation
      Ansible cloud icon
    • Java
      Java icon
    • AI/ML
      AI/ML Icon
    • View All Learning Resources

    E-Books

    • GitOps Cookbook
    • Podman in Action
    • Kubernetes Operators
    • The Path to GitOps
    • View All E-books

    Cheat Sheets

    • Linux Commands
    • Bash Commands
    • Git
    • systemd Commands
    • View All Cheat Sheets

    Documentation

    • API Catalog
    • Product Documentation
    • Legacy Documentation
    • Red Hat Learning

      Learning image
      Boost your technical skills to expert-level with the help of interactive lessons offered by various Red Hat Learning programs.
    • Explore Red Hat Learning
  • Developer Sandbox

    Developer Sandbox

    • Access Red Hat’s products and technologies without setup or configuration, and start developing quicker than ever before with our new, no-cost sandbox environments.
    • Explore Developer Sandbox

    Featured Developer Sandbox activities

    • Get started with your Developer Sandbox
    • OpenShift virtualization and application modernization using the Developer Sandbox
    • Explore all Developer Sandbox activities

    Ready to start developing apps?

    • Try at no cost
  • Blog
  • Events
  • Videos

Monitor OVN networking events using Network Observability

November 19, 2024
Mohamed Mahmoud
Related topics:
LinuxObservability
Related products:
Red Hat OpenShiftRed Hat OpenShift Container Platform

Share:

    Network security and performance maintenance crucially depend on monitoring network events triggered by Open Virtual Network (OVN), including network policies, admin network policies, and egress firewalls. You can achieve this using Network Observability eBPF agent, which runs in the Linux kernel and can trace various network activities with minimal performance overhead, allowing you to observe and capture detailed information about network traffic and events in real-time.

    Key components

    The following are key components for Network Observability with eBPF:

    1. eBPF network events monitoring kprobe eBPF hook: Network events monitoring using eBPF kernel probes (kprobes) provides deep, kernel-level insights into network stack behavior. The NetObserv eBPF agent leverages the entry point to efficiently capture packet metadata and identify policy violations with minimal overhead. The hook implemented in the NetObserv eBPF agent can capture multiple events within the same network flow and generate a list of network events that applied to that flow, with a limit of up to four events per flow.
    2. ovn-kubernetes observability library: The eBPF agent captures network events as an array of bytes, which is not very user-friendly. This library provides functionality to convert these events into human-readable strings, making them easily understandable for customers.

    Use cases for Network Observability with eBPF

    Below are specific use cases for Network Observability with eBPF.

    Monitor network policies

    When you apply OVN network policies (like Kubernetes NetworkPolicy), eBPF agent can monitor allowed and/or blocked traffic, detecting whether packets are allowed or blocked based on network policies.

    An example of these network policies is as follows:

    kind: NetworkPolicy
    apiVersion: networking.k8s.io/v1
    metadata:
      name: iperf3-server-access-ingress
      namespace: iperf
    spec:
      podSelector:
        matchLabels:
          app: iperf3-server
      ingress:
      - ports:
        - port: 5501
        from:
        - podSelector:
            matchLabels:
              app: iperf3-client
    ---
    kind: NetworkPolicy
    apiVersion: networking.k8s.io/v1
    metadata:
      name: iperf3-server-access-egress
      namespace: iperf
    spec:
      podSelector:
        matchLabels:
          app: iperf3-client
      egress:
      - ports:
        - port: 5201
          protocol: TCP
      podSelector: {}
      policyTypes:
      - Egress

    Figure 1 depicts the traffic flows in the NetObserv console plug-in. A network events column shows traffic allowed or denied by network policy rules.

    creen capture of the traffic flows in the NetObserv console plug-in with a network events column showing traffic allowed or denied by network policy rules.
    Figure 1: Screen capture of the traffic flows in the NetObserv console plug-in with a network events column showing traffic allowed or denied by network policy rules.

    Monitor AdminNetworkPolicies

    An AdminNetworkPolicy is a high-level security policy designed to provide cluster administrators with more control over network traffic in Kubernetes environments.
    eBPF agent can monitor allowed/blocked traffic, detecting whether packets are allowed or blocked based on admin network policies.

    An example of AdminNetworkPolicy and egress NetworkPolicy to show multiple events use case:

    apiVersion: policy.networking.k8s.io/v1alpha1
    kind: AdminNetworkPolicy
    metadata:
      name: allow-egress-iperf
    spec:
      egress:
      - action: Pass
        to:
        - namespaces: {}
      priority: 10
      subject:
        namespaces:
          matchLabels:
            kubernetes.io/metadata.name: iperf
    ---
    kind: NetworkPolicy
    apiVersion: networking.k8s.io/v1
    metadata:
      name: iperf3-server-access-egress
      namespace: iperf
    spec:
      podSelector:
        matchLabels:
          app: iperf3-client
      egress:
      - ports:
        - port: 5201
          protocol: TCP
      podSelector: {}
      policyTypes:
      - Egress

    Figure 2 shows the traffic flows in the NetObserv console plug-in, with a network events column showing the delegation by the admin policy resulting in traffic allowed or denied.

    Screen capture of the traffic flows in the NetObserv console plug-in, with a network events column showing the delegation by the admin policy resulting in traffic allowed or denied.
    Figure 2: Screen capture of the traffic flows in the NetObserv console plug-in, with a network events column showing the delegation by the admin policy resulting in traffic allowed or denied.

    Monitor egress firewall traffic

    For egress firewall monitoring, the eBPF agent can trace outbound traffic and see whether it adheres to egress firewall rules, detecting unauthorized outbound connections and flag outbound traffic that violates egress firewall rules.

    In the following example, there are three events, one for NetworkPolicy, another for AdminNetworkPolicy, and the third for EgressFirewall:

    apiVersion: k8s.ovn.org/v1
    kind: EgressFirewall
    metadata:
      name: default
      namespace: iperf
    spec:
      egress:
      - to:
          cidrSelector: 8.8.8.8/24
        type: Allow
      - to:
          cidrSelector: 0.0.0.0/0
        type: Deny
    ---
    apiVersion: policy.networking.k8s.io/v1alpha1
    kind: AdminNetworkPolicy
    metadata:
      name: allow-egress-iperf
    spec:
      egress:
      - action: Pass
        to:
        - namespaces: {}
      priority: 10
      subject:
        namespaces:
          matchLabels:
            kubernetes.io/metadata.name: iperf
    ---
    kind: NetworkPolicy
    apiVersion: networking.k8s.io/v1
    metadata:
      name: iperf3-server-access-egress
      namespace: iperf
    spec:
      podSelector:
        matchLabels:
          app: iperf3-client
      egress:
      - ports:
        - port: 5201
          protocol: TCP
      podSelector: {}
      policyTypes:
      - Egress

    Figure 3 displays the traffic flows in the NetObserv console plug-in. A network events column shows traffic allowed or denied by egress firewall rules.

    Screen capture of the traffic flows in the NetObserv console plug-in, with a network events column showing traffic allowed or denied by egress firewall rules.
    Figure 3: Screen capture of the traffic flows in the NetObserv console plug-in, with a network events column showing traffic allowed or denied by egress firewall rules.

    Integration with the Network Observability stack

    The following are integrated into the Network Observability stack:

    • eBPF agent: The eBPF agent manages a new kprobe hook through a configuration option. It also registers with the OVN observability library, allowing eBPF-generated events to be enriched into meaningful strings.
    • Agent user space: The agent user space handles the aggregation of the network events.
    • Flowlogs pipeline: Generated flows are transmitted over gRPC to the flowlogs-pipeline, where the flow's content is enriched with Kubernetes metadata.
    • Loki storage and console plug-in: The enriched flows are then sent to Loki storage, making them available for consumption by the NetObserv console plug-in. The new events are displayed in the console.
    • New filtering capability: A new filter is introduced to filter flows based on network events enrichment.

    Figure 4 depicts the Network Observability stack.

    Network Observability stack.
    Figure 4: Network Observability stack.

    Configuration

    Enable the OVNObservability feature in the FeatureGate custom resource:

    $ oc edit featuregates.config.openshift.io cluster
    spec:
     featureSet: TechPreviewNoUpgrade
    enabled:
    - name: OVNObservability

    Note

    The above FeatureGate might be on by default at the time this feature becomes generally available (GA).

    Enable NetworkEvents in the Network Observability FlowCollector custom resource:

    apiVersion: flows.netobserv.io/v1beta2
    kind: FlowCollector
    metadata:
      name: cluster
    spec:
      agent:
        type: eBPF
        ebpf:
          sampling: 1
          privileged: true
          features:
          - "NetworkEvents"

    Note

    • In the above example we set sampling to 1 to be able to capture all network events without missing any.
    • privileged is set to true because the OVN observability library needs to access local OVS socket and OVN databases.

    Availability

    The networking events monitoring feature is available in Developer Preview for Red Hat OpenShift Container Platform 4.17 z-stream and NetObserv release 1.7.

    Conclusion

    Relying on eBPF technology for network observability, particularly in environments governed by OVN network policies and egress firewalls, offers deep, real-time insights into network traffic. Users can monitor policy compliance, detect violations, and track detailed network flows. This helps you maintain a secure, high-performing network environment.

    Feedback

    We hope you liked this article! NetObserv is an open source project available on GitHub. Feel free to share your ideas ideas, use cases, or ask the community for help.

    OSZAR »

    Related Posts

    • Network observability using TCP handshake round-trip time

    • Packet capture using Network Observability eBPF Agent

    • Network observability on demand

    • Lightweight Network Observability Operator without Loki

    Recent Posts

    • Container starting and termination order in a pod

    • More Essential AI tutorials for Node.js Developers

    • How to run a fraud detection AI model on RHEL CVMs

    • How we use software provenance at Red Hat

    • Alternatives to creating bootc images from scratch

    What’s up next?

    The Red Hat OpenShift cheat sheet presents oc commands for managing an application’s lifecycle.

    Get the cheat sheet
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Products

    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform

    Build

    • Developer Sandbox
    • Developer Tools
    • Interactive Tutorials
    • API Catalog

    Quicklinks

    • Learning Resources
    • E-books
    • Cheat Sheets
    • Blog
    • Events
    • Newsletter

    Communicate

    • About us
    • Contact sales
    • Find a partner
    • Report a website issue
    • Site Status Dashboard
    • Report a security problem

    RED HAT DEVELOPER

    Build here. Go anywhere.

    We serve the builders. The problem solvers who create careers with code.

    Join us if you’re a developer, software engineer, web designer, front-end designer, UX designer, computer scientist, architect, tester, product manager, project manager or team lead.

    Sign me up

    Red Hat legal and privacy links

    • About Red Hat
    • Jobs
    • Events
    • Locations
    • Contact Red Hat
    • Red Hat Blog
    • Inclusion at Red Hat
    • Cool Stuff Store
    • Red Hat Summit

    Red Hat legal and privacy links

    • Privacy statement
    • Terms of use
    • All policies and guidelines
    • Digital accessibility

    Report a website issue

    OSZAR »