<p>Recently I have been researching about microservices and kubernetes. All the tutorial and article I read online talks about general staff. I have several specific questions about building a microservices app on kubernetes.</p>

<ol>
<li><strong>API gateway:</strong> Is API gateway a microservice I built for my app that can automatically scale? Or is it already a built-in function of kubernetes? The reason I ask is because a lot of the articles are saying that load-balancing is part of the API gateway which confuse me since in kubernetes, load-balancing is handled by <code>service</code>. Also, is this the same as the API gateway on AWS, why don't people use the AWS API gateway instead?</li>
<li><strong>Communication within services:</strong> from what I read only, there are <em>Rest/RPC</em> way and <em>Message queue</em> way. But why do people say that the <em>Rest</em> way is for sync operation? Can we build the services and have them communicate with rest api with <code>Nodejs async/await</code> functions? </li>
<li><strong>Service Discovery:</strong> Is this a problem with kubernetes at all? Does kubernetes automatically figure out this for you?</li>
<li><strong>Databases:</strong> What is the best practice to deploy a database? Deploy as a microservice on one of the node? Also, some articles say that each service should talk to a different db. So just separate the tables of one db to several dbs?</li>
</ol>

Hansen W
<blockquote>
  <p>Is API gateway a microservice I built for my app that can
  automatically scale? Or is it already a built-in function of
  kubernetes?</p>
</blockquote>

<p>Kubernetes does not have its own API-gateway service. It has an Ingress controller, which operates as a reverse proxy and exposes Kubernetes resources to the outside world. And Services, which load-balance traffic between Pods linked to them.</p>

<p>Also, Kubernetes provides an auto-scaling according to the resources consumed by Pods, memory usage or CPU utilization and some custom metrics. It is called Horizontal Pod Autoscaler, and you can read more about it <a href="https://medium.com/google-cloud/kubernetes-horizontal-pod-scaling-190e95c258f5" rel="nofollow noreferrer">here</a> or in the <a href="https://kubernetes.io/v1.1/docs/user-guide/horizontal-pod-autoscaler.html" rel="nofollow noreferrer">official documentation</a>. </p>

<blockquote>
  <p>Service Discovery: Is this a problem with kubernetes at all? Does kubernetes automatically figure out this for you?</p>
</blockquote>

<p>Service Discovery is not a problem in Kubernetes, it has an entity called Services responsible for this. For more information, you can look through the <a href="https://kubernetes.io/docs/tutorials/services/" rel="nofollow noreferrer">link</a>.</p>

<p>Your other questions refer more to the architecture of your application.</p>
