Podman: Kubernetes Integration

Introduction to Podman and Kubernetes

Kubernetes is the reigning champion of container orchestration, and Podman plays well with it—despite what the Docker fanboys might tell you. If you’re tired of Docker’s baggage but still need to run workloads on Kubernetes, Podman’s got your back.

Why Use Podman with Kubernetes?

  • No Daemon Required – Unlike Docker, Podman doesn’t need a long-running daemon, making it more secure and less prone to sudden failures.
  • Rootless Mode – Deploy containers without root privileges, because giving everything root access is just asking for trouble.
  • OCI Compliance – Ensures compatibility with Kubernetes by adhering to Open Container Initiative (OCI) standards.
  • Built-in Kubernetes YAML Generation – Podman can generate Kubernetes manifests directly, saving you from YAML-induced headaches.

Deploying Podman Images to Kubernetes

Let’s walk through deploying a Podman-built image to a Kubernetes cluster.

Step 1: Build the Container Image

podman build -t myapp:latest -f Containerfile

This compiles your app into a container image tagged myapp:latest.

Step 2: Push the Image to a Registry

Kubernetes needs to pull your image from a registry, so let’s get it up there:

podman tag myapp:latest docker.io/myrepo/myapp:latest
podman push docker.io/myrepo/myapp:latest

Tip: If you’re running a private registry, make sure Kubernetes has credentials to access it.

Step 3: Generate a Kubernetes Deployment YAML

Podman can generate Kubernetes YAML from a running container:

podman generate kube mycontainer > myapp-deployment.yaml

This outputs a fully formed Kubernetes manifest, so you don’t have to write it from scratch.

Step 4: Deploy to Kubernetes

Use kubectl to apply the deployment:

kubectl apply -f myapp-deployment.yaml

Step 5: Verify Deployment

Make sure your Podman-powered container is running in Kubernetes:

kubectl get pods

If it’s not running, congratulations! You’ve just entered the world of debugging Kubernetes deployments.

Podman and Kubernetes Compatibility

Podman is designed to be Kubernetes-friendly, but there are still some differences to be aware of.

Using podman generate kube

This command creates Kubernetes-compatible YAML files based on your running containers and pods. It’s a great way to quickly spin up deployments.

Running Kubernetes Manifests with Podman

Want to test your Kubernetes YAML locally? Use podman play kube:

podman play kube myapp-deployment.yaml

This simulates a Kubernetes deployment, allowing you to test your YAML before pushing it to the cluster.

Podman Pods vs. Kubernetes Pods

  • Podman Pods – Work similarly to Kubernetes pods but don’t require a cluster.
  • Kubernetes Pods – Designed for orchestration at scale, requiring a Kubernetes cluster.

Troubleshooting Compatibility Issues

  • Image Pull Issues? Ensure your registry is accessible and authentication is configured properly.
  • Networking Problems? Kubernetes networking differs from Podman’s default setup, so check your network policies.
  • Volume Mounts Not Working? Ensure your storage drivers and volume configurations match between Podman and Kubernetes.

Transitioning from Podman to Kubernetes

Podman is great for local development, but at some point, you’ll need to transition to a full Kubernetes setup.

Migrating Podman Containers to Kubernetes Pods

If you’ve been using Podman for local development, the transition is relatively painless:

  1. Convert your running container to a Kubernetes manifest:
    podman generate kube mycontainer > myapp-deployment.yaml
  2. Apply the manifest to Kubernetes:
    kubectl apply -f myapp-deployment.yaml

Best Practices for Running Podman Workloads in Kubernetes

  • Use Kubernetes-native Networking – Podman’s networking is great for local use, but make sure your app is ready for Kubernetes’ networking model.
  • Check Storage Drivers – Kubernetes may use different storage backends than what Podman uses locally.
  • Optimize Images – Use multi-stage builds and minimal base images to ensure efficient deployment.

Simulating Kubernetes Networking with Podman

Podman’s networking can approximate Kubernetes behavior using podman network commands:

podman network create myk8snetwork
podman run --network=myk8snetwork -d myapp:latest

Managing Multi-Container Applications Before Deployment

Podman’s pod feature lets you manage multiple containers together, much like Kubernetes pods:

podman pod create --name mypod
podman run --pod mypod -d myapp:latest

This allows you to test pod-based deployments before moving them to Kubernetes.

Ensuring Compatibility with CRI-O

If you’re using Kubernetes with CRI-O (Container Runtime Interface for OpenShift), Podman’s OCI compliance ensures a smooth transition.

Hands-On Exercise

Let’s put this into practice:

  1. Build and push a Podman image to a container registry.
  2. Generate a Kubernetes deployment from a running Podman container.
  3. Deploy and manage the application in Kubernetes.
  4. Convert a Podman pod into a Kubernetes deployment using podman generate kube.

Complete this, and you’ll have a solid grasp of how Podman integrates with Kubernetes—without the headaches of Docker.


That’s a wrap! Now you can confidently deploy Podman containers in Kubernetes. If something goes wrong, don’t worry—it’s just Kubernetes being Kubernetes. Cheers!