mirror of https://github.com/hashicorp/consul
Add example ServiceResolver
parent
e41ec340d8
commit
72a3bf2296
|
@ -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
|
||||
|
||||
|
@ -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">
|
||||
|
||||
|
@ -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">
|
||||
|
||||
|
|
Loading…
Reference in New Issue