SERVICES IN KUBERNETES EXPLAINED
Think of a Kubernetes Service as a reception desk for a company.
Pods are constantly being created, destroyed, and replaced. Their IP addresses can change. The Service provides a stable address that clients can use to reach the right Pods.
WHAT IS A SERVICE
→ a Service is a Kubernetes networking object
→ provides a stable network endpoint for a group of Pods
→ routes traffic to healthy Pods
→ hides the changing IP addresses of individual Pods
→ makes applications discoverable inside or outside the cluster
WHY SERVICES EXIST
→ Pods are temporary
→ Pod IP addresses can change
→ a client should not need to track individual Pods
→ Service provides a stable virtual IP and DNS name
→ traffic is automatically routed to matching Pods
HOW A SERVICE WORKS
→ application Pods are running
→ Pods have individual IP addresses
→ Service selects Pods using labels
→ client sends request to Service
→ Service identifies matching Pods
→ traffic is forwarded to one of the Pods
SERVICE ARCHITECTURE
→ Client
→ Service
→ Selector
→ Pod 1
→ Pod 2
→ Pod 3
→ the Service acts as the stable entry point
SERVICE SELECTORS
→ Services use labels to identify Pods
→ example
→ app=backend
→ Service searches for Pods with matching labels
→ matching Pods become Service endpoints
→ traffic is distributed among them
SERVICE DISCOVERY
→ Kubernetes automatically provides DNS names for Services
→ example
→ backend.default.svc.cluster.local
→ applications can communicate using the Service name
→ no need to hard-code Pod IP addresses
CLUSTERIP SERVICE
→ default Service type
→ exposes application inside the Kubernetes cluster
→ receives a stable internal IP
→ accessible by other Pods and Services
→ ideal for internal APIs and databases
NODEPORT SERVICE
→ exposes a Service through a port on each Node
→ external traffic reaches:
→ Node IP + NodePort
→ Kubernetes forwards traffic to the Service
→ useful for basic external access
LOADBALANCER SERVICE
→ provisions an external load balancer when supported by the environment
→ provides an externally reachable IP or hostname
→ traffic flows:
→ Internet
→ Load Balancer
→ Service
→ Pods
→ commonly used for public applications
EXTERNALNAME SERVICE
→ maps a Kubernetes Service to an external DNS name
→ does not create a normal proxy endpoint
→ useful when applications need to reference an external service through a Kubernetes Service name
HEADLESS SERVICES
→ created by setting:
→ clusterIP: None
→ no virtual ClusterIP is assigned
→ DNS returns individual Pod addresses
→ commonly used with StatefulSets
→ allows clients to communicate directly with specific Pods
SERVICE LOAD BALANCING
→ multiple Pods receive traffic
→ Service distributes requests among available endpoints
→ example
→ Client
→ Service
→ Pod 1
→ Pod 2
→ Pod 3
→ if a Pod becomes unavailable
→ it is removed from the active endpoints
SERVICE + DEPLOYMENT
→ Deployment manages Pods
→ Service exposes Pods
→ Deployment creates and replaces Pods
→ Service provides stable networking
→ together they create a reliable application architecture
SERVICE + STATEFULSET
→ StatefulSet provides stable Pod identities
→ Service provides networking
→ Headless Service allows direct DNS-based discovery
→ commonly used for databases and distributed systems
COMMON SERVICE TYPES
→ ClusterIP
→ internal cluster access
→ NodePort
→ exposes through Node ports
→ LoadBalancer
→ external load balancer
→ ExternalName
→ maps to external DNS
→ Headless Service
→ direct Pod discovery
COMMON SERVICE PROBLEMS
→ Service has no endpoints
→ selector does not match Pod labels
→ Pods are not Ready
→ incorrect targetPort
→ incorrect Service port
→ NetworkPolicy blocks traffic
→ DNS resolution problems
BEST PRACTICES
→ use meaningful labels
→ verify selectors match Pods
→ use readiness probes
→ avoid exposing internal services unnecessarily
→ use ClusterIP for internal communication
→ use LoadBalancer or Ingress for appropriate external traffic
→ monitor Service endpoints
REAL WORLD ANALOGY
→ Kubernetes cluster = company
→ Pod = employee
→ Service = reception desk
→ Service IP = company phone number
→ Service selector = department directory
→ LoadBalancer = public entrance
→ Headless Service = direct employee directory
END TO END FLOW
→ client sends request
→ request reaches Service
→ Service checks matching endpoints
→ healthy Pod selected
→ request forwarded to Pod
→ Pod processes request
→ response returns through the Service
KEY IDEA
→ Pods are temporary
→ Pod IPs can change
→ Services provide stable networking
→ Services discover Pods
→ Services route traffic
→ Services make Kubernetes applications easier to connect and scale
Grab KUBERNETES EBOOK:
https://t.co/1JQaCCc17i
Did you know that creator of the Morris Worm, Robert Tappan Morris, spent 3 years on probation. Later creating a small company that sold to Yahoo (with Paul Graham). Morris later cofounded ycombinator, a worm for startups
that guy loved creating worms...
It’s been 10 years since I took a million dollar pay cut to pay all staff at Gravity Payments a $70,000 minimum wage. People have wondered: How did it go?
We conducted a comprehensive study of everything that has happened since our 2015 announcement.
We are proof that paying living wages is good for both employees and businesses.
Since raising wages, our revenue and profits have soared, employees have started families while continuing to provide excellent customer service, and clients have become happier and stayed longer.
It worked so well that we raised the minimum to $80,000 and added an employee profit-sharing program.
Yet outside our company, it made no impact: no businesses followed suit, and the pay gap between workers and CEOs remains massive.
just released pest v4.6.0 with time-balanced sharding
this was a long-time request from the @laravelphp cloud team; with around 15,000 tests, browser tests and other slow ones need to be spread evenly across all shards
fucking dope