Course contentsShow
← Cloud and Infrastructure
Lesson 1603 of 2,98933. Service Mesh FeaturesFree lesson

Virtual Services and Destination Rules

Understand how to define routing rules with virtual services and configure traffic policies with destination rules.

Virtual Services and Destination Rules

What you'll learn: How to define routing rules with virtual services and configure traffic policies with destination rules in a service mesh.

The Core Idea

In a service mesh, virtual services define how requests are routed to destinations, while destination rules define what happens to traffic once it reaches those destinations. Think of virtual services as GPS directions telling traffic which path to take, and destination rules as the rules of the road once you arrive (speed limits, lane assignments, etc.).

Virtual Services: The Routing Layer

Virtual services let you specify routing rules based on criteria like HTTP headers, URIs, or source services. They answer: "Where should this request go?"

You can:

  • Route 90% of traffic to version 1 and 10% to version 2 (canary deployments)
  • Direct requests with specific headers to a beta environment
  • Implement retries and timeouts for resilience

Virtual services sit between the client and the actual service, intercepting requests before they reach their destination.

Destination Rules: The Policy Layer

Destination rules configure what happens after routing decisions are made. They answer: "How should I handle traffic to this destination?"

You can define:

  • Load balancing policies (round-robin, least-connections)
  • Connection pool settings (max connections, timeouts)
  • Subset definitions (versions like v1, v2)
  • Circuit breaker thresholds

How They Work Together

Virtual services reference subsets defined in destination rules. For example, a virtual service might route 80% of traffic to subset "stable" and 20% to subset "canary," while the destination rule defines what "stable" and "canary" actually mean (e.g., pods with label version: v1 vs version: v2).

Key Takeaway: Virtual services control where traffic flows based on rules, while destination rules control how traffic behaves at each destination—together they provide fine-grained traffic management in your service mesh.