podman-kube-generate(1)
π podman-kube-generate β the podman kube generate glow-up π
okay bestie, pull up a chair, this is the podman-kube-generate page from the General Commands Manual and it's literally about turning your containers, pods and volumes into Kubernetes YAML. main character energy fr fr π
β¨ NAME β¨
podman-kube-generate β Generate Kubernetes YAML based on containers, pods or volumes π¦
β¨ SYNOPSIS β¨
podman kube generate [options] container... | pod... | volume...
β¨ DESCRIPTION β¨
so podman kube generate generates Kubernetes YAML (v1 specification) from Podman containers, pods or volumes. regardless of whether the input is for containers or pods, Podman generates the specification as a Pod by default. the input can be one or more containers, pods or volumes β names or IDs, either one. π
π«Ά Podman Containers or Pods
Volumes show up in the generated YAML according to two different volume types. Bind-mounted volumes become hostPath volume types and named volumes become persistentVolumeClaim volume types. Generated hostPath volume types are one of three subtypes, depending on the state of the host path:
DirectoryOrCreateβ when no file or directory exists at the hostDirectoryβ when the host path is a directoryFileβ when the host path is a file
The value for claimName for a persistentVolumeClaim is the name of the named volume registered in Podman.
Potential name conflicts between volumes are avoided by using a standard naming scheme for each volume type. The hostPath volume types are named according to the path on the host machine, replacing forward slashes with hyphens, less any leading and trailing forward slashes. The special case of the filesystem root, /, translates to the name root. Additionally, the name is suffixed with -host to avoid naming conflicts with persistentVolumeClaim volumes. Each persistentVolumeClaim volume type uses the name of its associated named volume suffixed with -pvc. β¨ no cap, the naming scheme really does eat β¨
Note that if an init container is created with type once and the pod has been started, it does not show up in the generated kube YAML, because once type init containers are deleted after they are run. If the pod has only been created and not started, it is in the generated kube YAML. Init containers created with type always are always generated in the kube YAML, as they are never deleted, even after running to completion. π
Note: when using volumes and generating a Kubernetes YAML for an unprivileged and rootless podman container on an SELinux enabled system, one of the following options must be completed: - Add the"privileged: true"option to the pod spec - Addtype: spc_tunder thesecurityContextseLinuxOptionsin the pod spec - Relabel the volume via the CLI commandchcon -t container_file_t -R <directory>
Once completed, the correct permissions are in place to access the volume when the pod/container is created in a Kubernetes cluster. π
Note that the generated Kubernetes YAML file can be used to re-run the deployment via podman-play-kube(1).
Note that if the pod being generated was created with the --infra-name flag set, then the generated kube yaml will have the io.podman.annotations.infra.name set, where the value is the name of the infra container set by the user. π
Note that both Deployment and DaemonSet can only have restartPolicy set to Always.
Note that Job can only have restartPolicy set to OnFailure or Never. By default, podman sets it to Never when generating a kube yaml using kube generate. periodt. π
πΈ OPTIONS πΈ
--filename,-f=filename β Output to the given file instead of STDOUT. If the file already exists,kube generaterefuses to replace it and returns an error. π rude but fair--podman-onlyβ Add podman-only reserved annotations in the generated YAML file (Cannot be used by Kubernetes)--replicas,-r=replica count β The value to set replicas to when generating a Deployment kind. Note: this can only be set with the option--type=deployment. π--service,-sβ Generate a Kubernetes service object in addition to the Pods. Used to generate a Service specification for the corresponding Pod output. In particular, if the object hasportmapbindings, the service specification includes aNodePortdeclaration to expose the service. A random port is assigned by Podman in the specification. π--type,-t=pod | deployment | daemonset | job β The Kubernetes kind to generate in the YAML file. Currently, the only supported Kubernetes specifications are Pod, Deployment, Job, and DaemonSet. By default, the Pod specification is generated. π
π§ EXAMPLES π§
Create Kubernetes Pod YAML for the specified container.
$ podman kube generate some-mariadb
# Save the output of this file and use kubectl create -f to import
# it into Kubernetes.
#
# Created with podman-4.8.2
# NOTE: If you generated this yaml from an unprivileged and rootless podman container on an SELinux
# enabled system, check the podman generate kube man page for steps to follow to ensure that your pod/container
# has the right permissions to access the volumes added.
---
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2024-01-09T02:24:55Z"
labels:
app: some-mariadb-pod
name: some-mariadb-pod
spec:
containers:
- args:
- mariadbd
env:
- name: MARIADB_ROOT_PASSWORD
value: x
image: docker.io/library/mariadb:10.11
name: some-mariadb
ports:
- containerPort: 3306
hostPort: 34891
volumeMounts:
- mountPath: /var/lib/mysql
name: mariadb_data-pvc
volumes:
- name: mariadb_data-pvc
persistentVolumeClaim:
claimName: mariadb_data
Create Kubernetes Deployment YAML with 3 replicas for the specified container. π
$ podman kube generate --type deployment --replicas 3 dep-ct
r
# Save the output of this file and use kubectl create -f to import
# it into Kubernetes.
#
# Created with podman-4.5.0-dev
apiVersion: apps/v1
kind: Deployment
metadata:
creationTimestamp: "2023-03-27T20:45:08Z"
labels:
app: dep-ctr-pod
name: dep-ctr-pod-deployment
spec:
replicas: 3
selector:
matchLabels:
app: dep-ctr-pod
template:
metadata:
annotations:
io.podman.annotations.ulimit: nofile=524288:524288,nproc=127332:127332
creationTimestamp: "2023-03-27T20:45:08Z"
labels:
app: dep-ctr-pod
name: dep-ctr-pod
spec:
containers:
- command:
- top
image: docker.io/library/alpine:latest
name: dep-ctr
Create Kubernetes Pod YAML for the specified container with the host directory /home/user/my-data bind-mounted onto the container path /volume. π
$ podman kube generate my-container-with-bind-mounted-data
# Save the output of this file and use kubectl create -f to import
# it into Kubernetes.
#
# Created with podman-3.1.0-dev
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2021-03-18T16:26:08Z"
labels:
app: my-container-with-bind-mounted-data
name: my-container-with-bind-mounted-data
spec:
containers:
- command:
- /bin/sh
image: docker.io/library/alpine:latest
name: test-bind-mount
volumeMounts:
- mountPath: /volume
name: home-user-my-data-host
restartPolicy: Never
volumes:
- hostPath:
path: /home/user/my-data
type: Directory
name: home-user-my-data-host
Create Kubernetes Pod YAML for the specified container with named volume priceless-data mounted onto the container path /volume. β¨
$ podman kube generate my-container-using-priceless-data
# Save the output of this file and use kubectl create -f to import
# it into Kubernetes.
#
# Created with podman-3.1.0-dev
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: "2021-03-18T16:26:08Z"
labels:
app: my-container-using-priceless-data
name: my-container-using-priceless-data
spec:
containers:
- command:
- /bin/sh
image: docker.io/library/alpine:latest
name: test-bind-mount
volumeMounts:
- mountPath: /volume
name: priceless-data-pvc
restartPolicy: Never
volumes:
- name: priceless-data-pvc
persistentVolumeClaim:
claimName: priceless-data
Create Kubernetes Pod YAML for the specified pod and include a service. π₯
$ sudo podman kube generate -s demoweb
# Save the output of this file and use kubectl create -f to import
# it into Kubernetes.
#
# Created with podman-0.12.2-dev
apiVersion: v1
kind: Pod
metadata:
creationTimestamp: 2018-12-18T15:16:06Z
labels:
app: demoweb
name: demoweb-libpod
spec:
containers:
- command:
- python3
- /root/code/graph.py
image: quay.io/baude/demoweb:latest
name: practicalarchimedes
tty: true
workingDir: /root/code
---
apiVersion: v1
kind: Service
metadata:
creationTimestamp: 2018-12-18T15:16:06Z
labels:
app: demoweb
name: demoweb-libpod
spec:
ports:
- name: "8050"
nodePort: 31269
port: 8050
targetPort: 0
selector:
app: demoweb
type: NodePort
status:
loadBalancer: {}
π¦ SEE ALSO π¦
podman(1), podman-container(1), podman-pod(1), podman-kube-play(1), podman-kube-down(1)
π HISTORY π
December 2018, Originally compiled by Brent Baude (bbaude at redhat dot com)
and that's the whole page bestie, we literally made it to the end π this was podman-kube-generate(1) from the General Commands Manual, and if you ever need to find it again she's filed right there under her own name. ily, go generate some kube yaml. πβ¨π
π¦ where this page comes from
- arch rolling: podman-docker 6.1.4-1 Β· Apache-2.0
- fedora 43: podman-docker 5:5.6.2-1.fc43 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0
- fedora 43: podman-docker 5:5.8.4-1.fc43
- fedora 43: podman-docker 5:5.8.8-1.fc43
- fedora 43: podman-docker 5:5.8.9-1.fc43 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0
- fedora 44: podman-docker 5:5.8.1-1.fc44 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0
- fedora 44: podman-docker 5:5.8.7-1.fc44
- fedora 44: podman-docker 5:5.8.9-1.fc44 Β· Apache-2.0 AND BSD-2-Clause AND BSD-3-Clause AND ISC AND MIT AND MPL-2.0
- ubuntu resolute: podman-docker 5.7.0+ds2-3build1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms