K8s CKA Certificate 7 — Service

Tony
9 min readSep 15, 2024

Previously, we learned how to deploy stateless application Pods using Deployment. Some of the applications within these Pods provide web access services, so we need to access these Pods via the network.

When deploying Pods, the K8s cluster assigns them their own IP addresses, allowing Pods to communicate with each other directly through internal IP addresses within the cluster. However, we need to address two issues:

  1. Service Discovery: In K8s, Pod IP addresses are dynamically assigned and are reassigned every time a Pod restarts, making it impossible to use a fixed IP to access a Pod.
  2. Load Balancing: Pods managed by Deployment are replicated and can be scaled up or down. Therefore, we need a unified access point to automatically distribute incoming requests to these Pod replicas.

Service Basics

A Service in Kubernetes (K8s) is a resource object responsible for network service discovery and load balancing. It defines the method of accessing Pods via the network. When accessing a Service, it automatically forwards the request to the appropriate Pod, which then handles the incoming request.

Key Functions of Service:

  1. Service Discovery: When Pods change (due to failures, restarts, scaling up or down, etc.), the Service can still…

--

--