liveBook · Manning

Loadbalancer service

As explained in Road to Kubernetes

A Kubernetes LoadBalancer Service is a Service type that provisions or integrates with an external load balancer to expose workloads outside the cluster.

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

How Road to Kubernetes covers it

How deep it goes
Explains routing, standard ports, provider provisioning, static IPs, and DNS, while deferring HTTPS certificates.
Examples
Uses Python and Node.js applications plus an NGINX Pod to demonstrate selectors, port mappings, and public exposure.
What it assumes
Assumes Pods or Deployments have matching labels and distinguishes external Services from internal ClusterIP communication.
What you can do after
Apply it via Kubernetes YAML to expose selected Pods and connect a custom domain to the resulting public IP.
How it connects
Connects Kubernetes Services with Deployments, Pods, NodePort, ClusterIP, DNS A records, and cloud-managed load balancers.

Also explained in

Compare how 5 books explain loadbalancer service →

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Road to Kubernetes. The section links point to the parts of the book it draws on.