Manage L7 traffic with cluster peering
This usage topic describes how to configure and apply the service-resolver
configuration entry to set up redirects and failovers between services that have an existing cluster peering connection.
For Kubernetes-specific guidance for managing L7 traffic with cluster peering, refer to Manage L7 traffic with cluster peering on Kubernetes.
Service resolvers for redirects and failover
When you use cluster peering to connect datacenters through their admin partitions, you can use dynamic traffic management to configure your service mesh so that services automatically forward traffic to services hosted on peer clusters.
However, the service-splitter
and service-router
configuration entry kinds do not natively support directly targeting a service instance hosted on a peer. Before you can split or route traffic to a service on a peer, you must define the service hosted on the peer as an upstream service by configuring a failover in the service-resolver
configuration entry. Then, you can set up a redirect in a second service resolver to interact with the peer service by name.
For more information about formatting, updating, and managing configuration entries in Consul, refer to How to use configuration entries.
Configure dynamic traffic between peers
To configure L7 traffic management behavior in deployments with cluster peering connections, complete the following steps in order:
Define the peer cluster as a failover target in the service resolver configuration.
The following examples update the
service-resolver
configuration entry incluster-01
so that Consul redirects traffic intended for thefrontend
service to a backup instance in peercluster-02
when it detects multiple connection failures.Define the desired behavior in
service-splitter
orservice-router
configuration entries.The following example splits traffic evenly between
frontend
services hosted on peers by defining the desired behavior locally:Create a local
service-resolver
configuration entry namedfrontend-peer
and define a redirect targeting the peer and its service: