Skip to content
This repository has been archived by the owner on Feb 10, 2021. It is now read-only.

No option to publish ports on pod #64

Open
AstraLuma opened this issue Jan 6, 2020 · 6 comments
Open

No option to publish ports on pod #64

AstraLuma opened this issue Jan 6, 2020 · 6 comments
Assignees

Comments

@AstraLuma
Copy link

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.

def create(self,
ident=None,
cgroupparent=None,
labels=None,
share=None,
infra=False):
"""Create a new empty pod."""
config = ConfigDict(
name=ident,
cgroupParent=cgroupparent,
labels=labels,
share=share,
infra=infra,
)
with self._client() as podman:
result = podman.CreatePod(config)
details = podman.GetPod(result['pod'])
return Pod(self._client, result['pod'], details['pod'])

@AstraLuma
Copy link
Author

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
Copy link
Author

Also, the default container network configuration interferes with this.

@4383
Copy link
Collaborator

4383 commented Jan 8, 2020

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
Copy link
Collaborator

4383 commented Jan 8, 2020

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
Copy link
Collaborator

4383 commented Jan 8, 2020

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
Copy link
Collaborator

4383 commented Jan 8, 2020

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

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants