0

I have two frontend applications deployed in different aks cluster (Deployment, service, ingress). They had different subdomains until now but should now be hosted on the same one, e.g. example.com I know it would be easier if they're on the same cluster but for our dev environment every team has their own cluster.

I want to write an ingress in cluster A which has path / which redirects traffic to the service in the same cluster (A) and path /user which redirects traffic to the service in the other cluster (B).

What I tried for now is setup an internal load balancer in Cluster B. Created Peering between the different Vnets of the clusters and created a private DNS Zone with some RecordSets. Now I can access the service in the other cluster via http://user-service.example.internal.

Now I want to write the ingress for Cluster A.

ingress.yaml

apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
  labels:
    app: ingress
  name: ingress
  namespace: default
  annotations:
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  ingressClassName: public-ingress
  rules:
  - host: example.com
    http:
      paths:
      - path: /
        pathType: Prefix
        backend:
          service:
            name: internal-service
            port:
              number: 80
      - path: /user
        pathType: Prefix
        backend:
          service:
            name: external-service
            port:
              number: 80
  tls:
  - hosts:
    - example.com
    secretName: secret-tls

external-service.yaml

apiVersion: v1
kind: Service
metadata:
  name: external-service
  namespace: default
spec:
  type: ExternalName
  externalName: user-service.example.internal

When I access https://example.com via browser everything works fine but if I try to access https://example.com/user I'm getting a 404 from the private ingress-controller. It seems it redirects traffic to the LoadBalancer and to the nginx-ingress but it does not get redirected to the corresponding service.

Why is that so and how can I achieve what I want?

1 Answers1

0

Seems like I was missing this annotation

nginx.ingress.kubernetes.io/upstream-vhost: user-service.example.internal