A Kubernetes LoadBalancer Service exposes workloads outside the cluster by requesting a cloud-managed load balancer. It distributes external requests across cluster nodes and their Pods. Compared with NodePort, it supports standard web ports such as 80, allowing domains like py.book.roadtok8s.com without a port suffix. section 8.5 section 8.5.1
Use a LoadBalancer Service when you need to:
- Expose an application to internet traffic through a public address. section 8.3.2
- Serve multiple external Services through standard HTTP or HTTPS ports instead of assigning each a node port. section 8.5
- Map a custom domain to the load balancer’s static IP with a DNS A record. section 8.5.1
Expose the Python application
Declare a Service with type LoadBalancer, listen on port 80, forward to the container’s named http-port, and select Pods labeled app: py-deploy. Applying this manifest lets the managed Kubernetes provider provision the external load balancer. section 8.5.1
Listing 8.27 Service for the Python app
apiVersion: v1
kind: Service
metadata:
name: py-book
spec:
type: LoadBalancer
ports:
- port: 80
targetPort: http-port
selector:
app: py-deploy
Shows the complete Service manifest for the Python application, including LoadBalancer type, port mapping, target port, and Pod selector. section 8.5.1




