DEV Community

Cover image for A Simple Guide to Kubernetes Services and Ingress
jaya sakthi
jaya sakthi

Posted on

A Simple Guide to Kubernetes Services and Ingress

Your Front Door and Your Mailroom

Kubernetes is designed for internal stability—it constantly spins up and tears down your application copies (Pods). That's great for resilience, but how do users and other applications actually find your service? The answer lies in two critical networking concepts: Services and Ingress.

The Kubernetes Service — The Stable Address

A Kubernetes Service is a permanent, stable network address for a changing group of Pods. Pods are ephemeral—their IP addresses constantly change. The Service acts as a load balancer and a consistent endpoint, directing traffic to any healthy Pod that matches its label selector.

The Restaurant Menu Analogy

Think of a Service as the Menu Item at a restaurant. You, the customer (another Pod or an external user), order the "Taco Plate" (the Service name). You don't care which specific chef (Pod) makes it—you just need the final product. The kitchen (Kubernetes) has 10 chefs (Pods) all ready to make tacos. The Service is the order ticket that automatically routes your request to the next available chef.

The most common Service type is ClusterIP, which gives the Service an internal IP address only reachable from inside the cluster.

The Kubernetes Ingress — The Smart Traffic Cop

Ingress is an API object that manages external access to the Services within a cluster, typically HTTP and HTTPS traffic. It acts as the intelligent front door, routing external requests to the correct internal Service based on rules.

The Building's Front Desk and Router Analogy

If a Service is the internal department directory, Ingress is the Main Building Entrance and Receptionist. All outside visitors (users on the internet) enter the building (your cluster) through one main gate (the Ingress's external IP). The Ingress Receptionist reads their request ("I want to go to api.example.com/login") and uses a complex rule book to direct them to the right internal department (the appropriate Service). Ingress is powerful because it lets you expose multiple Services using a single external IP address and domain name.

Real-Time Scenario: Running an E-Commerce Site

Let's say you run an e-commerce platform with three separate microservices:

  1. Frontend Service — Handles the main website (www.mystore.com)
  2. API Service — Handles user accounts and inventory (api.mystore.com)
  3. Checkout Service — Handles payments and orders

Implementation Flow

1. Internal Services
You create three separate ClusterIP Services—one for the Frontend, one for the API, and one for the Checkout. These are only reachable from within Kubernetes.

2. Ingress Deployment
You deploy an Ingress Controller (like NGINX or Traefik) to your cluster. This acts as the actual router.

3. The Ingress Rules
You define a single Ingress resource with rules like this:

  • If the request Host is www.mystore.com, send traffic to the Frontend Service
  • If the request Host is api.mystore.com, send traffic to the API Service
  • If the request Path is /checkout, send traffic to the Checkout Service

This setup uses one external IP for the whole store, while allowing fine-grained control over which internal Service handles each request.

The Missing Controller Challenge

One of the most common challenges for beginners with Ingress is: "My Ingress Resource Does Nothing!"

You create your Ingress YAML file perfectly, but traffic never gets routed, and you don't get a public IP. Why does this happen?

The Ingress resource (the YAML file) is just a set of rules—it's the blueprint. It doesn't actually do any work itself. To enforce those rules and manage the network traffic, you need an Ingress Controller running in your cluster.

Solution

You must manually deploy an Ingress Controller (like NGINX Ingress Controller, Traefik, or a cloud-provider-specific controller) into your cluster. The controller is a Pod that constantly watches the Kubernetes API for Ingress resources and automatically configures its underlying reverse proxy to match the rules you've defined.


Understanding these two fundamental concepts—Services and Ingress—will give you a solid foundation for exposing and managing your Kubernetes applications efficiently.

Top comments (0)