{"id":320,"date":"2023-08-03T05:09:56","date_gmt":"2023-08-03T05:09:56","guid":{"rendered":"http:\/\/192.168.0.142\/?p=320"},"modified":"2023-08-03T11:30:23","modified_gmt":"2023-08-03T11:30:23","slug":"podman-play-kube-how-to-use-volumes-for-data-persistence","status":"publish","type":"post","link":"http:\/\/192.168.0.142\/podman-play-kube-how-to-use-volumes-for-data-persistence\/","title":{"rendered":"Podman play kube – How to use volumes for data persistence"},"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

Please refer Podman play kube \u2013 How to run a pod from a <\/a>yaml <\/a>file<\/a> for running a pod using play kube.<\/p>\n\n\n\n

Modify pod.yaml to include volumes for containers<\/strong><\/p>\n\n\n\n

apiVersion: v1\r\nkind: Pod\r\nmetadata:\r\n  labels:\r\n    app: wordpress\r\n  name: wordpress\r\nspec:\r\n  containers:\r\n    - image: docker.io\/mysql:8.0 # MySQL Image\r\n      name: db\r\n      envFrom:\r\n        - configMapRef:\r\n            name: config # Load Environment Variables from ConfigMap\r\n      ports:\r\n        - containerPort: 3306 # MySQL Container Port\r\n          hostPort: 3306 # MySQL Host Port\r\n          name: mysql\r\n      volumeMounts:\r\n      - mountPath: \/var\/lib\/mysql # directory in the container which is mounted\r\n        name: wordpress-db # volume name\r\n    - image: docker.io\/wordpress:6.2.1-apache # WordPress Image\r\n      name: ui\r\n      ports:\r\n        - containerPort: 80 # WordPress Container Port\r\n          hostPort: 8080 # WordPress Host Port\r\n          name: wordpress\r\n      envFrom:\r\n        - configMapRef:\r\n            name: config # Load Environment Variables from ConfigMap\r\n      volumeMounts:\r\n      - name: wordpress-ui # volume name\r\n        mountPath: \/var\/www\/html # directory in the container which is mounted\r\n  restartPolicy: Always\r\n  volumes:\r\n    - name: wordpress-db # volume name for db\r\n      hostPath:\r\n        path: \/home\/hyrule\/pod-volumes\/wordpress-db # host path for db volume, change accordingly\r\n        type: Directory\r\n    - name: wordpress-ui\r\n      hostPath:\r\n        path: \/home\/hyrule\/pod-volumes\/wordpress-ui # host path for ui volume, change accordingly\r\n        type: Directory<\/code><\/pre>\n\n\n\n

Create directories in host system. Change below command accordingly based on pod.yaml<\/strong><\/p>\n\n\n\n

mkdir -p  \/home\/hyrule\/pod-volumes\/wordpress-db\nmkdir -p \/home\/hyrule\/pod-volumes\/wordpress-ui<\/code><\/pre>\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\/320"}],"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=320"}],"version-history":[{"count":5,"href":"http:\/\/192.168.0.142\/wp-json\/wp\/v2\/posts\/320\/revisions"}],"predecessor-version":[{"id":502,"href":"http:\/\/192.168.0.142\/wp-json\/wp\/v2\/posts\/320\/revisions\/502"}],"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=320"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/192.168.0.142\/wp-json\/wp\/v2\/categories?post=320"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/192.168.0.142\/wp-json\/wp\/v2\/tags?post=320"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}