<p>Not sure if this is a silly question. When the same app/service running in multiple containers, how do they report themselves to zookeeper/etcd and identify themselves? So that load balancers know the different instances and know who to talk to, where to probe and dispatch, etc..? Or the service instances would use some id from the container in their identification?</p>
<p>Thanks in advance</p>

dengying
<p>To begin with, let me explain in a few sentences <a href="https://platform9.com/blog/kubernetes-service-discovery-principles-in-practice/" rel="nofollow noreferrer">how it works</a>:</p>
<blockquote>
<p>The basic building block starts with the  <strong>Pod</strong>, which is just a resource that can be created and destroyed on demand. Because a Pod can be moved or rescheduled to another <strong>Node</strong>, any internal IPs that this Pod is assigned can change over time.
If we were to connect to this Pod to access our application, it would not work on the next re-deployment. To make a Pod  <strong>reachable</strong> to external networks or clusters without relying on any internal IPs, we need another layer of abstraction. K8s offers that abstraction with what we call a  <strong>Service Deployment.</strong></p>
</blockquote>
<p>This way, you can create a website that will be identified, for example, by a load balancer.</p>
<blockquote>
<p><strong>Services</strong> provide network connectivity to Pods that work uniformly across clusters. <strong>Service discovery is the actual process of figuring out how to connect to a service.</strong></p>
</blockquote>
<hr />
<p>You can also find some information about Service <a href="https://kubernetes.io/docs/concepts/services-networking/service/" rel="nofollow noreferrer">in the official documentation</a>:</p>
<blockquote>
<p>An abstract way to expose an application running on a set of <a href="https://kubernetes.io/docs/concepts/workloads/pods/" rel="nofollow noreferrer">Pods</a> as a network service.
With Kubernetes you don't need to modify your application to use an unfamiliar service discovery mechanism. Kubernetes gives Pods their own IP addresses and a single DNS name for a set of Pods, and can load-balance across them.</p>
</blockquote>
<p>Kubernetes supports 2 primary modes of finding a Service - environment variables and DNS. You can read more about this topic <a href="https://kubernetes.io/docs/concepts/services-networking/service/#discovering-services" rel="nofollow noreferrer">here</a> and <a href="https://platform9.com/blog/kubernetes-service-discovery-principles-in-practice/" rel="nofollow noreferrer">here</a>.</p>
