Skip to main content

The podman play kube command now supports deployments

Work back and forth between Podman and Kubernetes.
Yellow parachutes ready for deployment

One of the most exciting features we've added to Podman is support for interacting with Kubernetes objects. With the podman generate kube command, Podman can export your existing containers into Kubernetes Pod YAML for import into an OpenShift or Kubernetes cluster. The podman play kube command does the opposite, taking Kubernetes YAML and running it in Podman. Initially, the play kube command only supported running Pod YAML. However, most Kubernetes users prefer using the more-flexible Deployment YAML, which we did not support. With the Podman v2.0 release, we've addressed this, and Deployment YAML can now be used with the podman play kube command.


When we first added podman generate kube and podman play kube, we intended to provide a way to ease migration to Kubernetes. Podman only runs containers on a single node, which means that users often outgrow it as their workloads increase. We wanted to give cluster admins an easy on-ramp to move their work to Kubernetes, an industry-standard solution for managing containers across many nodes. The podman generate kube command makes this possible. We added podman play kube to complement this by allowing developers to test their new YAML locally before deploying it. Our latest support for Deployments makes this much more usable.


Let’s look at an example Deployment from the Kubernetes documentation:

$ cat ./nginx-deployment.yaml  
apiVersion: apps/v1
kind: Deployment
  name: nginx-deployment
    app: nginx
  replicas: 3
      app: nginx
        app: nginx
      - name: nginx
        image: nginx:1.14.2
        - containerPort: 80

We can easily run this with podman play kube:

$ podman play kube ./nginx-deployment.yaml                                                                        
Trying to pull
Getting image source signatures
Copying blob 27833a3ba0a5 done   
Copying blob 0f23e58bd0b7 done   
Copying blob 8ca774778e85 done   
Copying config 295c7be079 done   
Writing manifest to image destination
Storing signatures

You can see that the YAML specifies three replicas, so Podman created three pods, each with one container. Let’s do a quick podman ps to see what it made:

$ podman ps -a
CONTAINER ID  IMAGE                 COMMAND               CREATED         STATUS             PORTS   NAMES
0c3fa04969f7  nginx:1.14.2         /docker-entrypoin...  14 seconds ago  Up 13 seconds ago          nginx-deployment-pod-0-nginx
1b50823b01b9                        11 seconds ago  Up 8 seconds ago           b461352502f0-infra
56b683ea398b  nginx:1.14.2          /docker-entrypoin...  8 seconds ago   Up 8 seconds ago           nginx-deployment-pod-2-nginx
83276e1e562b                        15 seconds ago  Up 13 seconds ago          16d50303cb06-infra
cb7c430f65d1  nginx:1.14.2          /docker-entrypoin...  11 seconds ago  Up 11 seconds ago          nginx-deployment-pod-1-nginx
fe6eefdfd7c4                        13 seconds ago  Up 11 seconds ago          288bcb7e5f7c-infra

You can see three infra (Pause) containers and three Nginx containers, one of each per pod, all of them running. Success!

Future plans

Unfortunately, while we can now run deployments with podman play kube, we can't create them yet. The podman generate kube command is not yet able to output Deployment YAML. We plan on working on this for a future release, but contributions are always welcome.

Community contribution

One of the best things about this new feature is that it was added by a community member, Aditya Kamath. The Podman Project is very thankful for the contribution. It is more proof of the power of open source.

[ Getting started with containers? Check out this free course. Deploying containerized applications: A technical overview. ]

Topics:   Containers   Podman  
Author’s photo

Matthew Heon

Matt Heon has been a software engineer on Red Hat's Container Runtimes team for the last five years. He's one of the original authors and lead maintainers of the Podman project. He focuses on container security, networking, and low-level development. More about me

Try Red Hat Enterprise Linux

Download it at no charge from the Red Hat Developer program.