Commit Graph

33 Commits

Author SHA1 Message Date
Daniel J Walsh 221b1add74 Add support for pod inside of user namespace.
Add the --userns flag to podman pod create and keep
track of the userns setting that pod was created with
so that all containers created within the pod will inherit
that userns setting.

Specifically we need to be able to launch a pod with
--userns=keep-id

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2021-08-09 15:17:22 -04:00
Daniel J Walsh 117850e6eb
Fix handling of selinux labels in podman play kube
Fixes: https://github.com/containers/podman/issues/10969

[NO TESTS NEEDED] We added tests for this, but they don't seem to be
running.  If I run the local system tests, they fail with the current
Podman and work with this version.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-07-20 08:42:07 -04:00
flouthoc 81e32b1808 Kube: Add liveness probe for containers.
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2021-07-17 18:35:22 +05:30
Daniel J Walsh de293c9802
Handle image user and exposed ports in podman play kube
Currently if a user runs an image with a user specified or
exposed ports with podman play kube, the fields are ignored.

Fixed: https://github.com/containers/podman/issues/9609

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-26 16:39:04 -04:00
Daniel J Walsh 4cc19f9e0f
Support automatic labeling of kube volumes
Allow users to specify options on the volume mount path.
This will trigger relabels of user specifies :z,:Z
Also will handle User Relabels if the user specifies :U

Fixes: https://github.com/containers/podman/issues/9371

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-05-16 07:09:22 -04:00
flouthoc 14a1a4546c Kube like pods should share ipc,net,uts by default
Signed-off-by: flouthoc <flouthoc.git@gmail.com>
2021-05-10 11:29:11 +05:30
Eduardo Vega 72f4f389f0 Adds support to preserve auto update labels in generate and play kube
In the case of generate kube the auto-update labels will be converted into kube annotations and for play kube they will be converted back to labels since that's what podman understands

Signed-off-by: Eduardo Vega <edvegavalerio@gmail.com>
2021-05-06 21:21:43 -06:00
Valentin Rothberg 0f7d54b026 migrate Podman to containers/common/libimage
Migrate the Podman code base over to `common/libimage` which replaces
`libpod/image` and a lot of glue code entirely.

Note that I tried to leave bread crumbs for changed tests.

Miscellaneous changes:

 * Some errors yield different messages which required to alter some
   tests.

 * I fixed some pre-existing issues in the code.  Others were marked as
   `//TODO`s to prevent the PR from exploding.

 * The `NamesHistory` of an image is returned as is from the storage.
   Previously, we did some filtering which I think is undesirable.
   Instead we should return the data as stored in the storage.

 * Touched handlers use the ABI interfaces where possible.

 * Local image resolution: previously Podman would match "foo" on
   "myfoo".  This behaviour has been changed and Podman will now
   only match on repository boundaries such that "foo" would match
   "my/foo" but not "myfoo".  I consider the old behaviour to be a
   bug, at the very least an exotic corner case.

 * Futhermore, "foo:none" does *not* resolve to a local image "foo"
   without tag anymore.  It's a hill I am (almost) willing to die on.

 * `image prune` prints the IDs of pruned images.  Previously, in some
   cases, the names were printed instead.  The API clearly states ID,
   so we should stick to it.

 * Compat endpoint image removal with _force_ deletes the entire not
   only the specified tag.

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-05-05 11:30:12 +02:00
Daniel J Walsh 9c8277247d
Fixes from make codespell
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-04-21 13:16:33 -04:00
Paul Holzinger 1685c2dc36 podman play kube apply correct log driver
The --log-driver flag was silently ignored by podman play kube. This
regression got introduced during the play kube rework.
Unfortunately the test for this was skipped for no good reason.

Fixes #10015

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-04-15 18:24:22 +02:00
OpenShift Merge Robot b7bb8a1fb9
Merge pull request #9842 from AlbanBedel/play-kube-env-from-secrets
Add support for env from secrets in play kube
2021-03-29 17:10:25 +00:00
Alban Bedel c59eb6f12b play kube: add support for env vars defined from secrets
Add support for secretRef and secretKeyRef to allow env vars to be set
from a secret. As K8S secrets are dictionaries the secret value must
be a JSON dictionary compatible with the data field of a K8S secret
object. The keys must consist of alphanumeric characters, '-', '_'
or '.', and the values must be base64 encoded strings.

Signed-off-by: Alban Bedel <albeu@free.fr>
2021-03-28 15:03:29 +02:00
Alban Bedel e5ff694855 play kube: support optional/mandatory env var from config map
In K8S the pod creation fails if an env var reference a non existing
config map key. It can be marked as optional, but per default it is
mandatory. Podman on the other hand always treat such references as
optional.

Rework envVarsFrom() and envVarValue() to additionaly return an error
and add support for the optional attribute in configMapRef and
configMapKeyRef.

Signed-off-by: Alban Bedel <albeu@free.fr>
2021-03-28 15:02:31 +02:00
Alban Bedel 9f92b8b0d8 play kube: prepare supporting other env source than config maps
Rework envVarsFromConfigMap() and envVarValue() to simplify supporting
other env sources than config maps. For this we pass the whole spec
generator options struct as parameter instead of just the config maps
list. Then we rename envVarsFromConfigMap() to envVarsFrom() and in
envVarValue() we reposition the loop over the config maps to only run
it when a configMapRef element exists.

Signed-off-by: Alban Bedel <albeu@free.fr>
2021-03-28 15:01:24 +02:00
Jordan Christiansen dce877c5ca Add problematic volume name to kube play error messages
When kube play fails to create a volume, it should say which volume had
the problem so the user doesn't have to guess. For the following pod
spec:

	apiVersion: v1
	kind: Pod
	metadata:
	  name: mypod
	spec:
	  containers:
	    - name: myfrontend
	      image: nginx
	      volumeMounts:
	      - mountPath: "/var/www/html"
		name: mypd
	  volumes:
	    - name: mypd
	      hostPath:
		path: /var/blah

podman will now report:

	Error: failed to create volume "mypd": error in parsing HostPath
	in YAML: error checking path "/var/blah": stat /var/blah: no such
	file or directory

Signed-off-by: Jordan Christiansen <xordspar0@gmail.com>
2021-03-27 09:46:30 -05:00
Valentin Rothberg 5dded6fae7 bump go module to v3
We missed bumping the go module, so let's do it now :)

* Automated go code with github.com/sirkon/go-imports-rename
* Manually via `vgrep podman/v2` the rest

Signed-off-by: Valentin Rothberg <rothberg@redhat.com>
2021-02-22 09:03:51 +01:00
Paul Holzinger 78b419909b Enable more golangci-lint linters
Cleanup the golangci.yml file and enable more linters.

`pkg/spec` and `iopodman.io` is history. The vendor directory
is excluded by default. The dependencies dir was listed twice.

Fix the reported problems in `pkg/specgen` because that was also
excluded by `pkg/spec`.

Enable the structcheck, typecheck, varcheck, deadcode and depguard
linters.

[NO TESTS NEEDED]

Signed-off-by: Paul Holzinger <paul.holzinger@web.de>
2021-02-12 18:20:28 +01:00
Steven Taylor c68b59f97f play kube selinux label issue
play kube function not respecting selinux options in kube yaml, all options were
being mapped to role.

fixes issue 8710

Signed-off-by: Steven Taylor <steven@taylormuff.co.uk>
2021-02-02 18:13:13 +00:00
baude ca0dd76bf3 Honor custom DNS in play|generate kube
when creating kubernetes yaml from containers and pods, we should honor
any custom dns settings the user provided. in the case of generate kube,
these would be provided by --dns, --dns-search, and --dns-opt. if
multiple containers are involved in the generate, the options will be
cumulative and unique with the exception of dns-opt.

when replaying a kube file that has kubernetes dns information, we now
also add that information to the pod creation.

the options for dnspolicy is not enabled as there seemed to be no direct
correlation between kubernetes and podman.

Fixes: #9132

Signed-off-by: baude <bbaude@redhat.com>
2021-01-29 08:49:45 -06:00
OpenShift Merge Robot 2b0cf7728d
Merge pull request #8954 from baude/reducebindingsize
Reduce general binding binary size
2021-01-13 13:29:24 -05:00
baude 827f6c9cb0 Reduce general binding binary size
when using the bindings to *only* make a connection, the binary was
rough 28MB.  This PR reduces it down to 11.  There is more work to do
but it will come in a secondary PR.

Signed-off-by: baude <bbaude@redhat.com>
2021-01-13 09:35:24 -06:00
Daniel J Walsh 0a7f4eaa9d
play kube: set entrypoint when interpreting Command
We now set Entrypoint when interpeting the image Entrypoint (or yaml.Command)
and Command when interpreting image Cmd (or yaml.Args)

This change is kind of breaking because now checking Config.Cmd won't return
the full command, but only the {cmd,args}.

Adapt the tests to this change as well

Signed-off-by: Peter Hunt <pehunt@redhat.com>
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2021-01-13 06:10:50 -05:00
Benedikt Ziemons 8566a5330b
Refactor kube.ToSpecGen parameters to struct
Create kube.CtrSpecGenOptions and document parameters.
Follow-up on https://github.com/containers/podman/pull/8792#discussion_r546673758

Signed-off-by: Benedikt Ziemons <ben@rs485.network>
2020-12-23 22:59:39 +01:00
Benedikt Ziemons 14439b9869
Set NetNS mode instead of value
when HostNetwork is true in the pod spec.
Also propagate whether host network namespace should be used for containers.

Add test for HostNetwork setting in kubeYaml.
The infra configuration should reflect the setting.

Signed-off-by: Benedikt Ziemons <ben@rs485.network>
2020-12-23 19:28:32 +01:00
OpenShift Merge Robot 54b82a175f
Merge pull request #8787 from jsoref/spelling
Spelling
2020-12-23 17:38:43 +01:00
Josh Soref 4fa1fce930 Spelling
Signed-off-by: Josh Soref <jsoref@users.noreply.github.com>
2020-12-22 13:34:31 -05:00
Peter Hunt 1c437f039a play kube: fix args/command handling
when neither yaml.Args nor yaml.Command are specified, we should use the entrypoint and cmd from the image.

update the tests to cover this and another case (both args and command are specified).
use the registry image instead of redis, as it has both an entrypoint and command specified.
update the documentation around this handling to hopefully prevent regressions and confusion.

Signed-off-by: Peter Hunt <pehunt@redhat.com>
2020-12-22 13:14:59 -05:00
OpenShift Merge Robot 49d11b53e1
Merge pull request #8661 from rhatdan/codespell
Fix spelling mistakes
2020-12-09 09:52:20 -05:00
Daniel J Walsh bf5d184325
Fix spelling mistakes
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2020-12-09 06:00:04 -05:00
Christopher J. Ruwe b13ae2b6dc make podman play use ENVs from image
fixes #8608.

Signed-off-by: Christopher J. Ruwe <cjr@cruwe.de>
2020-12-09 10:04:21 +01:00
Alban Bedel 66944baad6 Add support for persistent volume claims in kube files
In k8s a persistent volume claim (PVC) allow pods to define a volume
by referencing the name of a PVC. The PVC basically contains criterias
that k8s then use to select which storage source it will use for the
volume.

Podman only provide one abtracted storage, the named volumes, and
create them if they don't exists yet. So this patch simply use a
volume with the name of the PVC.

Signed-off-by: Alban Bedel <albeu@free.fr>
2020-11-27 11:38:33 +01:00
Alban Bedel b84304da5e Prepare support in kube play for other volume types than hostPath
Replace the simple map of names to paths with a map of names to a struct
to allow passing more parameters. Also move the code to parse the volumes
to its own file to avoid making the playKubePod() function overly complex.
Finally rework the kube volumes test to also be ready to support more
volume types.

Signed-off-by: Alban Bedel <albeu@free.fr>
2020-11-27 11:38:33 +01:00
baude 72ec8b0aa2 migrate play kube to spec gen
we need to migrate play kube away from using the old container creation
method.  the new approach is specgen and this aligns play kube with
container creation in the rest of podman.

Signed-off-by: baude <bbaude@redhat.com>
2020-11-10 07:55:24 -06:00