42 Commits

Author SHA1 Message Date
99bdafba99 podman: split env variables in env and overrides
There are three different priorities for applying env variables:

1) environment/config file environment variables
2) image's config
3) user overrides (--env)

The third kind are known to the client, while the default config and image's
config is handled by the backend.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-07 14:16:50 -04:00
f269be3a31 add {generate,play} kube
Add the `podman generate kube` and `podman play kube` command.  The code
has largely been copied from Podman v1 but restructured to not leak the
K8s core API into the (remote) client.

Both commands are added in the same commit to allow for enabling the
tests at the same time.

Move some exports from `cmd/podman/common` to the appropriate places in
the backend to avoid circular dependencies.

Move definitions of label annotations to `libpod/define` and set the
security-opt labels in the frontend to make kube tests pass.

Implement rest endpoints, bindings and the tunnel interface.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-05-06 17:08:22 +02:00
f7c3cfde77 Add small fixes for 'podman run' from diffing inspect
To try and identify differences between Podman v1.9 and master,
I ran a series of `podman run` commands with various flags
through each, then inspecting the resulting containers and diffed
the inspect JSON between each. This identified a number of issues
which are fixed in this PR.

In order of discovery:
- Podman v2 gave short names for images, where Podman v1 gave the
  fully-qualified name. Simple enough fix (get image tags and use
  the first one if they're available)
- The --restart flag was not being parsed correctly when a number
  of retries was specified. Parsing has been corrected.
- The -m flag was not setting the swap limit (simple fix to set
  swap in that case if it's not explicitly set by the user)
- The --cpus flag was completely nonfunctional (wired in its
  logic)

Tests have been added for all of these to catch future
regressions.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-05-05 20:21:01 -04:00
7ac3d906b5 Rework port parsing to support --expose and -P
As part of this, make a major change to the type we use to
represent port mappings in SpecGen (from using existing OCICNI
structs to using our own custom one). This struct has the
advantage of supporting ranges, massively reducing traffic over
the wire for Podman commands using them (for example, the
`podman run -p 5000-6000` command will now send only one struct
instead of 1000). This struct also allows us to easily validate
which ports are in use, and which are not, which is necessary for
--expose.

Once we have parsed the ports from the new struct, we can produce
an accurate map including all currently requested ports, and use
that to determine what ports need to be exposed (some requested
exposed ports may already be included in a mapping from --publish
and will be ignored) and what open ports on the host we can map
them to.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-05-04 20:57:27 -04:00
97fcbfcbec cgroupsns was not following containers.conf
Implement ParseCgroupsNamespace to handle defaults.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-01 15:00:33 -04:00
4a2765c498 Properly handle default capabilities listed in containers.conf
If user/admin specifies a different list of default capabilties
we need to honor these.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-01 15:00:26 -04:00
730fbc7628 Properly handle containers.conf devices
We need to add the default devices listed in containers.conf

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-05-01 15:00:26 -04:00
49107a5a2e Merge pull request #6004 from rhatdan/ulimits
Set up ulimits for rootless containers.
2020-05-01 15:58:24 +02:00
c11cff4542 cmd, podman: do not override entrypoint if unset
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-30 11:33:34 +02:00
65d7f22720 cmd, podman: handle --pod new:POD
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-30 11:33:33 +02:00
b2414b580e generate systemd
Implement `podman generate systemd` for Podman v2 and enable associated
tests.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2020-04-29 07:22:18 +02:00
23be7b5049 Merge pull request #6024 from baude/v2checkmediatypew
check image media/manifest type for healthchecks
2020-04-28 19:21:50 +02:00
a255075fe8 check image media/manifest type for healthchecks
before looking up a healthcheck in an image, check to make sure it is a dockerv2schema image.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-28 11:49:58 -05:00
a9aa9e2f78 pkg, specgen: do not hardcode user=0 in the config if not specified
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-28 15:25:59 +02:00
51585fffdd Set up ulimits for rootless containers.
Currently we are setting the maximum limits for rootful podman containers,
no reason not to set them by default for rootless users as well

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-28 08:09:39 -04:00
67ec4e1d27 Improve Entrypoint and Command support
We should not be overwriting the Specgen's Command and Entrypoint
when building the final command to pass in the OCI spec. Both of
these will be provided to Libpod for use in `podman inspect` and
committing containers, and both must be set to the user's input,
not overwritten by the image if unset.

Fix this by moving command generation into OCI spec generation
and not modifying the SpecGenerator when we do so.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-04-27 13:13:21 -04:00
02671a103f Add support for volumes-from, image volumes, init
This should complete Podmanv2's support for volume-related flags.
Most code was sourced from the old pkg/spec implementation with
modifications to account for the split between frontend flags
(volume, mount, tmpfs) and the backend flags implemented here.

Also enables tests for podman run with volumes

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-04-27 13:13:21 -04:00
fdf64f0c66 Merge pull request #5994 from giuseppe/fix-healthchecks
v2, podman: fix healthchecks
2020-04-27 15:40:24 +02:00
adb10783d9 spec, pod: honor --dns
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-27 12:58:02 +02:00
1cd484e13f specgen: read healthchecks from the image
if there is no healthcheck configuration specified, read it from the
image.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-27 11:22:27 +02:00
2afe579c06 Merge pull request #5971 from giuseppe/fix-userns-tests
v2, podman: fix and enable all run_userns_test.go tests
2020-04-24 22:39:26 +02:00
3c3adac528 Merge pull request #5967 from giuseppe/run-test-fixes
v2, tests: fix various run_test.go failures
2020-04-24 17:46:20 +02:00
b1552d9124 Do not join pod namespaces without an infra ctr
We do not want to join pod namespaces if no infra container is
present. A pod may claim it shares namespaces without an infra
container (I'll take an action item to fix that - it really
should not be allowed), which was tripping up our default
namespace code and forcing us to try and join the namespaces of
the nonexistant infra container.

Signed-off-by: Matthew Heon <mheon@redhat.com>
2020-04-24 09:44:51 -04:00
64d8b4eebb podman: implement userns=keep-id
add missing implementation for userns=keep-id and enable the user
namespaces tests.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-24 15:03:50 +02:00
a3acc4f977 podman: add support for --rootfs
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-24 12:56:20 +02:00
36039a38ea create: move validate after setting default ns
validate the configuration only after we set the default namespaces.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-24 10:48:40 +02:00
48530acbd9 podman: handle namespaces specified on the CLI
and handle differently the user namespace as it supports additional
options.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-23 18:05:03 +02:00
b4a4338dfe Enable basic volumes support in Podmanv2
This enables the --volume, --mount, and --tmpfs flags in
Podmanv2. It does not enable init-related flags, image volumes,
and --volumes-from.

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-04-22 14:24:12 -04:00
1cd2b746d0 Modify namespace generation code for specgen
Namespaces have now been changed to properly handle all cases.
Spec handling code for namespaces was consolidated in a single
function.

Still missing:
- Image ports
- Pod namespaces likely still broken in Podmanv2

Signed-off-by: Matthew Heon <matthew.heon@pm.me>
2020-04-21 14:38:52 -04:00
1ed849f2d1 Merge pull request #5921 from baude/v2imageep
add entrypoint from image where needed
2020-04-21 11:23:21 -04:00
a2541bf133 Merge pull request #5912 from giuseppe/v2-rlimits
v2, pkg: implement rlimits
2020-04-21 11:17:35 -04:00
224a5ce51e add entrypoint from image where needed
if the image specifies both the image and entrypoint, we need to account for that and preprend the entrypoint to the command.  this only happens if no user command and entrypoint were supplied.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-21 09:15:21 -05:00
75fdb753dd Handle annotations passed in via the client
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-21 05:18:39 -04:00
8884f6a4f3 Merge pull request #5875 from rhatdan/network
Cleanup network option parsing
2020-04-21 05:09:54 -04:00
0108161a4e pkg: implement rlimits
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2020-04-21 10:36:48 +02:00
eb101936e6 Handle Linux Capabilities correctly
If user sets capabilities list we need handle minimal capabilities.

Also handle seccomp-policy being passed in.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-20 15:50:46 -04:00
a2ad5bb9e1 Add functions to return image informations
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-20 15:50:46 -04:00
426eccee63 Cleanup network option parsing
We were not handling the parsing of --ip.  This pr adds validation
checks and now will support the flag.

Move validation to the actual parsing of the network flags.

We should only parse the dns flags if the user changed them. We don't
want to pass default options if set in containers.conf to the server.
Potential for duplicating defaults.

Add support for --dns-opt flag passing

Begin handling of --network flag, although we don't have a way right now
to translate a string into a specgen.Namespace.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-19 05:19:30 -04:00
ba430bfe5e podman v2 remove bloat v2
rid ourseleves of libpod references in v2 client

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-16 12:04:46 -05:00
ac94a96a74 Fix up SELinux labeling
SELinux label options processing fixes, should allow system tests to pass.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-04-15 16:30:03 -04:00
7147187942 v2specgen prune libpod
use libpod only in the specgen/generate package so that the remote clients do not inherit libpod bloat.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-14 20:02:20 -05:00
6514a5c80e v2podman container create
create a container in podmanv2 using specgen approach.  this is the core implementation and still has quite a bit of code commented out specifically around volumes, devices, and namespaces.  need contributions from smes on these parts.

Signed-off-by: Brent Baude <bbaude@redhat.com>
2020-04-03 15:43:03 -05:00