Skip to content

Commit

Permalink
Add example ServiceResolver
Browse files Browse the repository at this point in the history
  • Loading branch information
nathancoleman committed Oct 17, 2022
1 parent e41ec34 commit 72a3bf2
Showing 1 changed file with 19 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ This topic describes how to configure Consul API Gateway to route traffic to ser

1. Verify that the [requirements](/docs/api-gateway/tech-specs) have been met.
1. Verify that the Consul API Gateway CRDs and controller have been installed and applied. Refer to [Installation](/docs/api-gateway/install) for details.
1. Verify that a peering connection has been established between Consul clusters and that at least one service has been exported to the cluster containing your `Gateway`. Refer to [Cluster Peering on Kubernetes](https://developer.hashicorp.com/consul/docs/connect/cluster-peering/k8s) for details.
1. Verify that a peering connection has been established between Consul clusters and that the Consul service you want to route to has been exported to the cluster containing your `Gateway`. Refer to [Cluster Peering on Kubernetes](https://developer.hashicorp.com/consul/docs/connect/cluster-peering/k8s) for details.
1. Verify that a `ServiceResolver` has been created in the cluster containing your `Gateway` for the Consul service you want to route to

## Configuration

Expand All @@ -22,7 +23,21 @@ Configure the following fields in your `MeshService` configuration to use this f

## Example

In the following example, routes using the example-mesh-service as a backend will send requests to the `echo` service exported by the peered Consul cluster, `dc2`.
In the following example, routes using `example-mesh-service` as a backend will send requests to the `echo` service exported by the peered Consul cluster, `cluster-02`.

<CodeBlockConfig filename="serviceresolver.yaml">

```yaml hideClipboard
apiVersion: consul.hashicorp.com/v1alpha1
kind: ServiceResolver
metadata:
name: echo
spec:
redirect:
peer: cluster-02
service: echo
```
</CodeBlockConfig>
<CodeBlockConfig filename="meshservice.yaml">
Expand All @@ -34,11 +49,11 @@ metadata:
##...
spec:
name: echo
peer: dc2
peer: cluster-02
```
</CodeBlockConfig>
A `HTTPRoute` may then reference this `example-mesh-service` as its `backendRef`.
A `HTTPRoute` may then reference `example-mesh-service` as its `backendRef`.

<CodeBlockConfig filename="route.yaml">

Expand Down

0 comments on commit 72a3bf2

Please sign in to comment.