Podlet

Crates.io GitHub Workflow Status (with event) Crates.io License

Podlet generates podman quadlet (systemd-like) files from a podman command.

demo.gif You can also view the demo on asciinema.

Features

Install

Podlet can be acquired in several ways:

Usage

``` $ podlet -h

Podlet generates podman quadlet (systemd-like) files from a podman command.

Usage: podlet [OPTIONS]

Commands: podman Generate a podman quadlet file from a podman command compose Generate podman quadlet files from a compose file help Print this message or the help of the given subcommand(s)

Options: -f, --file [] Generate a file instead of printing to stdout -u, --unit-directory Generate a file in the podman unit directory instead of printing to stdout [aliases: unit-dir] -n, --name Override the name of the generated file (without the extension) --overwrite Overwrite existing files when generating a file --skip-services-check Skip the check for existing services of the same name -d, --description Add a description to the unit --wants Add (weak) requirement dependencies to the unit --requires Similar to --wants, but adds stronger requirement dependencies --before Configure ordering dependency between units --after Configure ordering dependency between units -i, --install Add an [Install] section to the unit --wanted-by Add (weak) parent dependencies to the unit --required-by Similar to --wanted-by, but adds stronger parent dependencies -h, --help Print help (see more with '--help') -V, --version Print version ```

To generate a quadlet file, just put podlet in front of your podman command!

``` $ podlet podman run quay.io/podman/hello

hello.container

[Container] Image=quay.io/podman/hello ```

This is useful for more complicated commands you are copying. For example, let's create a quadlet file for running caddy. We'll also use a few options for additional sections in the file.

``` $ podlet --file . --install --description Caddy \ podman run \ --restart always \ -p 8000:80 \ -p 8443:443 \ -v ./Caddyfile:/etc/caddy/Caddyfile \ -v caddy_data:/data \ docker.io/library/caddy:latest

Wrote to file: ./caddy.container

$ cat caddy.container

[Unit] Description=Caddy

[Container] Image=docker.io/library/caddy:latest PublishPort=8000:80 PublishPort=8443:443 Volume=./Caddyfile:/etc/caddy/Caddyfile Volume=caddy_data:/data

[Service] Restart=always

[Install] WantedBy=default.target ```

The name for the file was automatically pulled from the image name, but can be overridden with the --name option.

Podlet also supports creating kube, network, and volume quadlet files. However, not all options for their corresponding podman commands are supported by quadlet. Accordingly, those options are also not supported by podlet.

``` $ podlet podman kube play --network pasta --userns auto kube.yaml

[Kube] Yaml=kube.yaml Network=pasta UserNS=auto ```

Use the following commands for more usage information: - podlet --help - podlet podman --help - podlet compose --help

Cautions

Podlet is not (yet) a validator for podman commands. Some podman options are incompatible with each other and most options require specific formatting and/or only accept certain values. However, a few options are fully parsed and validated in order to facilitate creating the quadlet file.

For the kube play, network create, and volume create commands, not all of podman's options are available as not all options are supported by quadlet.

When converting compose files, not all options are supported by podman/quadlet. This is especially true when converting to a pod as some options must be applied to the pod as a whole. If podlet encounters an unsupported option an error will be returned. You will have to remove or comment out unsupported options to proceed.

Podlet is meant to be used with podman v4.5.0 or newer. Some quadlet options are unavailable or behave differently with earlier versions of podman/quadlet.

Contribution

This is my (@k9withabone) first real rust project and is mostly meant as a learning project for myself. That said, contributions, suggestions, and/or comments are appreciated! Feel free to create an issue, discussion, or pull request.

License

All source code for podlet is licensed under the Mozilla Public License v2.0. View the LICENSE file for more information.