Open MartinX3 opened 2 years ago
Original discussion in https://github.com/containers/podman/discussions/12852
I believe this is related to podman play kube
.
For comparison with kubernetes: k8s automatically adds a network interface to each pod. That interface is attached to k8s's network. It is not possible to attach multiple network interfaces to the pod, unless a plugin such as Multus is used.
Multus uses an annotation (k8s.v1.cni.cncf.io/networks
) inside the YAML file to attach & configure additional network interfaces to the pod. See https://github.com/k8snetworkplumbingwg/multus-cni/blob/master/docs/how-to-use.md#run-pod-with-network-annotation.
It would be great if podman supported those annotations too, but this may prove difficult:
--network
as a set and can only attach a single interface per network.Or we need support for kind: NetworkPolicy
https://kubernetes.io/docs/concepts/services-networking/network-policies/
A friendly reminder that this issue had no activity for 30 days.
@mheon please remove the stale status
Regarding NetworkPolicy
objects, they are akin to firewalls, allowing only select traffic to pass around between specified pods (even if the pods are connected to the same network).
I don't think supporting them would solve this issue, but it could be a nice addition in the future (although it may be hard to implement in podman due to its dependency on labels and such).
I think that's a separate feature request, but it's definitely an interesting one. Mind making a separate issue for it? I think this has applications even outside of podman play kube
.
A friendly reminder that this issue had no activity for 30 days.
/remove Stale
A friendly reminder that this issue had no activity for 30 days.
/remove Stale
@Luap99 PTAL
k8s.v1.cni.cncf.io/networks
seems to only specify particular network names.
If I understand the ask here correctly the goal is to also create networks. I have no experience with the k8s yaml format but I don't think it is a good idea to hack this in via annotations.
A friendly reminder that this issue had no activity for 30 days.
/remove Stale
A friendly reminder that this issue had no activity for 30 days.
/remove Stale
@umohnani8 PTAL
@mheon PTAL
I'm really missing this currently, as now we have official docs and blog posts explaining how to go from docker-compose services -> kubernetes yaml files -> systemd running via podman-kube@$(systemd-escape some.yml).service
and yet there is no way to get those running pods to communicate easily if the original scenario was one app/service per docker-compose.yml
file (and thus one pod/service per kubernetes.yml
file).
k8s.v1.cni.cncf.io/networks
seems to only specify particular network names. If I understand the ask here correctly the goal is to also create networks. I have no experience with the k8s yaml format but I don't think it is a good idea to hack this in via annotations.
FWIU, new networks can be declared using the NetworkAttachmentDefinition
resource kind (syntax / example), then referenced (and further configured) from a Pod
manifest using k8s.v1.cni.cncf.io/networks
(example)
I think it would make sense to add support for NetworkAttachmentDefinition
. Users could then embed both the NetworkAttachmentDefinition
and Pod
/Deployment
definition in the same YAML manifest (similar to how ConfigMap
objects work ref)
@umohnani8 @haircommander @saschagrunert WDYT? ^^
In order to mimic K8s behavior in regards to network, we have to create one common network to which all pods created by play-kube will be added. Make play-kube do following by default:
podman network create play-kube-network
podman play kube --network play-kube-network KUBEFILE
This would allow pods to discover and communicate with other pods - that's the basic of K8s network model. Note that I'm not a go developer, but since I need the default K8s behavior in regards to pods sharing same network space, I would give it a try to add creation of default network (if it doesn't exists) and attaching pods to it by default (maybe if play-kube is not called with --network option).
@MartinX3 did https://github.com/containers/podman/pull/16029 resolve the original ask of this issue? Or is something more needed?
I think the basic is solved. Just this network has ipv6 disabled. I don't know if it is a rootless limitation? And I can't edit an existing network to enable it.
(But also IPv6 is broken, see https://github.com/containers/podman/issues/15850)
And I think the following things are still missing:
@MartinX3 did #16029 resolve the original ask of this issue? Or is something more needed?
While #16029 makes sure that pods share a common network by default, it does not address the case where you have defined your own networks and want to use them by referencing them in the YAML manifest. The current way to use those networks requires passing additional options (namely, --network
) when calling podman play kube
(i.e. outside the manifest).
NetworkPolicy and multiple networks (as with Multus) are provided in K8s by CNI (and plugins). To some extent there is a conflict with podman network stack direction (see https://www.redhat.com/sysadmin/podman-new-network-stack) and podman-kube - which mimics K8s as a single node deployment. Some things are possible with less effort, some require effort which makes development not be feasible and then the question is if podman is supposed to support/implement full k8s in podman-kube. There are some questions which I'm asking myself and I would like to know your answer if possible:
While I definitely like to have podman-kube 100% compatibility with k8s it seems that we're implementing k8s in podman - which only make sense if podman-kube is meant to be used in production and it's aim is to have k8s "API" compatibility - but then maybe podman-kube should use CNI and not netavark/aardark?
Edit: P.S.: If podman-kube is supposed to be used in production I guess I'll give it a try to implement NetworkPolicy, Service and Namespace in the future, if not already implemented by the time I'll need them.
In my case I run rootless podman as a single node container solution in my private servers.
In our company we run a kubernetes cluster, but I can't simply deploy podman kube yaml files there, because of the missing compatibility. Otherwise this ticket would resolved together with the other stuff missing.
I also miss this basic feature, to add the network name in the yaml. For the time being, I just copied the systemd service file and made the links point to /etc/systemd/user...
[root@onyx ~]# cp /usr/lib/systemd/user/podman-kube@.service /etc/systemd/user
[root@onyx ~]# diff /usr/lib/systemd/user/podman-kube\@.service /etc/systemd/user/podman-kube\@.service
12c12,13
< ExecStart=/usr/bin/podman play kube --replace --service-container=true %I
---
> ExecStart=/usr/bin/podman play kube --replace --network web --service-container=true %I
Please let me know if there is a better way :-)
I really don't care if the option is available as an cli option or an yaml annotation, however using an automatic GitOps pipeline (https://github.com/containers/fetchit/issues/280), currently there is no way to set the network, because the cli options are not available in that context. Means all pods are created on the default network, which is unexpected. It would be better if a simple yaml annotation can be added, where we can set existing network names.
@Luap99 Thoughts? @alexanderniebuhr Care to open a PR?
I would like this feature, too. The less extra scripting (or other steps) that we have to do would be preferred.
@ygalblum something you could tackle?
This would be extremely useful to me too, because I'm using podman-kube@.service
with rootless Podman and I need to set the --net slirp4netns:port_handler=slirp4netns
option to be able to see the correct source IPs of the requests in the containers.
My "temporary fix" for now is the following:
sudo sed -i 's|^\(ExecStart=/usr/bin/podman play kube\)|\1 --net slirp4netns:port_handler=slirp4netns|' \
/usr/lib/systemd/*/podman-kube@.service
but honestly I don't like it a lot because it alters Podman's systemd files
@ygalblum do you have ideas? I think Quadlet can help out here if not already supported.
Yes. Quadlet already has everything in place to support what @dmotte is describing. Assuming the K8S YAML is mykub.yaml
the .kube
Quadlet file should be:
[Kube]
Yaml=mykub.yaml
Network=slirp4netns:port_handler=slirp4netns
You can see more info here: https://docs.podman.io/en/stable/markdown/podman-systemd.unit.5.html#kube-units-kube
Thank you so much for the answers guys! Didn't know about Quadlet. I did some research and found that "It has been merged into Podman 4.4" (source). Unfortunately, on the server:
$ podman --version
podman version 4.3.1
Because I'm using Podman from the Debian 12 repos :(
I guess I'll have to install Podman in some other way, or keep my current solution for now. But thanks anyway for letting me know!
Is this a BUG REPORT or FEATURE REQUEST? (leave only one on its own line)
/kind feature
Description
I miss the ability to create and use networks in yaml files like PVCs.
Steps to reproduce the issue:
No issue
Describe the results you received:
Missing support.
Describe the results you expected:
Support of the feature.
Additional information you deem important (e.g. issue happens only occasionally):
Output of
podman version
:Output of
podman info --debug
:Package info (e.g. output of
rpm -q podman
orapt list podman
):Have you tested with the latest version of Podman and have you checked the Podman Troubleshooting Guide? (https://github.com/containers/podman/blob/main/troubleshooting.md)
Yes
Additional environment details (AWS, VirtualBox, physical, etc.): Arch Linux