Run Kubernetes Workloads with Podman on Oracle Linux
Introduction
Podman kube provides developers and administrators with a way to test Kubernetes workloads using Podman before deploying them to a Kubernetes cluster. The podman kube
command is used to generate Kubernetes-compliant YAML from existing Podman containers, or Pods, or to create containers/pods from a Kubernetes YAML file. This provides a convenient way to easily transition between the Podman and Kubernetes environments, thereby leveraging the best of both ecosystems to accelerate the development and testing cycles.
Note: The podman kube play
command reads any valid Kubernetes YAML file, and starts the pods, containers or volumes defined in the YAML file on your locally running Podman instance. However, not all Kubernetes YAML file types are supported. The currently supported Kubernetes objects are:
- Pod
- Deployment
- PersistentVolumeClaim
- ConfigMap
- Secret
- DaemonSet
- Job
A more detailed list of the Kubernetes YAML fields currently supported by the podman kube play
command is located here .
The key benefits provided by the Podman Kube feature are:
- Interoperability: - Develop and test your containerized applications locally using Podman,and easily deploy them to a Kubernetes cluster when ready.
- Flexibility: - Use the strengths of Podman (e.g., simplicity, low resource needs) and also of Kubernetes (e.g., scalability, orchestration).
- Simpler Workflow: - Being able to generate Kubernetes YAML files from Podman containers or pods, or use Kubernetes YAML to create Podman containers/pods, simplifies the workflow for developers and administrators, allowing them to work flexibly.
In summary, the Podman Kube functionality is a powerful tool that provides a bridge between Podman and Kubernetes, simplifying the workflow between these two container management solutions.
Objectives
In this tutorial, you'll learn to:
- Use Podman to create and run a Pod.
- Use Podman to generate Kubernetes YAML.
- Create and run a Pod on Podman using Kubernetes YAML
- Use Podman Kube to test a Kubernetes YAML file locally using Podman.
Prerequisites
Minimum of a single Oracle Linux system
Each system should have Oracle Linux installed and configured with:
- A non-root user account with sudo access
- Access to the Internet
Deploy Oracle Linux
Note: If running in your own tenancy, read the linux-virt-labs
GitHub project README.md and complete the prerequisites before deploying the lab environment.
Open a terminal on the Luna Desktop.
Clone the
linux-virt-labs
GitHub project.git clone https://github.com/oracle-devrel/linux-virt-labs.git
Change into the working directory.
cd linux-virt-labs/ol
Install the required collections.
ansible-galaxy collection install -r requirements.yml
Deploy the lab environment.
ansible-playbook create_instance.yml -e localhost_python_interpreter="/usr/bin/python3.6" -e use_podman=true -e update_all=true -e os_version="9"
The free lab environment requires the extra variable
local_python_interpreter
, which setsansible_python_interpreter
for plays running on localhost. This variable is needed because the environment installs the RPM package for the Oracle Cloud Infrastructure SDK for Python, located under the python3.6 modules.The default deployment shape uses the AMD CPU and Oracle Linux 8. To use an Intel CPU or Oracle Linux 9, add
-e instance_shape="VM.Standard3.Flex"
or-e os_version="9"
to the deployment command.Important: Wait for the playbook to run successfully and reach the pause task. At this stage of the playbook, the installation of Oracle Linux is complete, and the instances are ready. Take note of the previous play, which prints the public and private IP addresses of the nodes it deploys and any other deployment information needed while running the lab.
Confirm Podman Works
The container-tools package in Oracle Linux provides the latest versions of Podman, Buildah, Skopeo, and associated dependencies.
Open a terminal and connect via SSH to the ol-node-01 instance.
ssh oracle@<ip_address_of_instance>
Check the version of Podman.
podman -v
Confirm the Podman CLI is working.
podman run quay.io/podman/hello
Example Output:
[oracle@ol-server ~]$ podman run quay.io/podman/hello Trying to pull quay.io/podman/hello:latest... Getting image source signatures Copying blob f82b04e85914 done Copying config dbd85e09a1 done Writing manifest to image destination Storing signatures !... Hello Podman World ...! .--"--. / - - \ / (O) (O) \ ~~~| -=(,Y,)=- | .---. /` \ |~~ ~/ o o \~~~~.----. ~~ | =(X)= |~ / (O (O) \ ~~~~~~~ ~| =(Y_)=- | ~~~~ ~~~| U |~~ Project: https://github.com/containers/podman Website: https://podman.io Documents: https://docs.podman.io Twitter: @Podman_io
Create a Kubernetes YAML file
First, create a pod with a container, then generate a Kubernetes-compliant YAML file from it.
Create a pod with an Nginx server that maps port 8081 to the host system.
podman run -dt --pod new:my-nginx --name nginx-container -p 8081:80 ghcr.io/oracle/oraclelinux9-nginx:1.20
This creates a new pod called 'my-nginx', deploys an Nginx container inside the pod and maps the container to port 8081 on the host.
Verify the Pod has been created.
podman pod ps
Example Output:
[oracle@ocne ~]$ podman pod ps POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS e5248f6968b3 my-nginx Running 48 seconds ago 5e41ad85e232 2
Confirm you can access the new pod and its container from the host.
curl http://localhost:8081
Generate a Kubernetes file YAML from the running pod.
podman kube generate my-nginx --type pod > nginx-pod.yaml
The
podman generate
command creates a Kubernetes-compliant file from a running Podman pod. Making it very useful for local prototyping, and subsequently creating a Kubernetes-compliant manifest file, you can deploy to a Kubernetes cluster.Inspect the
nginx-pod.yaml
file.cat nginx-pod.yaml
Example Output:
[oracle@ocne ~]$ cat nginx-pod.yaml # Save the output of this file and use kubectl create -f to import # it into Kubernetes. # # Created with podman-4.9.4-rhel apiVersion: v1 kind: Pod metadata: creationTimestamp: "2025-08-11T14:08:13Z" labels: app: my-nginx name: my-nginx spec: containers: - env: - name: TERM value: xterm image: ghcr.io/oracle/oraclelinux9-nginx:1.20 name: zenbardeen ports: - containerPort: 80 hostPort: 8081 tty: true
Run a Kubernetes YAML File
Create a Kubernetes YAML file.
cat << EOF | tee testpod.yaml > /dev/null apiVersion: v1 kind: Pod metadata: name: my-pod spec: containers: - name: test-container image: ghcr.io/oracle/oraclelinux9-nginx:1.20 ports: - containerPort: 8080 EOF
This YAML file creates a new Podman pod called 'my-pod' with a container called 'test-container' running an Nginx server.
Create a Pod.
The
podman kube play
command uses a manually created Kubernetes YAML file, as in the last step, or from the output of thepodman kube generate
command, to run the Kubernetes deployment locally using Podman. This helps you test the deployment locally before deploying it to your cluster.podman kube play testpod.yaml
Example Output:
[oracle@ol-node-01 ~]$ podman kube play testpod.yaml Pod: 1a4d460b062d82b0f89cfd77273f2436f745de8df7bfc2d2041e516d23e42ef6 Container: 16d3f54a562bfc2f30cbed46494d39594e82db902aeab2502bcec855653146b2
Verify the pod called 'my-pod' was created.
podman pod ps
Example Output:
[oracle@ocne ~]$ podman pod ps POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS 0220a06dbbfb my-pod Running 8 seconds ago 1be65a326af9 2 e5248f6968b3 my-nginx Running 3 minutes ago 5e41ad85e232 2
Inspect the 'my-pod' pod.
podman pod inspect my-pod
The output provides detailed information about the pod, including the containers it is running.
Remove Pods using a Kubernetes YAML file
Pods and their associated containers can be removed easily once you have finished working with them.
Remove the my-pod pod along with its associated containers.
This step uses the built-in Podman support for working with Kubernetes.
podman kube down testpod.yaml
Note: For an alternative way to remove the pod and its containers, use the following steps:
podman stop nginx-container podman rm nginx-container
Verify that my-pod has been deleted.
podman pod ps
Example Output:
[oracle@ocne ~]$ podman pod ps POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS c8e640bc95cb my-nginx Running 4 minutes ago d08c83deb075 2
Delete the my-nginx pod.
podman kube down nginx-pod.yaml
Confirm both pods have been deleted.
podman pod ps
Example Output:
[oracle@ocne ~]$ podman pod ps POD ID NAME STATUS CREATED INFRA ID # OF CONTAINERS
This confirms that the Kubernetes YAML file you created earlier is valid.
Next Steps
This tutorial demonstrated how to use podman kube
commands to work with Kubernetes-compliant YAML files using Podman. Check out the Oracle Linux Training Station for additional tutorials and content.