Commit Graph

181 Commits

Author SHA1 Message Date
Daniel J Walsh d51911f7b0
Support systemd optional prefix '-' for devices.
Systemd supports unit files with a prefix '-' which
tells the system to check if the content exists before
using it. This would allow the QM project to specify
AddDevice=-/dev/kvm, which would add the /dev/kvm device
to the container iff it exists on the host.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-04-26 14:22:57 -04:00
Ygal Blum 4aced7e3eb Quadlet - do not set log-driver by default
Update e2e tests not to expect the flag
System tests - explicitly set the log driver to be able to parse the output

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-04-13 09:14:40 +03:00
Cedric Staniewski f6a50311c5 quadlet: add `UserNS` option key
The `UserNS` key will replace the `RemapGid`, `RemapUid`, `RemapUidSize`
and `RemapUsers` options which are therefore marked as deprecated by
this commit.

Closes #17984

Signed-off-by: Cedric Staniewski <cedric@gmx.ca>
2023-04-07 17:19:21 +02:00
Cedric Staniewski 443f8d89c9 quadlet: implement `Tmpfs` option
This commit adds an quadlet option `Tmpfs` which can be used to mount a
tmpfs in the container.

Closes #17907

Signed-off-by: Cedric Staniewski <cedric@gmx.ca>
2023-04-03 20:22:02 +02:00
OpenShift Merge Robot 60d16d9f8e
Merge pull request #17961 from ygalblum/quadlet-remap-keepid-map
Quadlet - Support setting UID and GID for --userns=keep-id
2023-03-29 18:01:56 +02:00
Ygal Blum 11e5c2d0fd Quadlet: add support for keep-id with mapping values
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-03-28 16:07:12 +03:00
Ygal Blum da96ff6cc7 Quadlet - treat paths starting with systemd specifiers as absolute
If a path (Yaml, ConfigMap, EnvFile) starts with a systemd path
specifier, treat the path as absolute
Add tests - unit, e2e and bats

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-03-28 10:30:33 +03:00
Ygal Blum 5382997e01 Quadlet - add support for relative path in Volume key in .container file
If the volume source starts with . resolve the path relative to the
location of the unit file

Update the test code to allow verification of regex for the value in key
value arguments
Add the usage of relative paths to the volume and mount test cases
Update the man page

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-03-20 18:54:00 +02:00
Ygal Blum 5d1342fc58 Quadlet - Add support for health checks configuration in .container files
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-03-20 09:53:49 +02:00
restitux cb3cda55f2 Quadlet: add support for setting --ip and --ip6
Signed-off-by: restitux <restitux@ohea.xyz>
2023-03-06 18:36:41 -07:00
Ygal Blum ccc5aa59a0 Quadlet: Add support for the Mount key in .container files
Handle the Mount key
Reuse code from the handling of the Volume key
Add E2E Test
E2E Test - Add checker for KeyValue string
Update man page

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-02-28 16:14:19 +02:00
Ygal Blum 0d75854c52 Quadlet - use the default runtime
Do not set the runtime when processing a .container file
Let Podman choose the runtime based on its configuration

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-02-23 09:29:39 +02:00
Ygal Blum 6a3757b73a Quadlet: Add support for LogDriver key in container and kube units
Allow the user to set the log driver while keeping the default of passthrough

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-02-21 11:56:35 +02:00
Valentin Rothberg c95978f600 kube play: only enforce passthrough in Quadlet
Only enforce the passthrough log driver for Quadlet. Commit 68fbebf
introduced a regression on the `podman-kube@` template as `podman logs`
stopped working and settings from containers.conf were ignored.

Fixes: #17482
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-02-17 11:57:10 +01:00
Daniel J Walsh 3d8936642e
Quadlet use crun specified in containers.conf
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-02-15 05:39:56 +02:00
Valentin Rothberg 7c54d14232 quadlet: add ExecStop
Remove the container in ExecStop to make sure that Quadlet's adheres to
Podman's customizable stop signal/timeout.  Certain programs ignore
SIGTERM which renders the services generated by Quadlet less user
friendly compared to the ones from podman-generate-systemd.

Previously, `systemctl stop` would just hang until systemd's stop
timeout is hit.  Since `podman rm` also removes the CID file, the
additional `rm` can be removed.  Note that `podman rm` will return
immediately if the specified CID file isn't present.

I am working on a short tutorial on Quadlet and hit the issue with a
simple container running `sleep`.  `sleep` ignores SIGTERM and stopping
the service would take forever even with `PodmanArgs=--stop-timeout=0`.

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-02-13 15:21:48 +01:00
OpenShift Merge Robot d1fd399455
Merge pull request #17438 from rhatdan/quadlet
[CI:DOCS] Add tables to podman-systemd.unit man page
2023-02-08 15:54:28 -05:00
Daniel J Walsh 5ed2174097
[CI:DOCS] Add tables to podman-systemd.unit man page
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-02-08 14:19:32 -05:00
Ygal Blum d6dd17fdfe Quadlet: Add support for the Secret key in Container group
Add E2E tests
Add system test
Add to man page

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-02-08 16:12:08 +02:00
Daniel J Walsh 42c7c59dd5
Sort quadlet keys to make it easier to read
[NO NEW TESTS NEEDED]

Since this is just sorting keys.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-02-08 05:45:58 -05:00
Daniel J Walsh acaab3fa72
Add SELinux label types support to quadlet
Add support for disabeling SELinux process separation in the container.
Add support for setting the process type of the container.
Add support for setting the process MCS level of the container.
Add support for setting the file type of the container.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-02-06 12:54:34 -05:00
Daniel J Walsh 928d589b7e
Add quadlet support for rootfs= containers
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>

Add rootfs= support for quadlet containers

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-02-06 12:54:33 -05:00
Ingo Becker e62e42bfa9 quadlet: Add device support for .volume files
The Device, Type, Copy and Options keys are now supported in
quadlet  .volume files. This allows users to create filesystem
based volumes with quadlets .volume files.

Signed-off-by: Ingo Becker <ingo@orgizm.net>
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-01-26 14:46:57 +02:00
Daniel J Walsh c2b36beb40
Use containers/storage/pkg/regexp in place of regexp
This is a cleaner solution and guarantees the variables
will be used before they are initialized.

[NO NEW TESTS NEEDED]

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-01-12 18:33:38 -05:00
Ygal Blum b10a906b5c Quadlet Kube - add support for PublishPort key
Move the handling of Publish key to a method
use --publish instead of -p
Use the new method for both .container and .kube files
Adjust .container tests
Add .kube tests
Update the man page

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-01-12 10:19:14 +02:00
Daniel J Walsh 758f20e20a
Compile regex on demand not in init
Every podman command is paying the price for this compile even when they
don't use the Regex, this will speed up start of podman by a little.

[NO NEW TESTS NEEDED] Existing tests should catch issues.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-01-11 14:38:51 -05:00
Ygal Blum 1bd3d32c5f Quadlet: Add support for ConfigMap key in Kube section
For each instance of ConfigMap pass the path via --configmap
Add tests
Add to doc

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-01-09 14:58:31 +02:00
OpenShift Merge Robot a4edd0d310
Merge pull request #16971 from ygalblum/quadlet-network-depend
Quadlet Network - Fix the name of the required network service
2023-01-03 10:17:25 -05:00
Ygal Blum 347d5372e1 Quadlet Container: Add support for EnvironmentFile and EnvironmentHost
Add the new keys to the supported keys list for the Container group
Pass the list of EnvironmentFile values while maintaining the order
Quadlet e2e test framework: Add support for checking regex in Podman args
Add relevant tests
Update man

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-01-03 13:14:31 +02:00
Ygal Blum a061d793df Quadlet Network - Fix the name of the required network service
The name of the network service does not start with systemd only the
podman network name

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2023-01-02 14:55:56 +02:00
Alexander Larsson 0179aa2451 quadlet: Support Type=oneshot container files
These just run once and are considered successful at exist. Not much is
needed to support it, but we have to avoid overwriting the type
with Type=notify.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-12-21 12:49:50 +01:00
Alexander Larsson 0cf36684c6 quadlet: Handle booleans that have defaults better
The ReadOnly and the RunInit keys affect options that have a variable
default (configurable in containers.conf). This means we need to
handle them a bit differently in quadlet to allow overriding the
default. For example, we can't assume ReadOnly=false doesn't need to
add any argument because no argument may mean readonly=true if the default
is changed.

We now don't add any argument (leaving the default) if the key is not specified,
or we always add an argument (--foo or --foo=false) if the key is specified (overriding whatever the default is).

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-12-20 11:00:48 +01:00
Alexander Larsson dd428af898 quadlet: Rename parser.LookupBoolean to LookupBooleanWithDefault
We add a regular LookupBoolean that can fail lookups, which is used by
the WithDefault version. We want to use this directly later in some places.

It is fina to change API here because this has not been in a release yet.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-12-20 10:38:49 +01:00
OpenShift Merge Robot b0acb59ccb
Merge pull request #16688 from ygalblum/quadlet_network_file
Quadlet: add network support
2022-12-19 14:16:53 -05:00
Alexander Larsson e9243f904b quadlet: Default BINDIR to /usr/bin if tag not specified
When building without the makefile the v4/pkg/systemd/quadlet._binDir
defined is not set. In that case default to /usr/bin rather than the
empty string. This helps e.g. the rpm specfile which doesn't use
the makefile.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-12-19 09:49:08 +01:00
Ygal Blum d974a79e27 Quadlet: add network support
Support .network file to create a systemd service that runs podman network create
Support networks with .network suffix in Container and Kube to link with Quadlet created networks
Add E2E Tests
Add man doc

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2022-12-18 11:25:20 +02:00
Alexander Larsson 461726a3fa qudlet: Respect $PODMAN env var for podman binary
This changes the podman binary name embedded in the generated files.
This is primarily needed for testing podman.

This also adds a -X config for BINDIR so that we pick up the right
install target. This required tweaking some tests to handle the default
bindir not being /usr/bin.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-12-16 09:47:49 +01:00
Alexander Larsson fd92a68071 quadlet: Default VolatileTmp to off
This is another case where we're diverging from the defaults in
podman.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-12-13 14:58:48 +01:00
OpenShift Merge Robot 6e2e9ab227
Merge pull request #16709 from vrothberg/fix-16515
kube sdnotify: run proxies for the lifespan of the service
2022-12-07 18:10:31 -05:00
OpenShift Merge Robot 883ff665b2
Merge pull request #16748 from ygalblum/quadlet_kube_userns
Quadlet Kube: Add support for userns flag
2022-12-06 18:03:41 -05:00
OpenShift Merge Robot 293f1cd14d
Merge pull request #16713 from alexlarsson/quadlet-drop-cid-remove
quadlet: Drop ExecStartPre=rm %t/%N.cid
2022-12-06 09:00:57 -05:00
Valentin Rothberg 4fa307f149 kube sdnotify: run proxies for the lifespan of the service
As outlined in #16076, a subsequent BARRIER *may* follow the READY
message sent by a container.  To correctly imitate the behavior of
systemd's NOTIFY_SOCKET, the notify proxies span up by `kube play` must
hence process messages for the entirety of the workload.

We know that the workload is done and that all containers and pods have
exited when the service container exits.  Hence, all proxies are closed
at that time.

The above changes imply that Podman runs for the entirety of the
workload and will henceforth act as the MAINPID when running inside of
systemd.  Prior to this change, the service container acted as the
MAINPID which is now not possible anymore; Podman would be killed
immediately on exit of the service container and could not clean up.

The kube template now correctly transitions to in-active instead of
failed in systemd.

Fixes: #16076
Fixes: #16515
Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2022-12-06 14:15:11 +01:00
Ygal Blum 1ea00ebda1 Quadlet Kube: Add support for userns flag
Move the handling of userns keys from ConvertContainer to a separate method
Adjust the method according to the different supported values
Use the new method in both ConvertContainer and ConvertKube
Pass isUser to ConvertKube as well
Add tests

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2022-12-05 21:26:23 +02:00
Ygal Blum a55413c802 Quadlet Kube: Add support for relative path for YAML file
If the provided path is relative, turn path to absolute
Add regex verification option in tests

Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2022-12-05 16:08:50 +02:00
Alexander Larsson f3c5b0f9d1 quadlet: Drop ExecStartPre=rm %t/%N.cid
Since https://github.com/containers/podman/pull/16394 was merged
we now always delete the cid file if --replace=true was specified,
so we can avoid this extra command being launched.

[NO NEW TESTS NEEDED] Already tested in above PR.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-12-05 08:26:03 +01:00
Ygal Blum d61618ad44 Quadlet Kube: Set SyslogIdentifier if was not set
Signed-off-by: Ygal Blum <ygal.blum@gmail.com>
2022-12-04 15:53:44 +02:00
Alexander Larsson 16cf34dc3a quadlet: Use same default capability set as podman run
Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-12-02 16:37:22 +01:00
Alexander Larsson b34ab8b5fa quadlet: Drop --pull=never
This is to match podman run default behaviour.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-12-02 16:33:09 +01:00
Alexander Larsson 098ad52ecb quadlet: Change default of ReadOnly to no
This matches the default podman run behaviour.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-12-02 16:30:15 +01:00
Alexander Larsson 1c3fddfaf7 quadlet: Change RunInit default to no
This matches the default of podman run.

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-12-02 16:25:47 +01:00