Hands-On Lab
This lab integrates the core concepts of Chapter 3. We'll programmatically create a Service to expose a set of Pods and then build a separate tool to observe the dynamic nature of the associated Endpoints
object in real-time.
Objectives:
Write a Go program that creates a
ClusterIP
Service targeting Pods based on a specified label selector (e.g.,app=my-test-app
). The program should allow customization of the Service name, namespace, selector, service port, and target port via flags.Build a separate Go tool that specifically watches the
Endpoints
object corresponding to a given Service name and namespace.This watcher tool should print clear updates whenever the
Endpoints
object is added, modified (e.g., Pods added/removed from ready/notReady lists), or deleted.Observe how actions performed on the Pods (scaling deployments, deleting pods, readiness changes) are reflected almost immediately in the output of the watcher tool.
Tasks:
Navigate to the Code: Find the source code for both programs required for this lab in the companion GitHub repository. Look for the directory related to Chapter 3:
This lab demonstrates the dynamic relationship between Services, Endpoints, and Pod readiness. You've programmatically created the stable abstraction (Service) and observed the real-time updates that link it to the underlying ephemeral Pods via the Endpoints object. This understanding is crucial as we move towards more complex networking configurations like Ingress and Network Policies.
Last updated
Was this helpful?