Short Version:
In Kubernetes, Object definitions define desired state, while controllers watch Object definitions to achieve that state.
Ingress:
- "Ingress" Object that does little on its own, but defines L7 Load Balancing rules
- "Ingress Controller" that watches state of Ingress Objects to create L7 LB configuration based on rules defined in the Ingress Objects
LoadBalancer:
- "Service" Object of type "LoadBalancer" that allows a service to be attached to a LoadBalancer
- "Load Balancer Controller" that creates Load Balancers based on rules defined in the Service Object
Ingress
Ingress Object:
A kubernetes Object that does not do anything on its own because an Ingress Controller is not included by default. An Ingress Object just describes a way to route Layer 7 traffic into your cluster by specifying things like the request path, request domain, and target kubernetes service, while adding a service object may actually creates services because a service controller is included in Kubernetes by default.
Ingress Controller:
A Kubernetes Deployment/DaemonSet + Service which:
1. listens on specific ports (usually 80 and 443) for web traffic
2. Watches for the creation, modification, or deletion of Ingress Resources
3. Creates internal L7 routing rules based on desired state indicated by Ingress Objects
For example, the Nginx Ingress Controller may:
- Use a service to listen on port 80 and 443 for incoming traffic
- Watch for creation of Ingress Objects and convert the desired state into new server{} sections which are dynamically placed into nginx.conf
LoadBalancer
Load Balancer Controller:
Load Balancer Controllers may be configured in platforms such as AWS and GKE and provide a way to assign external IPs through the creation of external load balancers. This functionality can be used by:
- Deploying the Load Balancer Controller if it wasn't deployed yet
- Setting a service to type "LoadBalancer"
- Setting appropriate annotations in the Service to configure the Load Balancer
Service Type:
When the service type is set to LoadBalancer and there is a Cloud provided Load Balancer Controller present, the service is exposed externally using a cloud provider's load balancer. NodePort and ClusterIP Services, to which the external load balancer routes, are automatically created thereby assigning a service external IPs and or DNS.
Relationships
Ingress Controller Services are often provisioned as LoadBalancer type, so that http and https requests can be proxied / routed to specific internal services through an external ip.
However, a LoadBalancer is not strictly needed for this. Since, through the use of hostNetwork or hostPort you can technically bind a port on the host to a service (allowing you to visit it via the hosts external ip:port). Though officially this is not recommended as it uses up ports on the actual node.
References
https://kubernetes.io/docs/concepts/configuration/overview/#services
https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/
https://kubernetes.io/docs/tasks/access-application-cluster/create-external-load-balancer/#external-load-balancer-providers
https://kubernetes.io/docs/concepts/services-networking/ingress/
https://kubernetes.io/docs/concepts/architecture/cloud-controller/
https://kubernetes-sigs.github.io/aws-load-balancer-controller/v2.3/