I am having trouble understanding how ports work when using kubernetes. There are three ports in question
containerPort
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?
The issue was with my Django server and not Kubernetes or docker. I was starting my server with python manage.py runserver
instead of python manage.py runserver 0.0.0.0:8080
which was causing it to return empty responses as the requests were not coming from localhost.