How DestinationRules and VirtualServices work together
- VirtualService: decides how traffic is routed (hosts, path/URI matches, weights, headers).
- DestinationRule: applies policies to the concrete destination after routing (per-subset or host-level settings).
- Subsets: logical names in a DestinationRule that map to pods via label selectors. VirtualServices reference these subset names to route to specific workload versions.
Example: two deployments (v1 & v2), one Service, DestinationRule with subsets, and VirtualService traffic split
Deployments for v1 and v2 (each with 3 replicas):app: frontend label:
Resource summary
Key points
- DestinationRules are applied after routing decisions are made by VirtualServices.
- Subsets are logical names in a DestinationRule that map to pods via labels; VirtualServices reference these subset names to direct traffic.
- DestinationRules control per-subset or host-level policies:
- Load balancing algorithms
- Connection pool sizes
- Timeouts and retries
- Circuit breaking
- Client TLS / mTLS settings
- Create DestinationRules in the same namespace as the targeted workloads. The
hostin the DestinationRule can be the short service name (e.g.,app-svc) or the full FQDN (e.g.,app-svc.frontend.svc.cluster.local). - Ensure subset names used in VirtualServices exactly match the subset names defined in DestinationRules.
Ensure the subset names used in the VirtualService match the subset names defined in the DestinationRule, and place the DestinationRule in the same namespace as the service/workloads it targets.
