liveBook · Manning

Loadbalancer service

As explained in Kubernetes for Developers

A LoadBalancer Service is a Kubernetes Service type that requests an externally reachable network load balancer and external IP address.

A LoadBalancer Service publishes selected Kubernetes Pods to internet users. Kubernetes assigns the Service an internal cluster IP and provisions an external IP address through an external network load balancer. section 3.2.5

Configure the Service to control how traffic reaches the application:

  • Use selector labels to target Pods; the Service selects Pods directly rather than referencing a Deployment. section 3.2.5
  • Set port for the user-facing port and targetPort for the Pod’s receiving port; they may differ, such as 80 to 8080. section 3.2.5
  • Route traffic only to running Pods, even while replica counts change during upgrades or rollouts. section 3.2.5

Expose a timeserver

A Service selecting timeserver Pods can expose TCP port 80 with type: LoadBalancer. After creation, kubectl get service shows an external IP, which users can query with curl. section 3.2.5

Listing 3.3 Chapter03/3.2_DeployingToKubernetes/service.yaml
apiVersion: v1
kind: Service
metadata:
  name: timeserver
spec:
  selector:               #1
    pod: timeserver-pod   #1
  ports:
  - port: 80              #2
    targetPort: 80        #3
    protocol: TCP         #4
  type: LoadBalancer      #5

The YAML listing shows the selector, port mapping, TCP protocol, and LoadBalancer type in one deployable configuration. section 3.2.5

How Kubernetes for Developers covers it

How deep it goes
Explains selectors, port mapping, assigned addresses, and running-Pod routing, but defers detailed Service features to later treatment.
Examples
Uses a timeserver YAML manifest, kubectl service output, and curl against the provisioned external IP.
What you can do after
Operate a public Kubernetes endpoint by configuring a LoadBalancer Service and checking or calling its external IP.
How it connects
Connects Services with Pods, Deployments, service discovery, and microservice architecture.

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 Kubernetes for Developers. The section links point to the parts of the book it draws on.