python-podman icon indicating copy to clipboard operation
python-podman copied to clipboard

No option to publish ports on pod

Open AstraLuma opened this issue 6 years ago • 6 comments

Looking at the varlink schema, there's an option to set the published ports when creating a pod.

https://github.com/containers/libpod/blob/9758a975e67bb9d681d351aea0d858ace598dcdf/cmd/podman/varlink/io.podman.varlink#L451-L460

This library doesn't seem to expose that.

https://github.com/containers/python-podman/blob/4aa153396cafcc6f358e04222d19f27b87ca0387/podman/libs/pods.py#L126-L144

AstraLuma avatar Jan 06 '20 17:01 AstraLuma

The work-around I'm using for this is:

def create_pod(client, ident=None, cgroupparent=None, labels=None, share=None,
               infra=False, publish=[]):
    """Create a new empty pod."""
    infra = infra or bool(publish)
    if not share and infra:
        share = ['cgroup', 'ipc', 'net', 'uts']
    config = ConfigDict(
        name=ident,
        cgroupParent=cgroupparent,
        labels=labels,
        share=share,
        infra=infra,
        publish=publish
    )

    with client._client() as podman:
        result = podman.CreatePod(config)
        details = podman.GetPod(result['pod'])
    return Pod(client._client, result['pod'], details['pod'])

AstraLuma avatar Jan 06 '20 17:01 AstraLuma

Also, the default container network configuration interferes with this.

AstraLuma avatar Jan 08 '20 07:01 AstraLuma

It seems you are right the publish param is not exposed.

I think it's weird because python-podman is aligned with libpod 1.6.0 who was released on the last October (3-4 months ago) and the publish param was added to the varlink interface more than 1 years ago, so I think it's part to the libpod 1.6.0.

I think it's an issue and it need to be available in python-podman 1.6.0

4383 avatar Jan 08 '20 13:01 4383

I proposed a fix to realign the master with the latest signature of this interface.

Anyway it will part of a future release (surely 1.6.1)

4383 avatar Jan 08 '20 13:01 4383

It can be interesting to implement some automatized check to verify if python-podman implementation differ from defined interfaces on libpod.

These check could be either triggered on pushed changes on the interface description file on the libpod side or triggered daily on the python-podman side trough some cron job and travis-ci.

I will try to spend time in the next weeks to propose this kind of feature.

4383 avatar Jan 08 '20 13:01 4383

We can refer to this proposal to manage this kind of issue in the future.

4383 avatar Jan 08 '20 16:01 4383