7: Kubernetes Services

Pods are unreliable, and you should never connect to them directly. You should always connect to them through a Service.

The chapter is divided as follows:

  • Service theory
  • Hands-on with Services

Service Theory

Kubernetes treats Pods as ephemeral objects and deletes them when any of the following events occur:

  • Scale-down operations
  • Rolling updates
  • Rollbacks
  • Failures

This means they’re unreliable, and apps can’t rely on them being there to respond to requests. Fortunately, Kubernetes has a solution — Service objects sit in front of one or more identical Pods and expose them via a reliable DNS name, IP address, and port.

Figure 7.1 shows a client connecting to an application via a Service called app1. The client connects ...

Get The Kubernetes Book - Second Edition now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.