Podman and Red Hat OpenShift Integration

The convergence of Podman and Red Hat OpenShift represents a critical architectural bridge between local container development and enterprise-grade cloud orchestration. OpenShift is fundamentally a hybrid cloud platform that leverages Linux containers, orchestrated and managed via Kubernetes, and constructed upon a foundation of Red Hat Enterprise Linux. In this ecosystem, Podman serves as the primary tool for developers to build, run, and manage containers before they are promoted to a full-scale OpenShift cluster. This synergy allows for a consistent development lifecycle where the transition from a local workstation to a production cluster is seamless, provided the developer adheres to the specific security and runtime requirements of the OpenShift environment.

Architectural Foundations of OpenShift and Podman

OpenShift is designed as a complete platform for application development, focusing on providing a robust orchestration layer for containers. By utilizing Kubernetes for orchestration and Red Hat Enterprise Linux for the underlying operating system, OpenShift ensures that containerized workloads are managed with a level of stability and scalability required for enterprise operations.

Podman serves as the engine for local container management. Unlike other container engines, Podman is daemonless, which reduces the attack surface and eliminates the single point of failure often associated with daemon-based systems. When integrating with OpenShift, Podman allows developers to simulate the container lifecycle—building images, testing configurations, and managing pods—on their own machines before deploying to a hybrid cloud environment.

Local Development Environments with OpenShift Local

For developers who require a full OpenShift experience without the overhead of a remote cloud cluster, Red Hat OpenShift Local provides a mechanism to manage minimal clusters on a local workstation. This setup is essential for testing and development, ensuring that the application behaves as expected in a Kubernetes-orchestrated environment before moving to production.

Podman Desktop enhances this experience through the OpenShift Local extension, which provides a graphical interface to manage these instances. This integration simplifies the lifecycle of local clusters, from installation and initialization to ongoing management.

Installation and Configuration Process

The installation of OpenShift Local involves several critical steps to ensure the underlying system is correctly configured to support the virtualized cluster.

  1. Extension Installation: Users begin by accessing the Dashboard in Podman Desktop and clicking on the OpenShift Local option to install the necessary extension.

  2. Binary Installation: If Podman Desktop detects that the OpenShift Local binaries are missing, it provides installation paths for Windows, macOS, and Linux. Users can click Install within the OpenShift Local tile to initiate the process.

  3. Manual Binary Setup: For those preferring manual configuration, the process involves visiting the Red Hat OpenShift local download page, selecting the appropriate platform, and downloading the archive. Once extracted, the crc binary must be copied to a directory present in the system path, such as /usr/local/bin.

  4. System Finalization: After the installation program completes, a system reboot is required to finalize changes and ensure all drivers and configurations are active.

  5. System Configuration: To finalize the environment setup, the following command is executed:
    crc setup

  6. Restart: After running the setup command, the user must exit and restart Podman Desktop.

Initializing the OpenShift Local Instance

Once the binaries and extensions are in place, the user must initialize the cluster through the Podman Desktop interface.

  • Preset Selection: Users can review and select virtual machine presets in Settings > Preferences > Extension: Red Hat OpenShift Local. There are two primary options:

    • MicroShift: An experimental, lightweight, and optimized environment that provides a limited set of services. This is ideal for resource-constrained environments.
    • OpenShift: A single-node OpenShift cluster providing a full set of services, including the web console. This option requires significantly more system resources.
  • Pull Secret Configuration: To pull container images from the Red Hat registry, a pull secret is mandatory. Users must navigate to the Red Hat OpenShift Local download page, copy the pull secret, and paste it into the prompt within Podman Desktop.

  • Launch: After the pull secret is entered and the preset is selected, the user clicks Initialize and start on the Dashboard.

Verification of Deployment

Successful deployment can be verified through multiple interfaces within Podman Desktop.

  • Dashboard Verification: The Dashboard screen will explicitly indicate that OpenShift Local is running.

  • Resource Verification: Navigation to Settings > Resources will show the active OpenShift Local instance.

Porting Podman Containers to OpenShift

The transition of containers from a standalone Red Hat Enterprise Linux (RHEL) server to OpenShift is a common architectural progression. While Podman and OpenShift share the same container runtime foundations, the transition requires a shift in how security and permissions are handled.

Comparative Runtime Analysis

Understanding the differences between running Podman on RHEL and running containers on OpenShift is vital for a successful migration.

Feature Podman on RHEL OpenShift
Management Manual management via CLI Orchestrated via Kubernetes
Runtime Podman Engine CRI-O Runtime
Permissions Rootful or Rootless options Non-root containers by default
Constraints Standard Linux permissions SecurityContextConstraints (SCCs)

The primary challenge in this migration is the strict security model implemented by OpenShift. Specifically, OpenShift utilizes SecurityContextConstraints (SCCs) to restrict container capabilities, ensuring that no container has more privilege than necessary.

Adapting Images for OpenShift Security

OpenShift security mandates that containers run as random, non-root User IDs (UIDs) by default. This differs from standard RHEL deployments where a container might run as a specific user or root.

  • Non-Root UID Handling: Images must be designed to handle running as an arbitrary user. This means that any process within the container that requires specific permissions must be compatible with a random UID.

  • Group Permissions: Directories within the image must have group-write permissions for group 0. This ensures that regardless of the random UID assigned, the user remains part of the root group and can write to necessary directories.

  • Port Restrictions: OpenShift restricts the use of ports below 1024 for non-privileged containers. To avoid port binding failures, developers must configure applications to use non-privileged ports, such as 8080 or 8443.

  • Volume Mounts: Direct host path mounts are prohibited without special permissions. When using Persistent Volume Claims (PVCs), data directories may require group-writable permissions, which can be managed via an init container to ensure the environment is correctly set up before the main application starts.

  • Image Access: To prevent image pull failures, developers must ensure the OpenShift cluster can reach the registry and that the appropriate pull secrets are configured.

Local Testing for OpenShift Compatibility

Before deploying to a production cluster, developers should use Podman to simulate the OpenShift security environment. This prevents runtime failures that are difficult to debug in a cluster.

  • Testing with Random UID: To simulate the random UID assignment, the following command is used:
    podman run --rm -u $((RANDOM + 1000000)):0 -p 8080:8080 my-app:openshift

  • Testing Read-Only Filesystems: To ensure the application does not rely on writing to the root filesystem, a read-only test is conducted:
    podman run --rm --read-only --tmpfs /tmp -u 1001:0 my-app:openshift

  • Testing without Capabilities: To verify that the application does not require privileged capabilities, the following command is executed:
    podman run --rm --cap-drop ALL -u 1001:0 my-app:openshift

  • Verifying Identity: To confirm that no root processes are running, the identity of the user can be verified:
    podman run --rm -u 1001:0 my-app:openshift id

Container Lifecycle Management: From Podman to OpenShift

Once an image is verified as OpenShift-ready, the process of moving it into the cluster involves tagging, pushing, and deploying.

Registry Interaction and Image Management

Images can be pushed to either an internal OpenShift registry or an external registry such as Quay.io.

  • Internal Registry Authentication: To authenticate with the internal OpenShift image registry, the following command is used:
    podman login -u $(oc whoami) -p $(oc whoami -t) default-route-openshift-image-registry.apps.cluster.example.com

  • Tagging and Pushing to Internal Registry:
    podman tag my-app:openshift default-route-openshift-image-registry.apps.cluster.example.com/myproject/my-app:latest
    podman push default-route-openshift-image-registry.apps.cluster.example.com/myproject/my-app:latest

  • Tagging and Pushing to External Registry (Quay.io):
    podman tag my-app:openshift quay.io/myorg/my-app:latest
    podman push quay.io/myorg/my-app:latest

Generating Kubernetes YAML from Podman

One of the most powerful features of Podman is the ability to export a running pod as a Kubernetes YAML file, which can then be adapted for OpenShift.

  • Exporting the Pod:
    podman kube generate --type deployment --replicas 2 my-app > my-app-k8s.yaml

  • Adaptation for OpenShift: The generated YAML must be edited to include OpenShift-specific resources. A typical configuration includes a Deployment, a Service, and a Route.

The Deployment section ensures the pod runs with the correct replicas and resource constraints:
yaml apiVersion: apps/v1 kind: Deployment metadata: name: my-app labels: app: my-app spec: replicas: 2 selector: matchLabels: app: my-app template: metadata: labels: app: my-app spec: containers: - name: my-app image: quay.io/myorg/my-app:latest ports: - containerPort: 8080 resources: limits: memory: "256Mi" cpu: "500m" requests: memory: "128Mi" cpu: "250m" livenessProbe: httpGet: path: / port: 8080 initialDelaySeconds: 10 readinessProbe: httpGet: path: / port: 8080 initialDelaySeconds: 5

The Service section enables internal communication:

```yaml

apiVersion: v1
kind: Service
metadata:
name: my-app
spec:
selector:
app: my-app
ports:
- port: 8080
targetPort: 8080
```

The Route section exposes the service to external traffic, a feature specific to OpenShift:

```yaml

apiVersion: route.openshift.io/v1
kind: Route
metadata:
name: my-app
spec:
to:
kind: Service
name: my-app
port:
targetPort: 8080
```

Rapid Deployment with oc new-app

For developers seeking a faster path to deployment without manually managing YAML files, the oc CLI provides a streamlined approach.

  • Direct Deployment: Creating an application directly from an image:
    oc new-app quay.io/myorg/my-app:latest --name=my-app

  • Exposing the Application: To make the service accessible via a route:
    oc expose svc/my-app

Educational Framework: Red Hat OpenShift Development I (DO188)

To formalize the skills required for this workflow, Red Hat provides the DO188 course, titled "Red Hat OpenShift Development I: Introduction to Containers with Podman." This course is designed as a developer-centric introduction to building and managing containers specifically for deployment on Red Hat OpenShift.

The curriculum focuses on:
- Building, running, and managing containers utilizing Podman.
- Establishing core skills for developing containerized applications.
- Hands-on experience in bridging the gap between local development and OpenShift deployment.

Detailed Analysis of the Podman-OpenShift Workflow

The integration of Podman and OpenShift is not merely a matter of tool selection but a strategic approach to the software development lifecycle. By moving the validation of security constraints (such as non-root UID and port restrictions) to the local development phase, the "fail-fast" philosophy is implemented. When a developer uses podman run with a random UID locally, they are essentially performing a pre-flight check. If the application crashes due to a permission error, it is corrected in the Dockerfile or the application code before it ever reaches the OpenShift cluster, thereby reducing the burden on cluster administrators and decreasing the time to production.

The use of OpenShift Local further strengthens this loop. By providing a single-node cluster, it allows for the testing of Kubernetes-specific manifests (Deployments, Services, and Routes) on the developer's workstation. The transition from Podman's standalone pods to OpenShift's orchestrated pods is the most critical step. The ability to generate Kubernetes YAML from Podman removes the guesswork from manifest creation, allowing the developer to focus on the operational requirements (resource limits, probes, and routing) rather than the syntax of the YAML file.

Ultimately, the combination of Podman's daemonless architecture and OpenShift's enterprise orchestration creates a continuum. A developer can start with a simple container, refine it using Podman, test it in a localized OpenShift environment, and finally deploy it to a hybrid cloud platform with total confidence in its security and stability.

Sources

  1. Podman Desktop - OpenShift
  2. Red Hat Training - DO188
  3. OneUptime - Porting Podman Containers to OpenShift
  4. Podman Desktop - OpenShift Local

Related Posts