1podman-generate-kube(1)() podman-generate-kube(1)()
2
3
4
6 podman-generate-kube - Generate Kubernetes YAML based on containers,
7 pods or volumes
8
9
11 podman generate kube [options] container... | pod... | volume...
12
13
15 podman generate kube will generate Kubernetes YAML (v1 specification)
16 from Podman containers, pods or volumes. Whether the input is for con‐
17 tainers or pods, Podman will always generate the specification as a
18 Pod. The input may be in the form of one or more containers, pods or
19 volumes names or IDs.
20
21
22 Podman Containers or Pods
23
24
25 Volumes appear in the generated YAML according to two different volume
26 types. Bind-mounted volumes become hostPath volume types and named vol‐
27 umes become persistentVolumeClaim volume types. Generated hostPath vol‐
28 ume types will be one of three subtypes depending on the state of the
29 host path: DirectoryOrCreate when no file or directory exists at the
30 host, Directory when host path is a directory, or File when host path
31 is a file. The value for claimName for a persistentVolumeClaim is the
32 name of the named volume registered in Podman.
33
34
35 Potential name conflicts between volumes are avoided by using a stan‐
36 dard naming scheme for each volume type. The hostPath volume types are
37 named according to the path on the host machine, replacing forward
38 slashes with hyphens less any leading and trailing forward slashes. The
39 special case of the filesystem root, /, translates to the name root.
40 Additionally, the name is suffixed with -host to avoid naming conflicts
41 with persistentVolumeClaim volumes. Each persistentVolumeClaim volume
42 type uses the name of its associated named volume suffixed with -pvc.
43
44
45 Note that if an init container is created with type once and the pod
46 has been started, the init container will not show up in the generated
47 kube YAML as once type init containers are deleted after they are run.
48 If the pod has only been created and not started, it will be in the
49 generated kube YAML. Init containers created with type always will al‐
50 ways be generated in the kube YAML as they are never deleted, even af‐
51 ter running to completion.
52
53
54 Note that the generated Kubernetes YAML file can be used to re-run the
55 deployment via podman-play-kube(1).
56
57
59 --filename, -f=filename
60 Output to the given file, instead of STDOUT. If the file already ex‐
61 ists, generate kube will refuse to replace it and return an error.
62
63
64 --service, -s
65 Generate a Kubernetes service object in addition to the Pods. Used to
66 generate a Service specification for the corresponding Pod output. In
67 particular, if the object has portmap bindings, the service specifica‐
68 tion will include a NodePort declaration to expose the service. A ran‐
69 dom port is assigned by Podman in the specification.
70
71
73 Create Kubernetes Pod YAML for a container called some-mariadb.
74
75
76 $ sudo podman generate kube some-mariadb
77 # Save the output of this file and use kubectl create -f to import
78 # it into Kubernetes.
79 #
80 # Created with podman-0.11.2-dev
81 apiVersion: v1
82 kind: Pod
83 metadata:
84 creationTimestamp: 2018-12-03T19:07:59Z
85 labels:
86 app: some-mariadb
87 name: some-mariadb-libpod
88 spec:
89 containers:
90 - command:
91 - docker-entrypoint.sh
92 - mysqld
93 env:
94 - name: HOSTNAME
95 - name: GOSU_VERSION
96 value: "1.10"
97 - name: GPG_KEYS
98 value: "199369E5404BD5FC7D2FE43BCBCB082A1BB943DB \t177F4010FE56CA3336300305F1656F24C74CD1D8
99 \t430BDF5C56E7C94E848EE60C1C4CBDCDCD2EFD2A \t4D1BB29D63D98E422B2113B19334A25F8507EFA5"
100 - name: MARIADB_MAJOR
101 value: "10.3"
102 - name: MARIADB_VERSION
103 value: 1:10.3.10+maria~bionic
104 - name: MYSQL_ROOT_PASSWORD
105 value: x
106 image: quay.io/baude/demodb:latest
107 name: some-mariadb
108 ports:
109 - containerPort: 3306
110 hostPort: 36533
111 resources: {}
112 securityContext:
113 capabilities:
114 drop:
115 - CAP_MKNOD
116 - CAP_NET_RAW
117 - CAP_AUDIT_WRITE
118 tty: true
119 status: {}
120
121
122
123 Create Kubernetes Pod YAML for a container with the directory
124 /home/user/my-data on the host bind-mounted in the container to /vol‐
125 ume.
126
127
128 $ podman generate kube my-container-with-bind-mounted-data
129 # Save the output of this file and use kubectl create -f to import
130 # it into Kubernetes.
131 #
132 # Created with podman-3.1.0-dev
133 apiVersion: v1
134 kind: Pod
135 metadata:
136 creationTimestamp: "2021-03-18T16:26:08Z"
137 labels:
138 app: my-container-with-bind-mounted-data
139 name: my-container-with-bind-mounted-data
140 spec:
141 containers:
142 - command:
143 - /bin/sh
144 image: docker.io/library/alpine:latest
145 name: test-bind-mount
146 resources: {}
147 securityContext:
148 capabilities:
149 drop:
150 - CAP_MKNOD
151 - CAP_NET_RAW
152 - CAP_AUDIT_WRITE
153 volumeMounts:
154 - mountPath: /volume
155 name: home-user-my-data-host
156 restartPolicy: Never
157 volumes:
158 - hostPath:
159 path: /home/user/my-data
160 type: Directory
161 name: home-user-my-data-host
162 status: {}
163
164
165
166 Create Kubernetes Pod YAML for a container with the named volume price‐
167 less-data mounted in the container at /volume.
168
169
170 $ podman generate kube my-container-using-priceless-data
171 # Save the output of this file and use kubectl create -f to import
172 # it into Kubernetes.
173 #
174 # Created with podman-3.1.0-dev
175 apiVersion: v1
176 kind: Pod
177 metadata:
178 creationTimestamp: "2021-03-18T16:26:08Z"
179 labels:
180 app: my-container-using-priceless-data
181 name: my-container-using-priceless-data
182 spec:
183 containers:
184 - command:
185 - /bin/sh
186 image: docker.io/library/alpine:latest
187 name: test-bind-mount
188 resources: {}
189 securityContext:
190 capabilities:
191 drop:
192 - CAP_MKNOD
193 - CAP_NET_RAW
194 - CAP_AUDIT_WRITE
195 volumeMounts:
196 - mountPath: /volume
197 name: priceless-data-pvc
198 restartPolicy: Never
199 volumes:
200 - name: priceless-data-pvc
201 persistentVolumeClaim:
202 claimName: priceless-data
203 status: {}
204
205
206
207 Create Kubernetes Pod YAML for a pod called demoweb and include a ser‐
208 vice.
209
210
211 $ sudo podman generate kube -s demoweb
212 # Save the output of this file and use kubectl create -f to import
213 # it into Kubernetes.
214 #
215 # Created with podman-0.12.2-dev
216 apiVersion: v1
217 kind: Pod
218 metadata:
219 creationTimestamp: 2018-12-18T15:16:06Z
220 labels:
221 app: demoweb
222 name: demoweb-libpod
223 spec:
224 containers:
225 - command:
226 - python3
227 - /root/code/graph.py
228 image: quay.io/baude/demoweb:latest
229 name: practicalarchimedes
230 resources: {}
231 tty: true
232 workingDir: /root/code
233 status: {}
234 ---
235 apiVersion: v1
236 kind: Service
237 metadata:
238 creationTimestamp: 2018-12-18T15:16:06Z
239 labels:
240 app: demoweb
241 name: demoweb-libpod
242 spec:
243 ports:
244 - name: "8050"
245 nodePort: 31269
246 port: 8050
247 targetPort: 0
248 selector:
249 app: demoweb
250 type: NodePort
251 status:
252 loadBalancer: {}
253
254
255
257 podman(1), podman-container(1), podman-pod(1), podman-play-kube(1)
258
259
261 December 2018, Originally compiled by Brent Baude (bbaude at redhat dot
262 com)
263
264
265
266 podman-generate-kube(1)()