Welcome to the new Linux Foundation Forum!

How are the docker port and Service and Pod ports related

RahulRegeRahulRege Posts: 1
edited July 1 in LFD259 Class Forum

Hello everyone, this is my first post as I recently started LFD259 and at the Pod and Service creation exercise. I have worked with docker before, so trying to map how things are connected.

When I create the Pod, I do not see the ports on the Node2 getting created in the sudo docker ps -a. I then added a Service on top of it as well as added the NodePort. I can reach to my service just fine but I do not see any networking on my docker container.

I imagine the CNI plugin is doing the magic but wondering if anyone can shed some light or would reviewing the CNI documentation (it was mentioned as a resource in the lab) would be the way to go .

Thanks
Rahul

Answers

  • chrispokornichrispokorni Posts: 243

    Hi @RahulRege,

    When in doubt, it always helps to check the documentation :wink:

    The pod is a wrapper around one or many containers and it creates a network namespace for its container(s) to share.

    A pod created with a container is not exposed to the outside world. It is only accessible from the local node so you won't find a port on the local node, but you will be able to access your containerized application thru the pod's IP address.

    As opposed to a single container exposed to the outside world thru a random high-port of the local node, a pod is exposed thru another Kubernetes resource - a Service. Specific types of services receive a random high-port on every node in the Kubernetes cluster (the same high-port number reserved on every node), allowing access to a single pod from any node in the cluster and from the outside world.

    Regards,
    -Chris

Sign In or Register to comment.