Home > other >  Clarification about Ports in Kubernetes scaling
Clarification about Ports in Kubernetes scaling

Time:01-29

Let's say I have a web application Backend that I want to deploy with the help of Kubernetes, how exactly does scaling work in this case.

I understand scaling in Kubernetes as: We have one a master node that orchestrates multiple worker nodes where each of the worker nodes runs 0-n different containers with the same image. My question is, if this is correct, how does Kubernetes deal with the fact that the same application use the same Port within one worker node? Does the request reach the master node which then handles this problem internally?

CodePudding user response:

Does the request reach the master node which then handles this problem internally?

No, the master nodes does not handle traffic for your apps. Typically traffic meant for your apps arrive to a load balancer or gateway, e.g. Google Cloud Load Balancer or AWS Elastic Load Balancer, then the load balancer forwards the request to a replica of a matching service - this is managed by the Kubernetes Ingress resource in your cluster.

The master nodes - the control plane - is only used for management, e.g. when you deploy a new image or service.

how does Kubernetes deal with the fact that the same application use the same Port within one worker node?

Kubernetes uses a container runtime for your containers. You can try this on your own machine, e.g. when you use docker, you can create multiple containers (instances) of your app, all listening on e.g. port 8080. This is a key feature of containers - the provide network isolation.

On Kubernetes, all containers are tied together with a custom container networking. How this works, depends on what Container Networking Interface-plugin you use in your cluster. Each Pod in your cluster will get its own IP address. All your containers can listen to the same port, if you want - this is an abstraction.

  • Related