{"id":223,"date":"2023-08-01T13:52:27","date_gmt":"2023-08-01T13:52:27","guid":{"rendered":"http:\/\/192.168.0.142\/?p=223"},"modified":"2023-08-03T12:10:11","modified_gmt":"2023-08-03T12:10:11","slug":"podman-play-kube-example-on-ubuntu-22-04","status":"publish","type":"post","link":"http:\/\/192.168.0.142\/podman-play-kube-example-on-ubuntu-22-04\/","title":{"rendered":"Podman play kube – How to run a pod from a yaml file"},"content":{"rendered":"\n

Podman (the POD manager) is an open source tool for developing, managing, and running containers on Linux systems.<\/p>\n\n\n\n

podman play kube will read in a structured file of Kubernetes YAML. It will then recreate the containers, pods or volumes described in the YAML. Containers within a pod are then started and the ID of the new Pod or the name of the new Volume is the output.<\/p>\n\n\n\n

Please refer Podman installation on Ubuntu 22.04<\/a> for installation of podman on Ubuntu. <\/p>\n\n\n\n

Pull pause image<\/strong><\/p>\n\n\n\n

podman pull k8s.gcr.io\/pause:3.5<\/code><\/pre>\n\n\n\n

Create a file named configmap.yaml to hold environment variables values<\/strong><\/p>\n\n\n\n

apiVersion: v1\nkind: ConfigMap\nmetadata:\n  name: config\ndata:\n  # MySQL Container Envrionment Variables\n  MYSQL_ROOT_PASSWORD: welcome123 # MySQL root password\n  MYSQL_DATABASE: wordpress # WordPress Database Name\n  MYSQL_USER: wordpress # WordPress Database User\n  MYSQL_PASSWORD: welcome123 # WordPress Database User Password\n  # WordPress Container Envrionment Variables\n  WORDPRESS_DB_HOST: 127.0.0.1 # MySQL Host\n  WORDPRESS_DB_PASSWORD: welcome123 # DB Password\n  WORDPRESS_DB_USER: wordpress # DB User\n<\/code><\/pre>\n\n\n\n

Create a file named pod.yaml to mention the containers belong to the pod.<\/strong><\/p>\n\n\n\n

apiVersion: v1\nkind: Pod\nmetadata:\n  labels:\n    app: wordpress\n  name: wordpress\nspec:\n  containers:\n    - image: docker.io\/mysql:8.0 # MySQL Image\n      name: db\n      envFrom:\n        - configMapRef:\n            name: config # Load Environment Variables from ConfigMap\n      ports:\n        - containerPort: 3306 # MySQL Container Port\n          hostPort: 3306 # MySQL Host Port\n          name: mysql\n    - image: docker.io\/wordpress:6.2.1-apache # WordPress Image\n      name: ui\n      ports:\n        - containerPort: 80 # WordPress Container Port\n          hostPort: 8080 # WordPress Host Port\n          name: wordpress\n      envFrom:\n        - configMapRef:\n            name: config # Load Environment Variables from ConfigMap\n  restartPolicy: Never\n<\/code><\/pre>\n\n\n\n

Run below command to create the pod<\/strong><\/p>\n\n\n\n

podman play kube --configmap configmap.yaml pod.yaml <\/code><\/pre>\n\n\n\n

Terminal output for reference<\/strong><\/p>\n\n\n\n

$ podman play kube --configmap configmap.yaml pod.yaml \nPod:\n38b5cc9742f15ef77e1d12711af6fb3ef04b8f962b297a2ac8483f86cc90dcc3\nContainers:\n308ee2933cb602657dc168a1ce5d95fc48ee57b7757d05414bbb878a3cadb901\nc97efa9eb6bf4b87b8e963895f0fb7e801dae3ba35c730f68fea6c16cb297683<\/code><\/pre>\n\n\n\n

Check the pod running status <\/strong><\/p>\n\n\n\n

podman pod ls<\/code><\/pre>\n\n\n\n

Terminal output for reference<\/strong><\/p>\n\n\n\n

ability@abb:~\/scripts$ podman pod ls\nPOD ID        NAME        STATUS      CREATED         INFRA ID      # OF CONTAINERS\n38b5cc9742f1  wordpress   Running     10 seconds ago  a03b5dece28a  3<\/code><\/pre>\n\n\n\n

Check the containers running using below command<\/strong><\/p>\n\n\n\n

podman ps<\/code><\/pre>\n\n\n\n

Terminal output for reference<\/strong><\/p>\n\n\n\n

$ podman ps \nCONTAINER ID  IMAGE                                     COMMAND               CREATED        STATUS            PORTS                                         NAMES\na03b5dece28a  k8s.gcr.io\/pause:3.5                                            4 minutes ago  Up 4 minutes ago  0.0.0.0:8080->80\/tcp, 0.0.0.0:3306->3306\/tcp  38b5cc9742f1-infra\n308ee2933cb6  docker.io\/library\/mysql:8.0               mysqld                4 minutes ago  Up 4 minutes ago  0.0.0.0:8080->80\/tcp, 0.0.0.0:3306->3306\/tcp  wordpress-db\nc97efa9eb6bf  docker.io\/library\/wordpress:6.2.1-apache  apache2-foregroun...  4 minutes ago  Up 4 minutes ago  0.0.0.0:8080->80\/tcp, 0.0.0.0:3306->3306\/tcp  wordpress-ui<\/code><\/pre>\n\n\n\n

Open url http:\/\/<host_ip>:8080 in browser to access wordpress application. Installation workflow is displayed on the page.<\/strong><\/p>\n\n\n\n

\"Wordpress<\/figure>\n","protected":false},"excerpt":{"rendered":"

Podman (the POD manager) is an open source tool for developing, managing, and running containers on Linux systems. podman play kube will read in a structured file of Kubernetes YAML. It will then recreate the containers, pods or volumes described in the YAML. Containers within a pod are then started and the ID of the … Read more<\/a><\/p>\n","protected":false},"author":1,"featured_media":321,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[26],"tags":[25],"_links":{"self":[{"href":"http:\/\/192.168.0.142\/wp-json\/wp\/v2\/posts\/223"}],"collection":[{"href":"http:\/\/192.168.0.142\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/192.168.0.142\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/192.168.0.142\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/192.168.0.142\/wp-json\/wp\/v2\/comments?post=223"}],"version-history":[{"count":24,"href":"http:\/\/192.168.0.142\/wp-json\/wp\/v2\/posts\/223\/revisions"}],"predecessor-version":[{"id":503,"href":"http:\/\/192.168.0.142\/wp-json\/wp\/v2\/posts\/223\/revisions\/503"}],"wp:featuredmedia":[{"embeddable":true,"href":"http:\/\/192.168.0.142\/wp-json\/wp\/v2\/media\/321"}],"wp:attachment":[{"href":"http:\/\/192.168.0.142\/wp-json\/wp\/v2\/media?parent=223"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/192.168.0.142\/wp-json\/wp\/v2\/categories?post=223"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/192.168.0.142\/wp-json\/wp\/v2\/tags?post=223"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}