Which port do I need to open to allow pip to connect (in a docker running via kubernetes)?

5/17/2020

I want to install additional python libraries in a running container via pip. The reason why I use this way instead of building a container which have already be installed this library, is that my docker image needs to be small.

I have tried to open ports 8080, 3128 and 443. The yaml entries are as follows:

ports: 
- containerPort: 8080 
  name: http 
  protocol: TCP
- containerPort: 3128
  name: http 
  protocol: TCP
- containerPort: 443
  name: http 
  protocol: TCP

However, pip is not able to connect with the pypi server.

What port do I have to add? Or did I miss anything else?

-- Tobias Senst
kubernetes

2 Answers

5/17/2020

containerPort is the port on which the container will listen for incoming traffic. For downloading library from pypy server the traffic flow is outgoing from the pod.If you don't have any network policy blocking egress traffic then there is no need to whitelist any IP for traffic to go out to internet from the pod. But the pod and node need to be able to reach internet without getting the traffic blocked by any firewall.

-- Arghya Sadhu
Source: StackOverflow

5/17/2020

You just need to allow the egress traffic from your containers. If you are deploying it on some cloud provider just ensure that you are able to connect to the pypi server. If you are able to do that there should not be a problem to connect and download the required packages.

One easy way to check if you can connect is that if you are able to connect to the container and take shell session try to connect using curl. You will be able to surely troubleshoot the problem in your environment. It is usually the UDP port that needs port (53) if you are using the host network.

-- ANKIT SURKAR
Source: StackOverflow