Can Istio map an non existing host to a given service on K8s

6/7/2018

2 questions for you guys.

I have a pod A trying to request a url called foo doing a GET on http://foo . But the service foo does not exists in my K8 cluster instead I have a service called fooX that could do the job. Is it possible to create an Istio configuration to route my call to foo to the fooX service ?

More generally we have a bunch of services calling other services and that get the service urls via environment variables, but the more service we have the more environment variable we have, it is not scalable. I hoped service mesh would help in the regard but I am not sure.

-- SeB.Fr
istio
kubernetes

2 Answers

6/15/2018

As mentioned in the other answer, it is possible using a ExternalService (renamed ServiceEntry in 0.8.1). However, this comes with the caveat that the name you choose for the alias in the ServiceEntry be DNS resolvable for HTTP. Otherwise the DNS lookup will fail, and the connection will never make it to the proxy to be routed based on the ServiceEntry.

-- Isaiah Snell-Feikema
Source: StackOverflow

6/8/2018

You can use K8S ExternalName services for that:

An ExternalName service is a special case of service that does not have selectors. It does not define any ports or Endpoints. Rather, it serves as a way to return an alias to an external service residing outside the cluster.

While it was intended to define an alias to a service outside the cluster, it can be used to create aliases for the services inside the cluster as well. In your case, just define the following K8S Service:

kind: Service
apiVersion: v1
metadata:
  name: foo
  namespace: prod
spec:
  type: ExternalName
  externalName: fooX.prod.svc.CLUSTER

So when your apps will send requests to http://foo.prod.svc.CLUSTER, the requests will arrive http://fooX.prod.svc.CLUSTER.

-- Vadim Eisenberg
Source: StackOverflow