Commit Graph

146 Commits

Author SHA1 Message Date
Jan Kaluza 224e791161 Replace podman pause image with rootfs.
This commit removes the code to build a local pause
image from the Containerfile. It is replaced with
code to find the catatonit binary and include it in
the Rootfs.

This removes the need to build a local pause container
image.

The same logic is also applied to createServiceContainer
which is originally also based on the pause image.

Fixes: #23292

Signed-off-by: Jan Kaluza <jkaluza@redhat.com>
2025-04-17 08:36:27 +02:00
Kir Kolyshkin 0dddc5e3c0 Apply De Morgan's law
This fixes a bunch of "QF1001: could apply De Morgan's law" warnings
from staticcheck linter.

Signed-off-by: Kir Kolyshkin <kolyshkin@gmail.com>
2025-03-31 12:27:55 -07:00
Victor Toso 321634d599 Add volume SubPath in generate kube
Trying to generate a Pod yaml file when we are using --mount with
SubPath does not generate a VolumeMount with SubPath. This patch fixes
that.

Note that kube play does support SubPath since 95cc7e052, see:
    https://github.com/containers/podman/pull/16803

Signed-off-by: Victor Toso <victortoso@redhat.com>
2025-03-25 11:59:21 +01:00
Daniel J Walsh ecd882f9f7
Kube volumes can not container _
Need to substiture all _ to - for k8s support.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-12-18 09:07:57 -05:00
Daniel J Walsh 8b23e6d408
When generating host volumes for k8s, force to lowercase
Fixes: https://github.com/containers/podman/issues/16542

Kubernetes only allows lower case persistent volume names.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-12-16 11:22:22 -05:00
openshift-merge-bot[bot] 62c101651f
Merge pull request #23857 from rhatdan/run
Remove containers/common/pkg/config from pkg/util
2024-09-17 20:31:28 +00:00
Daniel J Walsh eb396705c6
Remove containers/common/pkg/config from pkg/util
Probably has to wait for V6

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2024-09-06 07:45:04 -04:00
Urvashi Mohnani bdf96e7df2 Add support for Job to kube generate & play
The kube generate command can now generate a yaml for
the Job kind and the kube play command can create a pod
and containers with podman when passed in a Job yaml.
Add relevant tests and docs for this.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2024-09-05 11:36:38 -04:00
Paul Holzinger f93fcf7dee
bump go to 1.22
Many dependencies started using go 1.22 which means we have to follow in
order to update.

Disable the now depracted exportloopref linter as it was replaced by
copyloopvar as go fixed the loop copy problem in 1.22[1]

Another new chnage in go 1.22 is the for loop syntax over ints, the
intrange linter chacks for this but there a lot of loops that have to be
converted so I didn't do it here and disable th elinter for now, th eold
syntax is still fine.

[1] https://go.dev/blog/loopvar-preview

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-09-03 15:14:15 +02:00
Giuseppe Scrivano 61f0230c31
kube: record infra user namespace
if there is an annotation that specifies the user namespace for the
infra container, then make sure it is used for the entire pod.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-07-24 12:10:48 +02:00
Giuseppe Scrivano e97bb79b7a
kube: invert branches
it increases readability as it doesn't need the negation, and the
first branch is shorter.

Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2024-07-24 12:10:47 +02:00
Doug Rabson ffc8522646 libpod: fix 'podman kube generate' on FreeBSD
This avoids dereferencing c.config.Spec.Linux if it is nil, which is the
case on FreeBSD.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2024-06-05 10:38:30 +01:00
Paul Holzinger 83dbbc3a51
Replace golang.org/x/exp/slices with slices from std
Use "slices" from the standard library, this package was added in go
1.21 so we can use it now.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2024-04-23 11:16:40 +02:00
Sascha Grunert 1901403eda
Removing CRI-O related annotations
The annotations should be maintained by CRI-O itself to decouple the
projects from a dependency perspective.

[NO NEW TESTS NEEDED]

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2024-03-12 14:56:06 +01:00
Vikas Goel 89b415ba37 Comply to Kubernetes specifications for annotation size.
An annotation is a pair of key-value. The key has two parts, viz. a name and an optional prefix in DNS format.

The limitations on name is 63, prefix 253 chars. The limitation on total size of all key+value pairs combined is 256KB.

https://kubernetes.io/docs/concepts/overview/working-with-objects/annotations/#syntax-and-character-set

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

Signed-off-by: Vikas Goel <vikas.goel@gmail.com>
2024-02-20 14:58:35 -08:00
Matt Heon 72f1617fac Bump Go module to v5
Moving from Go module v4 to v5 prepares us for public releases.

Move done using gomove [1] as with the v3 and v4 moves.

[1] https://github.com/KSubedi/gomove

Signed-off-by: Matt Heon <mheon@redhat.com>
2024-02-08 09:35:39 -05:00
Philip Dubé 522934d5cf Replace strings.SplitN with strings.Cut
Cut is a cleaner & more performant api relative to SplitN(_, _, 2) added in go 1.18

Previously applied this refactoring to buildah:
https://github.com/containers/buildah/pull/5239

Signed-off-by: Philip Dubé <philip@peerdb.io>
2024-01-11 13:50:15 +00:00
Oleksandr Redko 8bdf77aa20 Refactor: replace StringInSlice with slices.Contains
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-05 16:25:56 +02:00
Oleksandr Redko 2a2d0b0e18 chore: delete obsolete // +build lines
Signed-off-by: Oleksandr Redko <Oleksandr_Redko@epam.com>
2024-01-04 11:53:38 +02:00
Valentin Rothberg e966c86d98 container.conf: support attributed string slices
All `[]string`s in containers.conf have now been migrated to attributed
string slices which require some adjustments in Buildah and Podman.

[NO NEW TESTS NEEDED]

Signed-off-by: Valentin Rothberg <vrothberg@redhat.com>
2023-10-27 12:44:33 +02:00
Paul Holzinger bad25da92e
libpod: add !remote tag
This should never be pulled into the remote client.

Signed-off-by: Paul Holzinger <pholzing@redhat.com>
2023-10-24 12:11:34 +02:00
danishprakash cdcf18b862
kube: add DaemonSet support for generate
Signed-off-by: danishprakash <danish.prakash@suse.com>
2023-09-12 10:30:57 +05:30
Urvashi Mohnani d9a85466a0 Add support for kube TerminationGracePeriodSeconds
Add support to kube play to support the TerminationGracePeriodSeconds
fiels by sending the value of that to podman's stopTimeout.
Add support to kube generate to generate TerminationGracePeriodSeconds
if stopTimeout is set for a container (will ignore podman's default).

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-09-10 16:41:24 -04:00
Daniel J Walsh b83485022d
Add support for kube securityContext\.procMount
Fixes: https://github.com/containers/podman/issues/19881

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-09-07 09:49:11 -04:00
Urvashi Mohnani 52ed7fce2a Add infra-name annotations to kube gen/play
Add io.podman.annotations.infra.name annotation to kube play so
users can set the name of the infra container created.
When a pod is created with --infra-name set, the generated
kube yaml will have an infraName annotation set that will
be used when playing the generated yaml with podman.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-08-24 11:29:56 -04:00
Doug Rabson afe8d5d840 libpod: fix 'podman kube generate' on FreeBSD
On FreeBSD, config.Spec.Linux and config.Spec.Process.Capabilities are
nil pointers so this just avoids dereferencing these pointers in that
case.

[NO NEW TESTS NEEDED]

Signed-off-by: Doug Rabson <dfr@rabson.org>
2023-07-27 11:38:23 +01:00
Jake Correnti d0602e8f75 Add `--podman-only` flag to `podman generate kube`
Adds an `--podman-only` flag to `podman generate kube` to allow for
reserved annotations to be included in the generated YAML file.

Associated with: #19102

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-14 09:35:59 -04:00
Jake Correnti 7b54fd84ec Add `--no-trunc` flag to maintain original annotation length
Adds a `--no-trunc` flag to `podman kube generate` preventing the
annotations from being trimmed at 63 characters. However, due to
the fact the annotations will not be trimmed, any annotation that is
longer than 63 characters means this YAML will no longer be Kubernetes
compatible. However, these YAML files can still be used with `podman
kube play` due to the addition of the new flag below.

Adds a `--no-trunc` flag to `podman kube play` supporting YAML files with
annotations that were not truncated to the Kubernetes maximum length of
63 characters.

Signed-off-by: Jake Correnti <jakecorrenti+github@proton.me>
2023-07-10 18:02:53 -04:00
Erik Sjölund 685c736185 source code comments and docs: fix typos, language, Markdown layout
- fix a/an before noun
- fix loose -> lose
- fix "the the"
- fix lets -> let's
- fix Markdown layout
- fix a few typos
- remove unnecessary text in troubleshooting.md

Signed-off-by: Erik Sjölund <erik.sjolund@gmail.com>
2023-05-22 07:52:16 +02:00
Urvashi Mohnani fa1ba17bc1 Update kube gen & play to use pod restart policy
Podman kube generate now uses the pod's restart policy
when generating the kube yaml. If generating from containers
only, use the restart policy of the first non-init container.
Podman kube play applies the pod restart policy from the yaml
file to the pod. The containers within a pod inherit this restart
policy.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-05-02 10:30:07 -04:00
Daniel J Walsh c4e79fc169
Fix up codespell errors
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-04-08 00:53:38 -04:00
Urvashi Mohnani d0ffb87925 Fix invalid pod name and hostname during kube generate
Kube generate on pods was not checking for any underscores
in the pod name so was creating a kube yaml with an invalid
pod name when there were underscores present.
The hostname for the pod is set to the podname by default. There
is no need to set that to the container's name or the pod name
again in the generated yaml. So removed that field unless a hostname
was set for the container by the user.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-04-05 17:43:02 -04:00
Urvashi Mohnani 4f90194068 Support Deployment generation with kube generate
The podman kube generate command can now generate a
Deployment kind when the --ype flag is set to deployment.
By default, a Pod spec will be generated if --type flag is
not set.
Add --replicas flag to kube generate to allow users to set
the value of replicas in the generated yaml when generating a
Deployment kind.
Add e2e and minikube tests for this feature.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-03-31 13:34:38 -04:00
Urvashi Mohnani c0f983db87 Don't set hostPort when generating a service
When generating a kube yaml with kube generate, do not
set the hostPort in the pod spec if the service flag is
set and we are generating a service kind too.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-02-14 11:00:28 -05:00
Urvashi Mohnani 35d16ea027 Add ulimit annotation to kube gen & play
Add a podman ulimit annotation to kube generate and play.
If a container has a container with ulimits set, kube gen
will add those as an annotation to the generated yaml.
If kube play encounters the ulimit annotation, it will set
ulimits for the container being played.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-02-13 11:38:24 -05:00
Daniel J Walsh 02bcf0bac8
Handle filetype field in kubernetes.yaml files
Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-02-02 09:23:12 -06:00
Urvashi Mohnani 958c94094e Set runAsNonRoot=true in gen kube
If the image being used has a user set that is a positive
integer greater than 0, then set the securityContext.runAsNonRoot
to true for the container in the generated kube yaml.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2023-01-25 17:14:22 +05:30
Daniel J Walsh ef3f098796
Remove ReservedAnnotations from kube generate specification
Reserved annotations are used internally by Podman and would effect
nothing when run with Kubernetes so we should not be generating these
annotations.

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

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2023-01-18 08:46:24 -05:00
Daniel J Walsh 3718ac8e96
Vendor in latest containers/common with default capabilities
Also update vendor of containers/storage and image

Cleanup display of added/dropped capabilties as well

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-12-15 14:28:30 -05:00
Daniel J Walsh af86b4f62a
Fix handling of readonly containers when defined in kube.yaml
The containers should be able to write to tmpfs mounted directories.

Also cleanup output of podman kube generate to not show default values.

Signed-off-by: Daniel J Walsh <dwalsh@redhat.com>
2022-12-03 07:05:58 -05:00
Alexander Larsson 55191ecc20 Add and use Container.LinuxResource() helper
This gets c.config.Spec.Linux.Resources, with some nil checks.
Using this means less open coding of the nil-checks, but also the
existing user of this field in moveConmonToCgroupAndSignal() was
using ctr.Spec().Linux.Resources instead, and the Spec() call
is very expensive.

[NO NEW TESTS NEEDED] Just minor performance effects

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-10-12 13:45:49 +02:00
Alexander Larsson 1038f063e0 Add and use libpod/Container.Terminal() helper
This just gets ctr.config.Spec.Process.Terminal with some null checks,
allowing several places that open-coded this to use the helper.

In particular, this helps the code in
pkg/domain/infra/abi/terminal.StartAttachCtr(), that used to do:
`ctr.Spec().Process.Terminal`, which looks fine, but actually causes
a deep json copy in the `ctr.Spec()` call that takes over 3 msec.

[NO NEW TESTS NEEDED] Just minor performance effects

Signed-off-by: Alexander Larsson <alexl@redhat.com>
2022-10-11 17:17:11 +02:00
Giuseppe Scrivano 9a286f7126
generate, kube: plug HostUsers
Signed-off-by: Giuseppe Scrivano <gscrivan@redhat.com>
2022-09-08 22:55:52 +02:00
OpenShift Merge Robot 6d8bafe57a
Merge pull request #15607 from fpoirotte/main
Fix #15243 Set AutomountServiceAccountToken to false
2022-09-08 19:38:56 +02:00
François Poirotte 71978b0a0c
Fix #15243 Set AutomountServiceAccountToken to false
podman does not use any service account token, so we set the automount flag
to false in podman generate kube.

Signed-off-by: François Poirotte <clicky@erebot.net>
2022-09-04 22:51:56 +02:00
Urvashi Mohnani 4a1acccf96 Fix bind-mount-option annotation in gen/play kube
The format used for setting the bind-mount-options annotations
in the kube yaml was incorrect and caused k8s to throw an error
when trying to play the generated kube yaml.
Fix the annotation format to match the rules of k8s.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2022-09-01 11:51:46 -04:00
Urvashi Mohnani 84352a81c9 Set enableServiceLinks to false in generated yaml
Since podman doesn't set/use the needed service env
variable, always set enableServiceLinks to false in
the generated kube yaml.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2022-08-31 14:02:13 -04:00
Urvashi Mohnani 10b4605124 Remove duplicate annotations in generated service yaml
Don't add the same annotations as the pod yaml to the
service yaml as it is not needed.

[NO NEW TESTS NEEDED]

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2022-08-24 23:47:38 -04:00
Urvashi Mohnani 81a19a568f Add ports and hostname correctly in kube yaml
If a pod is created without net sharing, allow adding
separate ports for each container to the kube yaml
and also set the pod level hostname correctly if the
uts namespace is not being shared.

Add a warning if the default namespace sharing options
have been modified by the user.

Signed-off-by: Urvashi Mohnani <umohnani@redhat.com>
2022-07-08 11:21:48 -04:00
Sascha Grunert 251d91699d
libpod: switch to golang native error wrapping
We now use the golang error wrapping format specifier `%w` instead of
the deprecated github.com/pkg/errors package.

[NO NEW TESTS NEEDED]

Signed-off-by: Sascha Grunert <sgrunert@redhat.com>
2022-07-05 16:06:32 +02:00