Kubernetes : Exposing a container's port



This techniques is useful more for debugging purposes more than anything else.
We could expose a container's port on the host port and access it.


Below is a Yaml file of a pod, we could access its container on port "80": 


We create our pod using the below command:


We use port forwarding to be able to forward a request on our local host on port "80" to port "80" of our nginx container.


We could access our nginx pod by using the "localhost" IP address as below:


We could also use the "Curl" utility that transfers data to and from server.
"Curl" support various protocols like for example - http, https, ldap, ... - :


Comments

Leave as a comment:

Archive