Skip to main content
Redhat Developers  Logo
  • AI

    Get started with AI

    • Red Hat AI
      Accelerate the development and deployment of enterprise AI solutions.
    • AI learning hub
      Explore learning materials and tools, organized by task.
    • AI interactive demos
      Click through scenarios with Red Hat AI, including training LLMs and more.
    • AI/ML learning paths
      Expand your OpenShift AI knowledge using these learning resources.
    • AI quickstarts
      Focused AI use cases designed for fast deployment on Red Hat AI platforms.
    • No-cost AI training
      Foundational Red Hat AI training.

    Featured resources

    • OpenShift AI learning
    • Open source AI for developers
    • AI product application development
    • Open source-powered AI/ML for hybrid cloud
    • AI and Node.js cheat sheet

    Red Hat AI Factory with NVIDIA

    • Red Hat AI Factory with NVIDIA is a co-engineered, enterprise-grade AI solution for building, deploying, and managing AI at scale across hybrid cloud environments.
    • Explore the solution
  • Learn

    Self-guided

    • Documentation
      Find answers, get step-by-step guidance, and learn how to use Red Hat products.
    • Learning paths
      Explore curated walkthroughs for common development tasks.
    • See all learning

    Hands-on

    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.
    • Interactive labs
      Learn by doing in these hands-on, browser-based experiences.
    • Interactive demos
      Click through product features in these guided tours.

    Browse by topic

    • AI/ML
    • Automation
    • Java
    • Kubernetes
    • Linux
    • See all topics

    Training & certifications

    • Courses and exams
    • Certifications
    • Skills assessments
    • Red Hat Academy
    • Learning subscription
    • Explore training
  • Build

    Get started

    • Red Hat build of Podman Desktop
      A downloadable, local development hub to experiment with our products and builds.
    • Developer Sandbox
      Spin up Red Hat's products and technologies without setup or configuration.

    Download products

    • Access product downloads to start building and testing right away.
    • Red Hat Enterprise Linux
    • Red Hat AI
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    Featured

    • Red Hat build of OpenJDK
    • Red Hat JBoss Enterprise Application Platform
    • Red Hat OpenShift Dev Spaces
    • Red Hat Developer Toolset

    References

    • E-books
    • Documentation
    • Cheat sheets
    • Architecture center
  • Community

    Get involved

    • Events
    • Live AI events
    • Red Hat Summit
    • Red Hat Accelerators
    • Community discussions

    Follow along

    • Articles & blogs
    • Developer newsletter
    • Videos
    • Github

    Get help

    • Customer service
    • Customer support
    • Regional contacts
    • Find a partner

    Join the Red Hat Developer program

    • Download Red Hat products and project builds, access support documentation, learning content, and more.
    • Explore the benefits

Run OpenShift sandboxed containers with hosted control planes

Maximize efficiency and workload isolation

May 24, 2024
Camilla Conte Adel Zaalouk
Related topics:
ContainersKubernetes
Related products:
Red Hat OpenShift

    Hosted control planes, available via the multi-cluster engine, has been generally available since Red Hat OpenShift 4.14. Hosted control planes reduce costs and improve productivity for organizations adopting a multi-cluster approach.

    OpenShift sandboxed containers, based on Kata Containers, and generally available since OpenShift 4.8, is a native Kubernetes CRI runtime that provides an additional layer of isolation for workloads through hardware virtualization.

    When used together, hosted control planes and OpenShift sandboxed containers offer several benefits, such as speed, separation of concerns, and the necessary hardening to run multi-tenant workloads with stringent security constraints. 

    This article provides a detailed guide on how to configure and run sandboxed workloads for OpenShift clusters with hosted control planes, maximizing efficiency and workload isolation.

    Prerequisites

    In order to conduct this process, you need an OpenShift cluster already running, and a hosted control plane already configured. You don't need a node pool yet.

    We’ll use the oc and hcp command-line tools. Access credentials must be already set up.

    We recommend that you have already practiced setting up a node pool for your hosted control plane on your current cluster. Apart from that, completing these instructions should be as simple as creating a few Kubernetes resources from files.

    Create MachineConfig

    The first resource we will create is a MachineConfig. All the nodes using this MachineConfig will install the sandboxed-containers Red Hat Enterprise Linux CoreOS extension. Create the file sandboxed-containers-mc.yaml, with the following content:

    apiVersion: machineconfiguration.openshift.io/v1
    kind: MachineConfig
    metadata:
     name: sandboxed-containers-mc
    spec:
     extensions:
        - sandboxed-containers

    To link a MachineConfig to a node pool, we need to put the MachineConfig in a ConfigMap. Here we create the ConfigMap sandboxed-containers-mc-cm out of the sandboxed-containers-mc.yaml file:

    oc create configmap sandboxed-containers-mc-cm -n clusters --from-file config=sandboxed-containers-mc.yaml

    Create a node pool

    Now it's time to create a new node pool. The new node pool must use the sandboxed-containers MachineConfig. We also want to have a dedicated label for all the nodes in the node pool.

    Depending on the platform you are going to deploy on, the create nodepool command has different arguments. Use the same command and arguments that you already practiced when creating other node pools. Add the --render argument, and save the output to a file, node-pool.yaml:

    hcp create nodepool [...] --render > node-pool.yaml

    Now we have the file node-pool.yaml. We extend the file with the additional config and label, as in the snippet below:

    [...]
    spec:
     config:
       - name: "sandboxed-containers-mc-cm"
     nodeLabels:
       node-role.kubernetes.io/kata-oc: ""
    [...]

    Finally we create the node pool by applying the file node-pool.yaml:

    oc create -f node-pool.yaml

    We wait to see the new nodes up and running before continuing to the next section. You may see the nodes rebooting once, as part of the Red Hat Enterprise Linux CoreOS extension installation process.

    Depending on the platform you deploy on, additional steps might be necessary. For example, when using the “None” platform, you need further manual steps to deploy the workers. This is covered in the hosted control planes documentation.

    Create RuntimeClass

    In the previous section, we created a node pool. The MachineConfig mechanism installed the sandboxed-containers extension on the new nodes. Now, for pods to run in the sandboxed runtime, we need to create the kata RuntimeClass.

    Create the file runtime-class.yaml with the following content:

    apiVersion: node.k8s.io/v1
    handler: kata
    kind: RuntimeClass
    metadata:
     name: kata
    overhead:
     podFixed:
       cpu: 250m
       memory: 350Mi
    scheduling:
     nodeSelector:
       node-role.kubernetes.io/kata-oc: ""

    Prepare to access the hosted cluster. In the following steps we use oc with the --kubeconfig option to make sure we’re running commands on the hosted cluster. See the following example:

    oc --kubeconfig ${HOSTED_CLUSTER_NAME}.kubeconfig ...

    Apply the kata RuntimeClass to the hosted cluster:

    oc --kubeconfig ${HOSTED_CLUSTER_NAME}.kubeconfig apply -f runtime-class.yaml

    Run a sandboxed workload

    Everything should be set. In the previous step, we created the kata RuntimeClass to select the sandboxed-containers runtime. Now we will create a simple pod that uses the kata RuntimeClass. Then we show that the pod is running in a sandbox as expected.

    We start a pod with the kata RuntimeClass. For the sake of the example, a web server keeps the pod running indefinitely. Be mindful that you have to use the hosted cluster kubeconfig here, like in the previous step.

    oc --kubeconfig ${HOSTED_CLUSTER_NAME}.kubeconfig \
    run --image=registry.fedoraproject.org/fedora \
    --overrides='{"spec":{"runtimeClassName":"kata"}}' \
    test-pod-sandboxed -- python3 -m http.server

    We inspect the pod to tell which node it’s running on:

    oc describe pod test-pod-sandboxed | grep 'Node:'

    We get a shell on the worker node where the pod is running on. On the worker node, we show the qemu-kvm processes:

    ps -ef | grep qemu

    Check the output of the previous command, you should see the process of the Kata sandbox, something like the following:

    qemu-kvm -name sandbox-...

    That’s it. QEMU is running your pod in a virtual machine sandbox, managed with a hosted control plane!

    More Information 

    For more information, visit the documentation: 

    • Hosted control planes | OpenShift Container Platform 4.15
    • OpenShift sandboxed containers user guide

    If you need further assistance, you can reach out to us through the following methods:

    • OpenShift Commons slack
    • OpenShift users Kubernetes slack channel
    • Through your Red Hat account representative

    Related Posts

    • How to install single node OpenShift on bare metal

    • How to manage a fleet of heterogeneous OpenShift clusters

    • Set up an OpenShift cluster to deploy an application in odo CLI

    • Ensure a scalable and performant environment for ROSA with hosted control planes

    • Use OperatorPolicy to manage Kubernetes-native applications

    • What's new for developers in Red Hat OpenShift 4.15

    Recent Posts

    • Best Practice Configuration and Tuning for Linux and Windows VMs

    • Red Hat UBI 8 builders have been promoted to the Paketo Buildpacks organization

    • Using eBPF in Red Hat products

    • How we made one data layer serve the UI, the mocks, and the E2E tests

    • Build trusted Python containers with Project Hummingbird and Calunga

    What’s up next?

    Get a hands-on introduction to daily life as a developer crafting code on OpenShift, the open source application development platform from Red Hat, with OpenShift for Developers.

    Get the e-book
    Red Hat Developers logo LinkedIn YouTube Twitter Facebook

    Platforms

    • Red Hat AI
    • Red Hat Enterprise Linux
    • Red Hat OpenShift
    • Red Hat Ansible Automation Platform
    • See all products

    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
    © 2026 Red Hat

    Red Hat legal and privacy links

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