Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to use 1 Kubernetes ingress object to route traffic to k8s services in different clusters?

I have the following setup: k8s cluster A, containing service SA k8s cluster B, containing service SB, and an HTTP ingress that routes traffic to SB

Is it possible to add service SA as the backend service for one of the path of the ingress? If so, how do I refer to it in the ingress configuration file? (using selectors in the usual way doesn't work, presumably because we are in different clusters)

like image 803
Ana Ulin Avatar asked Dec 05 '25 10:12

Ana Ulin


1 Answers

Ingress objects help configure HTTP(S) load balancing for a single cluster. They don't have a concept of multiple clusters, so they aren't going to have a configuration language for what you are trying to accomplish (maybe they will with Ubernetes, but they certainly don't today).

The upshot is that you can bypass the Ingress configuration and configure the routing manually (after all, Ingress is really just an ease-of-use shortcut for a typical L7 configuration). You can create your own L7 configuration in GCP and set up the path based forwarding to route to different backend groups. You can then assign the backend groups to a NodePort service that you configure in each of your clusters.

The rough steps are:

  1. Create a NodePort service in each cluster
  2. Create an HTTP health check for each service
  3. Add a firewall rule to allow http health checks to hit your backends
  4. Add a service to the instance group for your cluster (e.g. gcloud compute instance-groups managed set-named-ports ...)
  5. Add backend services for the load balancer (e.g. gcloud compute backend-services create ...)
  6. Add a backend for your cluster to this backend service (e.g. gcloud compute backend-services add-backend ...)
  7. Map that URL to your backend service (e.g. gcloud compute url-maps create ...)
  8. Create a load balancing proxy for that backend service (e.g. gcloud compute target-http-proxies create ...)
  9. Create a forwarding rule for that proxy (e.g. gcloud compute forwarding-rules create ...)
like image 104
Robert Bailey Avatar answered Dec 08 '25 11:12

Robert Bailey



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!