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

Get started with the bpfman eBPF manager on OpenShift 4.16

bpfman is an open source project that makes eBPF easier to secure, manage, and use.

June 25, 2024
Andrew Stoycos
Related topics:
ContainersDevOpsLinuxKubernetesOperators
Related products:
Red Hat OpenShiftRed Hat OpenShift Container Platform

Share:

    eBPF is a low-level technology for running sandboxed kernel programs. Its use in Kubernetes-based applications has grown rapidly due to the revolutionary capabilities it enables, as demonstrated by Cloud Native Computing Foundation (CNCF) projects such as Cilium, Datadog, Calico, and Pixie. However, eBPF in Kubernetes also poses a number of new challenges for developers and administrators alike. These challenges include program lifecycle management issues, the widespread use of privileged pods, the lack of eBPF subsystem visibility, and problems with program cooperation.

    bpfman is an open source project dedicated to making eBPF easier to secure, manage, and use. The project includes an operator that allows eBPF application developers to package programs via OCI container images and deploy them via Kubernetes CustomResourceDefinitions (CRDs) such as TcPrograms and XdpPrograms. Additionally, it allows cluster administrators to tightly control which users can/can not deploy specific types of programs. 

    As of Red Hat OpenShift 4.16, bpfman will be available in Developer Preview status, meaning users will be able to install the bpfman operator from Operator Hub and start working and experimenting with the platform. This article will show exactly how to get up and running.

    Traditional eBPF-enabled applications on OpenShift

    Today across the OpenShift ecosystem there are numerous examples of internal and external applications utilizing eBPF. Core features such as the IngressNodeFirewall, NetworkObservability, and AdvancedClusterSecurity already make use of the technology in their implementations. The architectures for these applications have traditionally looked pretty similar, ultimately resembling the diagram in Figure 1.

    existing-eBPF-app-arch
    Figure 1: Existing eBPF application architecture.

    In this model, eBPF programs are compiled and embedded into the userspace binaries that deploy them. Userspace applications traditionally make use of one of the provided eBPF loading libraries in order to load, attach, manage, and interact with their associated eBPF programs. 

    From a functional standpoint this works well enough; however, there are a few drawbacks to such a deployment model:

    • All the applications need at least the CAP_BPF Linux capability to interact with the eBPF subsystem, which should essentially be treated as root. In the worst case scenario, programs may need more broad-ranging capabilities that allow them to trace other processes, create network interfaces, and perform other potentially damaging tasks.
    • Every application needs to maintain duplicate logic for eBPF resource management such as program loading/attaching and eBPF file system management.
    • eBPF has challenges with program cooperation. For example, some software using eBPF assumes exclusive use of an eBPF hook and can unintentionally eject existing programs when being attached, which is an even bigger issue in a platform like OpenShift which can facilitate running hundreds of different applications.
    • No fine-grained versioning control of the eBPF program in relation to its accompanying userspace component.

    eBPF-enabled applications on OpenShift with bpfman

    When the bpfman-operator is deployed on OpenShift, applications can delegate eBPF program lifecycle and management responsibilities to bpfman, and the existing architecture can transform into the following (Figure 2).

    bpfman-eBPF-application-architecture
    Figure 2: eBPF application architecture with bpfman.

    With this new deployment model comes many benefits, including:

    • bpfman acts as the central privileged access point, allowing applications to run as non-root.  
    • Administrators can use traditional RBAC to tightly control which program types a given user/service account is allowed to deploy.
    • bpfman can manage program cooperation at a cluster-wide level.
    • eBPF programs are packaged separately from the application in OCI container images according to the specification provided by the bpfman community allowing for fine-grained versioning and signing control.
    • Applications can continue to use existing management libraries for interacting with the eBPF maps associated with their programs.

    Now that we’ve gone over the current landscape, it’s time to get up and running with the bpfman-operator.

    Install the bpfman-operator

    Starting with an OpenShift cluster, users can easily deploy bpfman and its dependencies via the OperatorHub within OpenShift’s console. Start by navigating to the console’s OperatorHub page and finding the bpfman-operator in the listings, as shown in Figure 3.

    bpfman-operator-operatorhub-listing
    Figure 3: bpfman-operator OperatorHub landing page.

    After choosing the bpfman-operator from the listing page, make sure the installation namespace is correct by selecting "Create Project",  and making a project named bpfman, as shown in Figure 4.

    create-bpfman-project
    Figure 4: Project creation dashboard.

    Finally,  click Install to continue (Figure 5). 

    bpfman-operator-install-page
    Figure 5: bpfman-operator install page configured correctly.

    When everything has been installed correctly, the bpfman-operator, the bpfman-daemon, and the security-profiles-operator pods will be running in the bpfman namespace. The security profiles operator is deployed alongside bpfman to manage SELinux profiles which allow unprivileged userspace applications to work with their programs via eBPF Maps. See Figure 6.

    bpfman-operator-running-pods
    Figure 6: bpfman-operator pods up and running in the bpfman project.

    Deploy an example eBPF-enabled application with bpfman

    Once the operator has been successfully installed, bring up a terminal window that has the oc binary installed to deploy an application by simply using example manifests provided by the community. The example manifest below will deploy an eBPF application that makes use of an XDP program to count the number of packets flowing through a pod’s primary network interface. Other examples can be found in the Release Assets, load any of the *-install-selinx.yaml files.

    # oc create -f https://github.com/bpfman/bpfman/releases/download/v0.4.2/go-xdp-counter-install-selinux.yaml
    namespace/go-xdp-counter created
    serviceaccount/bpfman-app-go-xdp-counter created
    clusterrolebinding.rbac.authorization.k8s.io/xdp-binding created
    daemonset.apps/go-xdp-counter-ds created
    xdpprogram.bpfman.io/go-xdp-counter-example created
    selinuxprofile.security-profiles-operator.x-k8s.io/bpfman-secure created

    This will create a full-fledged eBPF-enabled application which includes:

    • An XdpProgram CRD to specify the containerized bytecode image containing the program, the priority of the program on a given interface, the node(s) where the program should be deployed, and the function name of the program.
    apiVersion: bpfman.io/v1alpha1
    kind: XdpProgram
    metadata:
      labels:
        app.kubernetes.io/name: xdpprogram
      name: go-xdp-counter-example
    spec:
      bpffunctionname: xdp_stats
      bytecode:
        image:
          url: quay.io/bpfman-bytecode/go-xdp-counter:v0.4.1
      interfaceselector:
        primarynodeinterface: true
      nodeselector: {}
      priority: 55
    • An application DaemonSet, which specifies the userspace application’s deployment for each node as well as what eBPF maps it needs access to.
    apiVersion: apps/v1
    kind: DaemonSet
    metadata:
      ...
    spec:
      ...
      template:
        ...
        spec:
          containers:
          - ...
            image: quay.io/bpfman-userspace/go-xdp-counter:v0.4.1
            imagePullPolicy: IfNotPresent
            name: go-xdp-counter
            securityContext:
              allowPrivilegeEscalation: false
              capabilities:
                drop:
                - ALL
              runAsGroup: 65534
              runAsUser: 65534
              seLinuxOptions:
                type: bpfman-secure_go-xdp-counter.process
            volumeMounts:
            - mountPath: /run/xdp/maps
              name: go-xdp-counter-maps
              readOnly: true
          nodeSelector: {}
          securityContext:
            fsGroup: 65534
            runAsNonRoot: true
          serviceAccountName: bpfman-app-go-xdp-counter
    ...
          volumes:
          - csi:
              driver: csi.bpfman.io
              volumeAttributes:
                csi.bpfman.io/maps: xdp_stats_map
                csi.bpfman.io/program: go-xdp-counter-example
            name: go-xdp-counter-maps

    The example application uses bpfman to deploy its XDP eBPF program and to get unprivileged access to the generated maps via a CSI ephemeral volume. After the example is properly deployed, it’s simple to check on the status of the XdpProgram.

    # oc get xdpprogram go-xdp-counter-example
    NAME                     BPFFUNCTIONNAME   NODESELECTOR   STATUS
    go-xdp-counter-example   xdp_stats         {}             ReconcileSuccess

    Following verification that the program has in fact been reconciled successfully make sure all the application pods are running. 

    # oc get pods -n go-xdp-counter
    NAME                      READY   STATUS    RESTARTS   AGE
    go-xdp-counter-ds-9ddgh   1/1     Running   0          36s
    go-xdp-counter-ds-gbzsj   1/1     Running   0          36s

    Then simply dump the application’s pod logs to see how many packets have been counted by the XDP program:

    # oc logs go-xdp-counter-ds-9ddgh -n go-xdp-counter
    2024/06/24 02:45:29 3614 packets received
    2024/06/24 02:45:29 23754428 bytes received
    2024/06/24 02:45:32 3997 packets received
    2024/06/24 02:45:32 23890444 bytes received
    2024/06/24 02:45:35 4447 packets received
    2024/06/24 02:45:35 24356469 bytes received
    2024/06/24 02:45:38 4998 packets received
    2024/06/24 02:45:38 24791765 bytes received
    2024/06/24 02:45:41 5154 packets received
    2024/06/24 02:45:41 24867116 bytes received
    2024/06/24 02:45:44 5392 packets received
    2024/06/24 02:45:44 25175031 bytes received
    ...

    Congratulations, you have now deployed your first eBPF-enabled application with bpfman on OpenShift!

    Roadmap

    bpfman is dedicated to constantly evolving based on upstream best practices, and you can view current and future work items  in the upstream GitHub tracking project. Some proposed features include:

    • First class multi-architecture support
    • eBPF TCX attach type support
    • Ability to attach networking programs via pod selectors
    • Exportation of eBPF subsystem metrics and events
    • Using the eBPF Token API to secure eBPF applications that either compile programs on the fly or require more fine-grained control over how their programs are loaded.

    Additionally, the community has been accepted as  a CNCF sandbox project, a larger community we look forward to working with.

    For Red Hat Openshift 4.17, bpfman will be delivered as a Technical Preview within the new "eBPF manager" feature. 

    Get involved

    To start learning more about the project please checkout the project website at bpfman.io. bpfman is completely open—feel free to open issues, start discussions, or more generally reach out to the reach out to the upstream community on Github or within Kubernetes Slack in the #bpfman channel. Any and all contributions are welcome and appreciated.

    Related Posts

    • Secure your Kubernetes deployments with eBPF

    • Network observability with eBPF on single node OpenShift

    • Packet capture using Network Observability eBPF Agent

    • Network debugging with eBPF (RHEL 8)

    • Observability for Node.js applications in OpenShift

    • eBPF application development: Beyond the basics

    Recent Posts

    • AI meets containers: My first step into Podman AI Lab

    • Live migrating VMs with OpenShift Virtualization

    • Storage considerations for OpenShift Virtualization

    • Upgrade from OpenShift Service Mesh 2.6 to 3.0 with Kiali

    • EE Builder with Ansible Automation Platform on OpenShift

    What’s up next?

    Read Operating OpenShift, a practical guide to running and operating OpenShift clusters more efficiently using a site reliability engineering (SRE) approach. Learn best practices and tools that can help reduce the effort of deploying a Kubernetes platform.

    Get the e-book
    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
    © 2025 Red Hat

    Red Hat legal and privacy links

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

    Report a website issue