I am having trouble understanding how ports work when using kubernetes. There are three ports in question
- Port that my app is listening on inside the docker container
- Port mentioned in kubernetes config file as
containerPort
- LoadBalancer port when the deployment is exposed as a service
What is the relationship between the above three ports? In my current setup I mention EXPOSE 8000
in my Dockerfile and containerPort: 8000
in kubernetes config file. My app is listening on port 8000
inside the docker container. When I expose this deployment using kubectl expose deployment myapp --type="LoadBalancer"
, it results in the following service -
$ kubectl get service
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
myapp 10.59.248.232 <some-ip> 8000:32417/TCP 16s
But my curl
fails as shown below -
$ curl http://<some-ip>:8000/status/ -i
curl: (52) Empty reply from server
Can someone please explain me how the above three ports work together and what should be their values for successful 'exposure' of my app?