<p>I am trying to deploy my sample micro service Docker image in Kubernetes cluster having 2 node. I explored everything about Pods, Services, Deployment, StatefulSets and Daemon-sets etc.</p>

<p>I am trying to create a sample deployment and Service for that. Here I explored about how deployment provides the scalability and load balancing functionality. And exploring about service discovery by providing Services ClusterIp.</p>

<p>I have two questions:</p>

<p>My scenario is that I am trying to deploy microservice on my on-premise Ubuntu machine. The machine has the IP address of 192.168.1.15. When I am referring Kubernetes, service will also have one clusterIP. </p>

<ol>
<li><p>If my microservice end point is <code>/api/v1/loadCustomer</code>, how I can call this end point? Do I need to use clusterIP also ? Can I call simply 192.168.1.15:8080/api/v1/loadCustomers ?</p></li>
<li><p>What is the role of clusterIP when I am calling my end point ? Can I directly use port?</p></li>
</ol>

<p>I am referring to the following link for exploration:</p>

<p><a href="https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/services-networking/connect-applications-service/</a></p>

Mr.DevEng
<p><strong>tldr:</strong></p>

<p>you can not access the application using the <strong>clusterIP</strong> from the outside of the cluster. you can access the application using either loadbalancer's IP (<code>type=LoadBalaner</code>) or Node's IP (<code>type=NodePort</code>).  </p>

<p><strong>benefit of clusterIP:</strong>
As you know that pods can be created and terminated during its life-cycle consequently IP (endpoint IP)address created and terminated.Therefore, clusterIP is static which does not depends of the life-cycle of the pods.  </p>

<p><strong>Long Answer</strong></p>

<p><strong>In a Kubernetes cluster</strong>
an application or pod has following abstraction. </p>

<p><strong>Endpoint IP and Port</strong>:It is provided by the CNI Plugins such as flannel, calico.</p>

<ul>
<li>Each pod has an IP and tragetPort which is <em>UNIQUE</em>.</li>
</ul>

<p>you can list and watch the endpoints by the following commands. </p>

<pre><code>kubectl get endpoints --all-namespaces 
</code></pre>

<p><strong>clusterIP and port</strong> :  It is provided by the <strong><em>kube-proxy</em></strong> component.  </p>

<ul>
<li><p>The replicated pods share a clusterIP and Port. </p></li>
<li><p>Load-balancing of request to the replicated pods.</p></li>
<li>internally expose so that other pod can discover it</li>
</ul>

<p>you can list and watch clusterIP and port with the following command </p>

<pre><code>kubectl get services --all-namespaces 
</code></pre>

<p><strong>externalIP and port</strong>: It can be layer 3-4 load balancer's IP and port or node's IP and Nodeport.</p>

<p>if you want to use loadbalancer's IP and port, you can use <code>type=LoadBalaner</code> in service file.</p>

<p>If you want to use node's IP, you need to use <code>type=NodePort</code> in service file. </p>
