VirtualServices define traffic routing rules. DestinationRules define load balancing and subsets. Together, they enable canary deployments, traffic shifting, and advanced routing.
VirtualServices define traffic routing rules. DestinationRules define load balancing and subsets. Together, they enable canary deployments, traffic shifting, and advanced routing.
Lesson outline
VirtualService defines how traffic is routed to a Service. Multiple http/tcp routes can be defined with different destinations, weights, and policies.
Example: route 90% of traffic to v1, 10% to v2 (canary). Or route based on headers: if user-type=premium, route to premium-svc.
Supports timeout, retry, fault injection (deliberately introduce errors for testing).
DestinationRule specifies how traffic is handled at the destination. Defines subsets, connection pool sizes, outlier detection, etc.
Subset: a group of Pods selected by labels. E.g., version=v1 or version=v2. Used by VirtualService to implement canary routing.
Connection pool: TCP and HTTP connection limits. Prevents resource exhaustion.
Outlier detection: automatically eject Pods that are behaving badly (high error rate, slow responses).
Deploy new version alongside old version. Use VirtualService to gradually shift traffic: start at 5%, increase to 10%, then 50%, then 100%.
Monitor metrics during each shift. If error rate spikes, traffic is automatically rolled back.
Enables safe testing of new features in production.
Fault injection: deliberately introduce delays or errors to test resilience.
Timeout and retry: define how long to wait and how many times to retry.
Circuit breaker: stop sending traffic to backend if it's overloaded.
Header-based routing: route based on HTTP headers (user type, API version, etc.).
Key takeaways
💡 Analogy
VirtualService is like a maitre d' at a restaurant who directs diners to tables (subsets). "90% of people go to Table A, 10% to Table B." DestinationRule is like the table configuration: table size (connection pool), how many waiters per table (load balancing), and when to close a table due to bad service (outlier detection).
⚡ Core Idea
VirtualService = traffic routing logic. DestinationRule = destination configuration. Subsets enable splitting traffic across different Pods.
🎯 Why It Matters
Together, they enable advanced deployment patterns (canary, blue-green, A/B testing) without code changes or manual load balancer configuration.
Ready to see how this works in the cloud?
Switch to Career Paths for structured paths (e.g. Developer, DevOps) and provider-specific lessons.
View role-based pathsSign in to track your progress and mark lessons complete.
Questions? Discuss in the community or start a thread below.
Join DiscordSign in to start or join a thread.