<p>This is my first time trying to deploy a microservices architecture into Kubernetes.  At the beginning, I was considering to use Ambassador as my API Gateway. I also have an authentication service which validates users and generates a JWT token, however, I need to validate this token
every time a service is called. This represents an overload problem (since every time the API Gateway receives traffic it will go to this external authentication service to validate the JWT token) and Ambassador does not have an option to do this filtering without the use of the external service.</p>

<p>Using the Zuul Gateway seems like the best option in this case, since it allows me to validate the JWT token inside the gateway (not through an external service like Ambassador). However, I'm not sure how Zuul is going to work if I deploy it in Kubernetes since, as I understand, Zuul requires to have the address of the service discovery (like Eureka).</p>

<p>if I deploy Zuul in my Kubernetes cluster, then how it will be able to locate my services? </p>

<p>Locally, for example, there is no problem since I was using Eureka before, and I knew its address. Also, I don't think having Eureka deployed in Kubernetes will be a good idea, since it will be redundant.</p>

<p>If it is not possible to do it with Zuul, is there another API Gateway or approach where I can validate tokens using the Gateway instead of relying on an external authentication service like Ambassador does?</p>

<p>Thank you.</p>

Carlos Gomez
<p>In kubernetes you already have "discovery" service which is kubernetes-service. It locates pods and serves as load balancer for them.</p>

<p>Lets say you have Zuul configuration like this:</p>

<pre><code>zuul:
  routes:
    books-service:
      path: /books/**
      serviceId: books-service
</code></pre>

<p>which routes requests matching <code>/books/**</code> to the service <code>books-service</code>. Usually you have an Eureka which gives you real address of <code>books-service</code>, but not now. </p>

<p>And this is where Ribbon can help you - it allows you to manually tune routing after Zuul has matched it's request. So you need to add this to configuration:</p>

<pre><code>books-service.ribbon.listOfServers: "http://books:8080"
</code></pre>

<p>and after Zuul had found serviceId (<code>books-service</code>) it will route the request to <code>books:8080</code></p>

<p>And <code>books:8080</code> is just a kubernetes-service:</p>

<pre><code>kind: Service
apiVersion: v1
metadata:
  name: books
spec:
  selector:
    app: spring-books-service
  ports:
  - protocol: TCP
    port: 8080
    targetPort: 9376
</code></pre>

<p>You can say its a load balancer that takes traffic from :8080 and redirects it to pods with label <code>app: spring-books-service</code>.</p>

<p>All you have to do next is to assign labels to pods (via deployments for example)</p>

<p>Btw, you can configure Ribbon like this in any app and kubernetes will locate all your apps (pods) with its services so you dont need any discovery service at all! And since k8s-services are much more reliable than Eureka, you can simply remove it.</p>
