1podman-generate-kube(1)()                            podman-generate-kube(1)()
2
3
4

NAME

6       podman-generate-kube  -  Generate  Kubernetes YAML based on containers,
7       pods or volumes
8
9

SYNOPSIS

11       podman generate kube [options] container... | pod... | volume...
12
13

DESCRIPTION

15       podman generate kube will generate Kubernetes YAML  (v1  specification)
16       from  Podman containers, pods or volumes. Regardless of whether the in‐
17       put is for containers or pods, Podman will always generate the specifi‐
18       cation  as  a Pod. The input may be in the form of one or more contain‐
19       ers, pods or 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: When using volumes and generating a Kubernetes YAML  for  an  un‐
55       privileged  and rootless podman container on an SELinux enabled system,
56       one of the following options must be completed:
57         * Add the "privileged: true" option to the pod spec
58         * Add type: spc_t under the securityContext seLinuxOptions in the pod
59       spec
60         * Relabel the volume via the CLI command chcon -t container_file_t -R
61       <directory>
62
63
64       Once completed, the correct permissions will be in place to access  the
65       volume when the pod/container is created in a Kubernetes cluster.
66
67
68       Note  that the generated Kubernetes YAML file can be used to re-run the
69       deployment via podman-play-kube(1).
70
71

OPTIONS

73   --filename, -f=filename
74       Output to the given file, instead of STDOUT. If the  file  already  ex‐
75       ists, generate kube will refuse to replace it and return an error.
76
77
78   --service, -s
79       Generate  a  Kubernetes service object in addition to the Pods. Used to
80       generate a Service specification for the corresponding Pod  output.  In
81       particular,  if the object has portmap bindings, the service specifica‐
82       tion will include a NodePort declaration to expose the service. A  ran‐
83       dom port is assigned by Podman in the specification.
84
85

EXAMPLES

87       Create Kubernetes Pod YAML for a container called some-mariadb.
88
89
90              $ sudo podman generate kube some-mariadb
91              # Save the output of this file and use kubectl create -f to import
92              # it into Kubernetes.
93              #
94              # Created with podman-0.11.2-dev
95              apiVersion: v1
96              kind: Pod
97              metadata:
98                creationTimestamp: 2018-12-03T19:07:59Z
99                labels:
100                  app: some-mariadb
101                name: some-mariadb-libpod
102              spec:
103                containers:
104                - command:
105                  - docker-entrypoint.sh
106                  - mysqld
107                  env:
108                  - name: HOSTNAME
109                  - name: GOSU_VERSION
110                    value: "1.10"
111                  - name: GPG_KEYS
112                    value: "199369E5404BD5FC7D2FE43BCBCB082A1BB943DB \t177F4010FE56CA3336300305F1656F24C74CD1D8
113                      \t430BDF5C56E7C94E848EE60C1C4CBDCDCD2EFD2A \t4D1BB29D63D98E422B2113B19334A25F8507EFA5"
114                  - name: MARIADB_MAJOR
115                    value: "10.3"
116                  - name: MARIADB_VERSION
117                    value: 1:10.3.10+maria~bionic
118                  - name: MYSQL_ROOT_PASSWORD
119                    value: x
120                  image: quay.io/baude/demodb:latest
121                  name: some-mariadb
122                  ports:
123                  - containerPort: 3306
124                    hostPort: 36533
125                  resources: {}
126                  securityContext:
127                    capabilities:
128                      drop:
129                      - CAP_MKNOD
130                      - CAP_NET_RAW
131                      - CAP_AUDIT_WRITE
132                  tty: true
133              status: {}
134
135
136
137       Create   Kubernetes  Pod  YAML  for  a  container  with  the  directory
138       /home/user/my-data on the host bind-mounted in the container  to  /vol‐
139       ume.
140
141
142              $ podman generate kube my-container-with-bind-mounted-data
143              # Save the output of this file and use kubectl create -f to import
144              # it into Kubernetes.
145              #
146              # Created with podman-3.1.0-dev
147              apiVersion: v1
148              kind: Pod
149              metadata:
150                creationTimestamp: "2021-03-18T16:26:08Z"
151                labels:
152                  app: my-container-with-bind-mounted-data
153                name: my-container-with-bind-mounted-data
154              spec:
155                containers:
156                - command:
157                  - /bin/sh
158                  image: docker.io/library/alpine:latest
159                  name: test-bind-mount
160                  resources: {}
161                  securityContext:
162                    capabilities:
163                      drop:
164                      - CAP_MKNOD
165                      - CAP_NET_RAW
166                      - CAP_AUDIT_WRITE
167                  volumeMounts:
168                  - mountPath: /volume
169                    name: home-user-my-data-host
170                restartPolicy: Never
171                volumes:
172                - hostPath:
173                    path: /home/user/my-data
174                    type: Directory
175                  name: home-user-my-data-host
176              status: {}
177
178
179
180       Create Kubernetes Pod YAML for a container with the named volume price‐
181       less-data mounted in the container at /volume.
182
183
184              $ podman generate kube my-container-using-priceless-data
185              # Save the output of this file and use kubectl create -f to import
186              # it into Kubernetes.
187              #
188              # Created with podman-3.1.0-dev
189              apiVersion: v1
190              kind: Pod
191              metadata:
192                creationTimestamp: "2021-03-18T16:26:08Z"
193                labels:
194                  app: my-container-using-priceless-data
195                name: my-container-using-priceless-data
196              spec:
197                containers:
198                - command:
199                  - /bin/sh
200                  image: docker.io/library/alpine:latest
201                  name: test-bind-mount
202                  resources: {}
203                  securityContext:
204                    capabilities:
205                      drop:
206                      - CAP_MKNOD
207                      - CAP_NET_RAW
208                      - CAP_AUDIT_WRITE
209                  volumeMounts:
210                  - mountPath: /volume
211                    name: priceless-data-pvc
212                restartPolicy: Never
213                volumes:
214                - name: priceless-data-pvc
215                  persistentVolumeClaim:
216                    claimName: priceless-data
217              status: {}
218
219
220
221       Create Kubernetes Pod YAML for a pod called demoweb and include a  ser‐
222       vice.
223
224
225              $ sudo podman generate kube -s demoweb
226              # Save the output of this file and use kubectl create -f to import
227              # it into Kubernetes.
228              #
229              # Created with podman-0.12.2-dev
230              apiVersion: v1
231              kind: Pod
232              metadata:
233                creationTimestamp: 2018-12-18T15:16:06Z
234                labels:
235                  app: demoweb
236                name: demoweb-libpod
237              spec:
238                containers:
239                - command:
240                  - python3
241                  - /root/code/graph.py
242                  image: quay.io/baude/demoweb:latest
243                  name: practicalarchimedes
244                  resources: {}
245                  tty: true
246                  workingDir: /root/code
247              status: {}
248              ---
249              apiVersion: v1
250              kind: Service
251              metadata:
252                creationTimestamp: 2018-12-18T15:16:06Z
253                labels:
254                  app: demoweb
255                name: demoweb-libpod
256              spec:
257                ports:
258                - name: "8050"
259                  nodePort: 31269
260                  port: 8050
261                  targetPort: 0
262                selector:
263                  app: demoweb
264                type: NodePort
265              status:
266                loadBalancer: {}
267
268
269

SEE ALSO

271       podman(1), podman-container(1), podman-pod(1), podman-play-kube(1)
272
273

HISTORY

275       December 2018, Originally compiled by Brent Baude (bbaude at redhat dot
276       com)
277
278
279
280                                                     podman-generate-kube(1)()
Impressum