I am trying to configure Traefik ingressRoute to route requests from a host to a url. The host and traefik is setup in region1 while the url is for the loadbalancer in region2 pointing to services in region2. See my ingressroute configuration below:
apiVersion: traefik.containo.us/v1alpha1
kind: IngressRoute
metadata:
name: route-name
namespace: default
spec:
entryPoints:
- web
routes:
- match: Host(`region1.domain.com`) && PathPrefix(`/`)
kind: Rule
services:
test-service:
loadBalancer:
servers:
- url: http://region2.domain.com/
I tried to follow the example here: https://doc.traefik.io/traefik/routing/services/ but I get the error:
IngressRoute in version "v1alpha1" cannot be handled as a IngressRoute: strict decoding error: unknown field "spec.routes[0].services.test-service"
I am able to access the url for the loadbalancer in region2,so just wondering if it is possible/how to configure the Ingressroute to route request to the url?
If you're looking to route requests from a Traefik IngressRoute in one region to a service or load balancer URL in another region, there are few different ways to achieve this.
option 1 create a Kubernetes Service of type
ExternalNamethat points to your external URL. This service acts as a DNS alias to your external service.and update your IngressRoute to route requests to the ExternalName Service you just created.
This configuration assumes that requests to
region1.domain.comwill be routed toregion2.domain.comthrough theexternal-service. Theportshould match the port your external service listens on. Since we're pointing to a URL,80is used for HTTP, but adjust accordingly if your service uses HTTPS or another port.Verify your service.
Test the routing by accessing
region1.domain.comfrom a browser or using a tool likecurl. You should be redirected to the service hosted atregion2.domain.com.