Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow users to expose ports from the pod to the host #1829

Merged

Conversation

baude
Copy link
Member

@baude baude commented Nov 19, 2018

we need to allow users to expose ports to the host for the purposes
of networking, like a webserver. the port exposure must be done at
the time the pod is created.

strictly speaking, the port exposure occurs on the infra container.

Signed-off-by: baude bbaude@redhat.com

@baude
Copy link
Member Author

baude commented Nov 19, 2018

/approve

@openshift-ci-robot
Copy link
Collaborator

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: baude

The full list of commands accepted by this bot can be found here.

The pull request process is described here

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@openshift-ci-robot openshift-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Nov 19, 2018

if !c.BoolT("infra") && len(c.StringSlice("publish")) > 0 {
return errors.Errorf("you must have an infra container to publish port bindings to the host")
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

could you also add an error when we are in rootless mode? Exposing port from the host is not currently supported for rootless containers.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

sure! added

@@ -2,12 +2,14 @@ package main

import (
"fmt"
"github.com/containers/libpod/pkg/rootless"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Formatting

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fixed

libpod/pod.go Outdated
@@ -96,7 +97,8 @@ type PodContainerInfo struct {

// InfraContainerConfig is the configuration for the pod's infra container
type InfraContainerConfig struct {
HasInfraContainer bool `json:"makeInfraContainer"`
HasInfraContainer bool `json:"makeInfraContainer"`
PortBindings map[nat.Port][]nat.PortBinding `json:"infraPortBindings"`
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we make these match the CNI structs that Libpod uses? So we can move the heavy lifting around ports into cmd/podman and turn CreatePortBindings into a straight assignment when we make the pod container

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

we need to allow users to expose ports to the host for the purposes
of networking, like a webserver.  the port exposure must be done at
the time the pod is created.

strictly speaking, the port exposure occurs on the infra container.

Signed-off-by: baude <bbaude@redhat.com>
@giuseppe
Copy link
Member

LGTM

@mheon
Copy link
Member

mheon commented Nov 20, 2018

LGTM, thanks @baude
/lgtm

@openshift-ci-robot openshift-ci-robot added the lgtm Indicates that a PR is ready to be merged. label Nov 20, 2018
@openshift-merge-robot openshift-merge-robot merged commit fe4f094 into containers:master Nov 20, 2018
"strings"

"github.com/containers/libpod/cmd/podman/libpodruntime"
"github.com/containers/libpod/cmd/podman/shared"
"github.com/containers/libpod/libpod"
"github.com/containers/libpod/pkg/rootless"
"github.com/cri-o/ocicni/pkg/ocicni"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Late to the game. Is there a reason why github.com/cri-o/ocicni/pkg/ocicni is not part of github.com/containers (or ideally a package of libpod)? Would be nice for CI and for consolidating packages.

@vrothberg
Copy link
Member

Nice PR!

@mheon
Copy link
Member

mheon commented Nov 21, 2018 via email

@rhatdan
Copy link
Member

rhatdan commented Nov 21, 2018

SGTM. I think pulling it into libpod and then having CRI-O vendoring matches our long term goals.

@baude baude deleted the enableportbindinginpods branch December 22, 2019 18:49
@github-actions github-actions bot added the locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments. label Sep 26, 2023
@github-actions github-actions bot locked as resolved and limited conversation to collaborators Sep 26, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
approved Indicates a PR has been approved by an approver from all required OWNERS files. lgtm Indicates that a PR is ready to be merged. locked - please file new issue/PR Assist humans wanting to comment on an old issue or PR with locked comments.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants