github.com/hanks177/podman/v4@v4.1.3-0.20220613032544-16d90015bc83/docs/source/markdown/podman-play-kube.1.md (about) 1 % podman-play-kube(1) 2 3 ## NAME 4 podman-play-kube - Create containers, pods or volumes based on Kubernetes YAML 5 6 ## SYNOPSIS 7 **podman play kube** [*options*] *file.yml|-* 8 9 ## DESCRIPTION 10 **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 output. If the yaml file is specified as "-" then `podman play kube` will read the YAML file from stdin. 11 Using the `--down` command line option, it is also capable of tearing down the pods created by a previous run of `podman play kube`. 12 Using the `--replace` command line option, it will tear down the pods(if any) created by a previous run of `podman play kube` and recreate the pods with the Kubernetes YAML file. 13 Ideally the input file would be one created by Podman (see podman-generate-kube(1)). This would guarantee a smooth import and expected results. 14 15 Currently, the supported Kubernetes kinds are: 16 - Pod 17 - Deployment 18 - PersistentVolumeClaim 19 - ConfigMap 20 21 `Kubernetes Pods or Deployments` 22 23 Only two volume types are supported by play kube, the *hostPath* and *persistentVolumeClaim* volume types. For the *hostPath* volume type, only the *default (empty)*, *DirectoryOrCreate*, *Directory*, *FileOrCreate*, *File*, *Socket*, *CharDevice* and *BlockDevice* subtypes are supported. Podman interprets the value of *hostPath* *path* as a file path when it contains at least one forward slash, otherwise Podman treats the value as the name of a named volume. When using a *persistentVolumeClaim*, the value for *claimName* is the name for the Podman named volume. 24 25 Note: When playing a kube YAML with init containers, the init container will be created with init type value `always`. 26 27 Note: *hostPath* volume types created by play kube will be given an SELinux shared label (z), bind mounts are not relabeled (use `chcon -t container_file_t -R <directory>`). 28 29 Note: If the `:latest` tag is used, Podman will attempt to pull the image from a registry. If the image was built locally with Podman or Buildah, it will have `localhost` as the domain, in that case, Podman will use the image from the local store even if it has the `:latest` tag. 30 31 `Kubernetes PersistentVolumeClaims` 32 33 A Kubernetes PersistentVolumeClaim represents a Podman named volume. Only the PersistentVolumeClaim name is required by Podman to create a volume. Kubernetes annotations can be used to make use of the available options for Podman volumes. 34 35 - volume.podman.io/driver 36 - volume.podman.io/device 37 - volume.podman.io/type 38 - volume.podman.io/uid 39 - volume.podman.io/gid 40 - volume.podman.io/mount-options 41 42 Play kube is capable of building images on the fly given the correct directory layout and Containerfiles. This 43 option is not available for remote clients, including Mac and Windows (excluding WSL2) machines, yet. Consider the following excerpt from a YAML file: 44 ``` 45 apiVersion: v1 46 kind: Pod 47 metadata: 48 ... 49 spec: 50 containers: 51 - command: 52 - top 53 - name: container 54 value: podman 55 image: foobar 56 ... 57 ``` 58 59 If there is a directory named `foobar` in the current working directory with a file named `Containerfile` or `Dockerfile`, 60 Podman play kube will build that image and name it `foobar`. An example directory structure for this example would look 61 like: 62 ``` 63 |- mykubefiles 64 |- myplayfile.yaml 65 |- foobar 66 |- Containerfile 67 ``` 68 69 The build will consider `foobar` to be the context directory for the build. If there is an image in local storage 70 called `foobar`, the image will not be built unless the `--build` flag is used. Use `--build=false` to completely 71 disable builds. 72 73 `Kubernetes ConfigMap` 74 75 Kubernetes ConfigMap can be referred as a source of environment variables or volumes in Pods or Deployments. 76 ConfigMaps aren't a standalone object in Podman; instead, when a container uses a ConfigMap, Podman will create environment variables or volumes as needed. 77 78 For example, the following YAML document defines a ConfigMap and then uses it in a Pod: 79 80 ``` 81 apiVersion: v1 82 kind: ConfigMap 83 metadata: 84 name: foo 85 data: 86 FOO: bar 87 --- 88 apiVersion: v1 89 kind: Pod 90 metadata: 91 name: foobar 92 spec: 93 containers: 94 - command: 95 - top 96 name: container-1 97 image: foobar 98 envFrom: 99 - configMapRef: 100 name: foo 101 optional: false 102 ``` 103 104 and as a result environment variable `FOO` will be set to `bar` for container `container-1`. 105 106 ## OPTIONS 107 108 #### **--annotation**=*key=value* 109 110 Add an annotation to the container or pod. The format is key=value. 111 The **--annotation** option can be set multiple times. 112 113 #### **--authfile**=*path* 114 115 Path of the authentication file. Default is ${XDG\_RUNTIME\_DIR}/containers/auth.json, which is set using `podman login`. 116 If the authorization state is not found there, $HOME/.docker/config.json is checked, which is set using `docker login`. 117 118 Note: You can also override the default path of the authentication file by setting the REGISTRY\_AUTH\_FILE 119 environment variable. `export REGISTRY_AUTH_FILE=path` 120 121 #### **--build** 122 123 Build images even if they are found in the local storage. Use `--build=false` to completely disable builds. (This option is not available with the remote Podman client) 124 125 #### **--cert-dir**=*path* 126 127 Use certificates at *path* (\*.crt, \*.cert, \*.key) to connect to the registry. (Default: /etc/containers/certs.d) 128 Please refer to containers-certs.d(5) for details. (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines) 129 130 #### **--configmap**=*path* 131 132 Use Kubernetes configmap YAML at path to provide a source for environment variable values within the containers of the pod. (This option is not available with the remote Podman client) 133 134 Note: The *--configmap* option can be used multiple times or a comma-separated list of paths can be used to pass multiple Kubernetes configmap YAMLs. 135 136 #### **--context-dir**=*path* 137 138 Use *path* as the build context directory for each image. Requires --build option be true. (This option is not available with the remote Podman client) 139 140 #### **--creds** 141 142 The [username[:password]] to use to authenticate with the registry if required. 143 If one or both values are not supplied, a command line prompt will appear and the 144 value can be entered. The password is entered without echo. 145 146 #### **--down** 147 148 Tears down the pods that were created by a previous run of `play kube`. The pods are stopped and then 149 removed. Any volumes created are left intact. 150 151 #### **--help**, **-h** 152 153 Print usage statement 154 155 #### **--ip**=*IP address* 156 157 Assign a static ip address to the pod. This option can be specified several times when play kube creates more than one pod. 158 Note: When joining multiple networks you should use the **--network name:ip=\<ip\>** syntax. 159 160 #### **--log-driver**=driver 161 162 Set logging driver for all created containers. 163 164 #### **--log-opt**=*name*=*value* 165 166 Set custom logging configuration. The following *name*s are supported: 167 168 - **path**: specify a path to the log file 169 (e.g. **--log-opt path=/var/log/container/mycontainer.json**); 170 171 - **max-size**: specify a max size of the log file 172 (e.g. **--log-opt max-size=10mb**); 173 174 - **tag**: specify a custom log tag for the container 175 (e.g. **--log-opt tag="{{.ImageName}}"**. 176 177 It supports the same keys as **podman inspect --format**. 178 179 This option is currently supported only by the **journald** log driver. 180 181 #### **--mac-address**=*MAC address* 182 183 Assign a static mac address to the pod. This option can be specified several times when play kube creates more than one pod. 184 Note: When joining multiple networks you should use the **--network name:mac=\<mac\>** syntax. 185 186 #### **--network**=*mode*, **--net** 187 188 Change the network mode of the pod. The host network mode should be configured in the YAML file. 189 Valid _mode_ values are: 190 191 - **bridge[:OPTIONS,...]**: Create a network stack on the default bridge. This is the default for rootful containers. It is possible to specify these additional options: 192 - **alias=name**: Add network-scoped alias for the container. 193 - **ip=IPv4**: Specify a static ipv4 address for this container. 194 - **ip=IPv6**: Specify a static ipv6 address for this container. 195 - **mac=MAC**: Specify a static mac address for this container. 196 - **interface_name**: Specify a name for the created network interface inside the container. 197 198 For example to set a static ipv4 address and a static mac address, use `--network bridge:ip=10.88.0.10,mac=44:33:22:11:00:99`. 199 - \<network name or ID\>[:OPTIONS,...]: Connect to a user-defined network; this is the network name or ID from a network created by **[podman network create](podman-network-create.1.md)**. Using the network name implies the bridge network mode. It is possible to specify the same options described under the bridge mode above. You can use the **--network** option multiple times to specify additional networks. 200 - **none**: Create a network namespace for the container but do not configure network interfaces for it, thus the container has no network connectivity. 201 - **container:**_id_: Reuse another container's network stack. 202 - **ns:**_path_: Path to a network namespace to join. 203 - **private**: Create a new namespace for the container. This will use the **bridge** mode for rootful containers and **slirp4netns** for rootless ones. 204 - **slirp4netns[:OPTIONS,...]**: use **slirp4netns**(1) to create a user network stack. This is the default for rootless containers. It is possible to specify these additional options, they can also be set with `network_cmd_options` in containers.conf: 205 - **allow_host_loopback=true|false**: Allow the slirp4netns to reach the host loopback IP (`10.0.2.2`). Default is false. 206 - **mtu=MTU**: Specify the MTU to use for this network. (Default is `65520`). 207 - **cidr=CIDR**: Specify ip range to use for this network. (Default is `10.0.2.0/24`). 208 - **enable_ipv6=true|false**: Enable IPv6. Default is true. (Required for `outbound_addr6`). 209 - **outbound_addr=INTERFACE**: Specify the outbound interface slirp should bind to (ipv4 traffic only). 210 - **outbound_addr=IPv4**: Specify the outbound ipv4 address slirp should bind to. 211 - **outbound_addr6=INTERFACE**: Specify the outbound interface slirp should bind to (ipv6 traffic only). 212 - **outbound_addr6=IPv6**: Specify the outbound ipv6 address slirp should bind to. 213 - **port_handler=rootlesskit**: Use rootlesskit for port forwarding. Default. 214 Note: Rootlesskit changes the source IP address of incoming packets to an IP address in the container network namespace, usually `10.0.2.100`. If your application requires the real source IP address, e.g. web server logs, use the slirp4netns port handler. The rootlesskit port handler is also used for rootless containers when connected to user-defined networks. 215 - **port_handler=slirp4netns**: Use the slirp4netns port forwarding, it is slower than rootlesskit but preserves the correct source IP address. This port handler cannot be used for user-defined networks. 216 217 #### **--no-hosts** 218 219 Do not create /etc/hosts for the pod. 220 By default, Podman will manage /etc/hosts, adding the container's own IP address and any hosts from **--add-host**. 221 **--no-hosts** disables this, and the image's **/etc/host** will be preserved unmodified. 222 This option conflicts with host added in the Kubernetes YAML. 223 224 #### **--quiet**, **-q** 225 226 Suppress output information when pulling images 227 228 #### **--replace** 229 230 Tears down the pods created by a previous run of `play kube` and recreates the pods. This option is used to keep the existing pods up to date based upon the Kubernetes YAML. 231 232 #### **--seccomp-profile-root**=*path* 233 234 Directory path for seccomp profiles (default: "/var/lib/kubelet/seccomp"). (This option is not available with the remote Podman client, including Mac and Windows (excluding WSL2) machines) 235 236 #### **--start** 237 238 Start the pod after creating it, set to false to only create it. 239 240 #### **--tls-verify** 241 242 Require HTTPS and verify certificates when contacting registries (default: true). If explicitly set to true, 243 then TLS verification will be used. If set to false, then TLS verification will not be used. If not specified, 244 TLS verification will be used unless the target registry is listed as an insecure registry in registries.conf. 245 246 #### **--userns**=*mode* 247 248 Set the user namespace mode for the container. It defaults to the **PODMAN_USERNS** environment variable. An empty value ("") means user namespaces are disabled unless an explicit mapping is set with the **--uidmap** and **--gidmap** options. 249 250 Rootless user --userns=Key mappings: 251 252 Key | Host User | Container User 253 ----------|---------------|--------------------- 254 "" |$UID |0 (Default User account mapped to root user in container.) 255 keep-id |$UID |$UID (Map user account to same UID within container.) 256 auto |$UID | nil (Host User UID is not mapped into container.) 257 nomap |$UID | nil (Host User UID is not mapped into container.) 258 259 Valid _mode_ values are: 260 261 **auto**[:_OPTIONS,..._]: automatically create a unique user namespace. 262 263 The `--userns=auto` flag, requires that the user name `containers` and a range of subordinate user ids that the Podman container is allowed to use be specified in the /etc/subuid and /etc/subgid files. 264 265 Example: `containers:2147483647:2147483648`. 266 267 Podman allocates unique ranges of UIDs and GIDs from the `containers` subordinate user ids. The size of the ranges is based on the number of UIDs required in the image. The number of UIDs and GIDs can be overridden with the `size` option. The `auto` options currently does not work in rootless mode 268 269 Valid `auto` options: 270 271 - *gidmapping*=_CONTAINER_GID:HOST_GID:SIZE_: to force a GID mapping to be present in the user namespace. 272 - *size*=_SIZE_: to specify an explicit size for the automatic user namespace. e.g. `--userns=auto:size=8192`. If `size` is not specified, `auto` will estimate a size for the user namespace. 273 - *uidmapping*=_CONTAINER_UID:HOST_UID:SIZE_: to force a UID mapping to be present in the user namespace. 274 275 **container:**_id_: join the user namespace of the specified container. 276 277 **host**: create a new namespace for the container. 278 279 **keep-id**: creates a user namespace where the current rootless user's UID:GID are mapped to the same values in the container. This option is not allowed for containers created by the root user. 280 281 **nomap**: creates a user namespace where the current rootless user's UID:GID are not mapped into the container. This option is not allowed for containers created by the root user. 282 283 **ns:**_namespace_: run the pod in the given existing user namespace. 284 285 ## EXAMPLES 286 287 Recreate the pod and containers as described in a file called `demo.yml` 288 ``` 289 $ podman play kube demo.yml 290 52182811df2b1e73f36476003a66ec872101ea59034ac0d4d3a7b40903b955a6 291 ``` 292 293 Recreate the pod and containers as described in a file `demo.yml` sent to stdin 294 ``` 295 $ cat demo.yml | podman play kube - 296 52182811df2b1e73f36476003a66ec872101ea59034ac0d4d3a7b40903b955a6 297 298 ``` 299 Teardown the pod and containers as described in a file `demo.yml` 300 ``` 301 $ podman play kube --down demo.yml 302 Pods stopped: 303 52182811df2b1e73f36476003a66ec872101ea59034ac0d4d3a7b40903b955a6 304 Pods removed: 305 52182811df2b1e73f36476003a66ec872101ea59034ac0d4d3a7b40903b955a6 306 ``` 307 308 Provide `configmap-foo.yml` and `configmap-bar.yml` as sources for environment variables within the containers. 309 ``` 310 $ podman play kube demo.yml --configmap configmap-foo.yml,configmap-bar.yml 311 52182811df2b1e73f36476003a66ec872101ea59034ac0d4d3a7b40903b955a6 312 313 $ podman play kube demo.yml --configmap configmap-foo.yml --configmap configmap-bar.yml 314 52182811df2b1e73f36476003a66ec872101ea59034ac0d4d3a7b40903b955a6 315 ``` 316 317 Create a pod connected to two networks (called net1 and net2) with a static ip 318 ``` 319 $ podman play kube demo.yml --network net1:ip=10.89.1.5 --network net2:ip=10.89.10.10 320 52182811df2b1e73f36476003a66ec872101ea59034ac0d4d3a7b40903b955a6 321 ``` 322 323 Please take into account that CNI networks must be created first using podman-network-create(1). 324 325 ## SEE ALSO 326 **[podman(1)](podman.1.md)**, **[podman-play(1)](podman-play.1.md)**, **[podman-network-create(1)](podman-network-create.1.md)**, **[podman-generate-kube(1)](podman-generate-kube.1.md)**, **[containers-certs.d(5)](https://github.com/containers/image/blob/main/docs/containers-certs.d.5.md)** 327 328 ## HISTORY 329 December 2018, Originally compiled by Brent Baude (bbaude at redhat dot com)