hashicorp / learn-consul-kubernetes

Mozilla Public License 2.0
32 stars 37 forks source link

Add ReferencePolicy to allow cross-namespace routing #55

Closed nathancoleman closed 2 years ago

nathancoleman commented 2 years ago

With the (future) release of Consul API Gateway v0.2.0, there must be a ReferencePolicy in place to allow a route in one namespace to use a backend/service in a different namespace.

Since the stack defined here does exactly that - HTTPRoute in the consul namespace and Service in the default namespace - we need to add a ReferencePolicy that allows it; otherwise, the example here will be broken in the future.

I chose to include the ReferencePolicy in the two-services/ directory since it needs to live alongside the services that will be routed to, within the same namespace. Alternatively, we could update the Learn guide to draw the practitioner's attention to the policy and install it separately; however, that's a much bigger cross-repo change. If you feel strongly that we should go that route instead, please speak to that by leaving a comment below.

Testing

I followed the Learn guide here but used a build from the main branch of hashicorp/consul-api-gateway to ensure that the ReferencePolicy meets the new requirements and that this stack will continue to work after release.