Course contentsShow
← Cloud and Infrastructure
Lesson 1216 of 2,98924. Kubernetes NetworkingFree lesson

Services Without Selectors

Manually managing Endpoints to route traffic to external resources or custom backends.

Services Without Selectors

What you'll learn: How to create Kubernetes Services that manually route traffic to external resources or custom backends instead of selecting Pods automatically.

Why Skip Selectors?

Until now, every Service you've created has used selectors to automatically find and route traffic to Pods with matching labels. But what if you need to route traffic to something outside your cluster—like a legacy database server, a third-party API, or a custom IP address? That's where Services without selectors come in.

How It Works

When you create a Service without a selector, Kubernetes doesn't automatically create Endpoints for you. Instead, you manually create and manage the Endpoints object yourself, specifying exactly where traffic should go.

Think of it like this: normally, Kubernetes is your automated switchboard operator, connecting calls based on who's available. With Services without selectors, you become the operator, manually routing calls to specific phone numbers you choose.

The Manual Endpoints Pattern

You define the Service as usual (with ClusterIP, NodePort, or LoadBalancer), but omit the spec.selector field entirely. Then you create a matching Endpoints object with the same name, listing the actual IP addresses and ports where traffic should be routed.

This gives you flexibility to:

  • Point to external databases or services
  • Gradually migrate workloads between clusters
  • Route to custom backends not managed by Kubernetes
  • Create abstract service names that change backends dynamically

Key Takeaway: Services without selectors let you manually control traffic routing by creating Endpoints objects yourself, enabling connections to external resources or custom backends outside Kubernetes' automatic Pod discovery.