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

Container manifest should allow specifying interface to listen on #2139

Closed
nikhilk opened this issue Nov 3, 2014 · 16 comments
Closed

Container manifest should allow specifying interface to listen on #2139

nikhilk opened this issue Nov 3, 2014 · 16 comments
Assignees
Labels
area/api Indicates an issue on api area. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. sig/network Categorizes an issue or PR as relevant to SIG Network.

Comments

@nikhilk
Copy link

nikhilk commented Nov 3, 2014

The -p argument to 'docker run' allows specifying the interface on which a port will be published:
-p, --publish=[] Publish a container's port to the host
format: ip:hostPort:containerPort | ip::containerPort | hostPort:containerPort | containerPort

However, the container VM manifest only allows specifying hostPort and containerPort:

containers[].ports[] -- Ports to expose from the container. All of these are exposed out through the public interface of the VM.
containers[].ports[].containerPort
containers[].ports[].hostPort

https://cloud.google.com/compute/docs/containers/container_vms

This is useful for implementing defense-in-depth, and as such an important feature. Specifically it would allow opening a port that is not accessible off-machine when that is all that is needed.

In our scenario, the only intended client of that port is the local SSH daemon. Securing the port through just a firewall setting has been deemed as insufficient, as opening that port inadvertently opens up a large surface area of capabilities.

@dchen1107
Copy link
Member

cc @craigmcl

@lavalamp
Copy link
Member

lavalamp commented Nov 3, 2014

Can the "the local SSH daemon" be taught the pod's IP address, such that you would not need to use the hostPort feature at all?

@nikhilk
Copy link
Author

nikhilk commented Nov 4, 2014

I am just using a vanilla container vm ... do any of the pod concept apply? That said, I don't know enough about pods, and so I don't know.

@bgrant0607
Copy link
Member

See also #222

@bgrant0607 bgrant0607 added the sig/network Categorizes an issue or PR as relevant to SIG Network. label Nov 4, 2014
@smarterclayton
Copy link
Contributor

This sounds like a use case that external IPs could / should also solve. I'm not sure having pods punch their own holes in the infrastructure is a resilient system to rescheduling (pod goes away, a new copy is bound to a new host, any new connections fail).

@nikhilk
Copy link
Author

nikhilk commented Nov 6, 2014

As mentioned above, I am using a single container vm for its vm capabilities + ability to run a docker container, so I don't know how/if any of the pod functionality applies here.

As for the point about external IPs, the reason this bug was logged is because firewall settings were insufficient. Inadvertent opening of a port would lead to too big of a surface area exposed, because of the nature of the process running on that port.

At the most fundamental level, the docker command offers the ability to restrict the port to the local interface. The docker command is derived from the container vm manifest, and not directly specifiable. So the bug here is about getting the ability to specify that bit of the docker command via the container manifest.

@lavalamp
Copy link
Member

lavalamp commented Nov 6, 2014

When running with containerVM, kublet makes a pod out of the stuff you put in the container manifest. Pods get their own IP address (we make a docker container for the network namespace).

Setting a hostPort causes the port to be exposed on both the pod's IP, and the node's external IP. So to solve this problem, you just need to stop using hostPort. If you do that, then there's multiple ways you could figure out what your pod's IP ended up being. 1. talk to kubelet, hit /podInfo, parse the json blob-- I think you can find the IP in that. 2. is docker ps and figure out our naming system to find the network contain we made for you; I do not recommend that, it's likely to be brittle.

Finally, since we're talking security: you need to make sure your kubelet is either not listening on the public interface or behind a firewall; IIRC kubelet allows starting arbitrary containers over an http endpoint, and even if we took that out, it will allow remote log viewing and all the stuff in /podInfo...

@mmdriley
Copy link
Contributor

mmdriley commented Nov 6, 2014

We would prefer to avoid that level of indirection if possible. We want Docker to wire 127.0.0.1:9999 (e.g.) to the container, then we can use that static port for SSH port forwarding.

Is there any way to configure on which interfaces, if any, the Kubelet is listening through the containerVM manifest?

@thockin
Copy link
Member

thockin commented Nov 7, 2014

Responding to the original bug, I might be OK to simply add a flag to Port
such as HostPortLocalOnly, but it's pretty obscure.

On Thu, Nov 6, 2014 at 3:41 PM, mmdriley notifications@github.com wrote:

We would prefer to avoid that level of indirection if possible. We want
Docker to wire 127.0.0.1:9999 (e.g.) to the container, then we can use
that static port for SSH port forwarding.

Is there any way to configure on which interfaces, if any, the Kubelet is
listening through the containerVM manifest?

Reply to this email directly or view it on GitHub
#2139 (comment)
.

@bgrant0607 bgrant0607 added priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. area/api Indicates an issue on api area. labels Dec 4, 2014
@cvle
Copy link

cvle commented Dec 5, 2015

+1 I just ran into this problem. It would make things easier if we can specify the interface.

@thockin
Copy link
Member

thockin commented Dec 5, 2015

Can you explain why? The same arguments apply - specifying an interface is
an even deeper level of coupling that we should not enable without serious
use-cases.
On Dec 5, 2015 8:22 AM, "wikiwi" notifications@github.com wrote:

+1 I just ran into this problem. It would make things easier if we can
specify the interface.


Reply to this email directly or view it on GitHub
#2139 (comment)
.

@smarterclayton
Copy link
Contributor

This is not exactly the published issue, but we are definitely getting folks with standard multi network setups who want to have pods listen on distinct interfaces (which correspond to existing network infrastructure choices, like control plane vs storage plane vs public plane). I had been leaning towards allowing a network plugin to solve this use case, but it would have to involve some level of setup in the cluster. Then the network plugin can look at annotations or labels.

@thockin
Copy link
Member

thockin commented Dec 6, 2015

For bridging to physical networks, I think we can consider some first class
support for Networks. I think that is a real use case.

I am less sure aboyt host ports, or at least it shouldn't be per-pod but a
config of the kubelet. But I think we need some real explorations before
we jump on this.
On Dec 5, 2015 10:16 AM, "Clayton Coleman" notifications@github.com wrote:

This is not exactly the published issue, but we are definitely getting
folks with standard multi network setups who want to have pods listen on
distinct interfaces (which correspond to existing network infrastructure
choices, like control plane vs storage plane vs public plane). I had been
leaning towards allowing a network plugin to solve this use case, but it
would have to involve some level of setup in the cluster. Then the network
plugin can look at annotations or labels.


Reply to this email directly or view it on GitHub
#2139 (comment)
.

@xiangpengzhao
Copy link
Contributor

As per the discussion in the issue, this can be a use case of multiple-networks.

@nikhilk Would you please join the mailing list and post your use case there?
see: https://groups.google.com/forum/#!topic/kubernetes-sig-network/8nDSQ2hF40w

@caseydavenport
Copy link
Member

Given the age of the conversation here I think we should close this and re-open / create a new issue if there are more recent requests for this. Will close in a few days if there are no objections.

/assign

@caseydavenport
Copy link
Member

/close

bertinatto pushed a commit to bertinatto/kubernetes that referenced this issue Nov 26, 2024
OCPBUGS-44896: Enable format library for 4.18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area/api Indicates an issue on api area. priority/awaiting-more-evidence Lowest priority. Possibly useful, but not yet enough support to actually get it done. sig/network Categorizes an issue or PR as relevant to SIG Network.
Projects
None yet
Development

No branches or pull requests