Can I use the Ambassador to authenticate service-to-service communication inside a Kubernetes cluster?

7/9/2018

I have a Kubernetes cluster with services and I use Ambassador as an API gateway between outside world and my services.

With Ambassador I know that I can use a service, which I have, to check authentication and authorization for incoming requests but does this only apply for requests coming outside the cluster?

I want to intercept service-to-service calls as well.

-- Nordkraft
kubernetes
kubernetes-security

2 Answers

10/28/2018

I have the same problem at the moment. Ambassador routes every request to an auth service (if provided), the auth service can be anything. So you can setup http basic auth, oauth, jwt auth and so on. The next important thing to mention is that your services may use header based routing (https://www.getambassador.io/reference/headers). Only if a bearer (or something similiar) is present the request will hit your service, otherwise will fail. In your service you can check for permissions and so on. So all in all ambassador can help you, but you have still to program something by yourself.

If you want something ready from start or more advanced you can try https://github.com/ory/oathkeeper or https://istio.io.

If you already found a solution, it would be interesting to know.

-- Marco
Source: StackOverflow

7/10/2018

I would be surprised if you cannot.

This answer needs some terminology, to avoid getting lost in word-soup.

  • App-A is a consumer of an in-cluster Service, and the one which will be authenticating to Ambassador
  • App-Z is the provider of an in-cluster Service (the selector would target its Pods)
  • The k8s Service for app-Z we'll call z-service in the z namespace, for a FQDN of z-service.z.svc.cluster.local

It seems like you can use its v-host support and teach it to honor the in-cluster virtual host (the aforementioned FQDN), then update the z-service selector to target the Ambassador Pods rather than the underlying app-Z Pods.

From app-A's point of view, the only thing that would change is that it now must provide authentication for contacting z-service.z.svc.cluster.local.

Without studying Ambassador's setup more, it's hard to know if Ambassador would Just Work™ at that point, or whether you would then need a "implementation" Service -- such as z-for-real.z.svc.cluster.local -- so that Ambassador knows how to find the actual app-Z Pods.

-- mdaniel
Source: StackOverflow