Missing something? (services/ingress)

I have a small kubernetes cluster running at home. So far what I have been doing is using it for fault tolerance. So all my deployments are single replica pods. I have a service setup to expose them to the rest of the network.

So my question is this. If I spin up a pod like a web server that will run on multiple nodes and expose a service to it. Will it distribute the load? This is kind of where I am confused between service and ingress.

If the service has all the webserver end points… then what does the ingress do when you give it the service as the endpoint?

I have read through alot of the docs on the k8s site and different places, but I seem to be missing something in the understanding of how/what the service does for load balancing if at all.

thanks!


CrankyCoder

    August 1

I have a small kubernetes cluster running at home. So far what I have been doing is using it for fault tolerance. So all my deployments are single replica pods. I have a service setup to expose them to the rest of the network.

So my question is this. If I spin up a pod like a web server that will run on multiple nodes and expose a service to it. Will it distribute the load? This is kind of where I am confused between service and ingress.

Yes, the service will distribute the load on a round robin basis.

If the service has all the webserver end points… then what does the ingress do when you give it the service as the endpoint?

The service has several types, leaving headless and external types aside, you have clusterIP, node port and load balancer. Each of this builds on top of the other, so a node port service has a clusterIP and then a node on all worker nodes, and load balancer build on nodeport, so it has a node port, a clusterIP (as node port has it) and creates a load balancer in the platform of choice.

When the Ingress forwards traffic to a service, it only needs to have the service clusterIP. That is a virtual IP that is stable and load balances traffic between pods. So, basically, the Ingress sends traffic to the service virtual IP and that is mostly it.

The big difference is that a service exposes traffic in layer 4 (tcp, udp) and does load balancing. Ingress is layer 7 (HTTP) and does layer 7 routing (so, you can route based on HTTP headers, like host, path, etc.).

1 Like

So if i have something simple for my local network and don’t need it to be a special url there is no real need for an ingress. A service would work fine?

If I have something a little higher end, say for work where we have like 10 worker nodes. Would the ingress really do anything special for me if I don’t need something to route .com/url1 to service1 and .com/url2 to service2?

Service is layer 4, ingress is layer 7.

As long as you are fine exposing the app http server (if it’s an http server) or whatever is running, aservice is totally fine :slight_smile: