Open PiotrBzdrega opened 2 weeks ago
AFAIK k8s always uses a infra container and the kube command tires to match k8s behavior wherever possible as long as it makes sense for podman. And I think there is important functionality that requires a infra container to be created for the pod, i.e. we need a container running to keep namespaces open that can be shared for all containers in a pod.
What exactly is your use case?
@Luap99 Thank you Paul for reaction,
I thought that infra is not so inevitable if there is cli --infra=false
😀
I read in "Podman in Action" ~Daniel Walsh that
The infra container (pause container) is similar to the rootless pause container; its only purpose is to hold open the namespaces and cgroups, while containers come and go. However, each pod will have a different infra container
In my pod i won't change number of running containers ( don't need to add or remove during runtime). I assumed that this is main task for infra, to let new container join namespace/cgroup.
But the main (dumb) reason ... is that i would like to filter out infra container during checking state of containers and have it short to not process it a lot 😅.
Additional side effect to consider what will happen if we would use this configuration variable durnig podman kube play: Working with the current version (5.3.0), if the .yaml file is broken, pod will be created with only one infra container with pod status = created. How podman will behave if there won't be dedicated infra 🤔, Will pod be created with 0 containers or maybe nothing will happen like with broken compose file in docker - compose
Well without the infra the containers will not share any namespaces which is not what most people want. In that case they are just a group of containers where podman pod start/stop starts and stops the containers at the some time.
But the main (dumb) reason ... is that i would like to filter out infra container during checking state of containers and have it short to not process it a lot 😅.
I don't know what you are doing but there is a IsInfra field in the inspect and list container output that can be used to filter.
$ bin/podman ps -a
CONTAINER ID IMAGE COMMAND CREATED STATUS PORTS NAMES
2b6ad4da01c0 localhost/podman-pause:5.4.0-dev-1731674600 6 minutes ago Up 3 minutes a7f302810edb-infra
a940f402b017 docker.io/library/debian:bookworm bash 3 minutes ago Exited (0) 3 minutes ago magical_hamilton
$ bin/podman ps -a --format '{{if not .IsInfra}}{{.State }}{{end}}'
exited
Additional side effect to consider what will happen if we would use this configuration variable durnig podman kube play: Working with the current version (5.3.0), if the .yaml file is broken, pod will be created with only one infra container with pod status = created.
Yeah I think this is pretty much undefined behavior. I guess on errors we should clean the pod up again which the code seem to say as well https://github.com/containers/podman/blob/e1951772c5f0b247e51ff6617a8aee9b48df910c/cmd/podman/kube/play.go#L329-L343
So I am not sure why this isn't done today or what the problems with that are.
When creating pod using
podman pod create --infra=false
we have possibility to avoid creating infra container. As far i know there is no counterpart command in .yaml file. In such situation i would suggest to create in containers.conf: