<p>I have a Kubernetes cluster running on the Google Kubernetes Engine.</p>

<p>I have a deployment that I manually (by editing the <code>hpa</code> object) scaled up from 100 replicas to 300 replicas to do some load testing. When I was load testing the deployment by sending HTTP requests to the service, it seemed that not all pods were getting an equal amount of traffic, only around 100 pods were showing that they were processing traffic (by looking at their CPU-load, and our custom metrics). So my suspicion was that the service is not load balancing the requests among all the pods equally.</p>

<p>If I checked the <code>deployment</code>, I could see that all 300 replicas were ready.</p>

<pre><code>$ k get deploy my-app --show-labels
NAME                DESIRED   CURRENT   UP-TO-DATE   AVAILABLE   AGE       LABELS
my-app              300       300       300          300         21d       app=my-app
</code></pre>

<p>On the other hand, when I checked the <code>service</code>, I saw this:</p>

<pre><code>$ k describe svc my-app
Name:              my-app
Namespace:         production
Labels:            app=my-app
Selector:          app=my-app
Type:              ClusterIP
IP:                10.40.9.201
Port:              http  80/TCP
TargetPort:        http/TCP
Endpoints:         10.36.0.5:80,10.36.1.5:80,10.36.100.5:80 + 114 more...
Port:              https  443/TCP
TargetPort:        https/TCP
Endpoints:         10.36.0.5:443,10.36.1.5:443,10.36.100.5:443 + 114 more...
Session Affinity:  None
Events:            &lt;none&gt;
</code></pre>

<p>What was strange to me is this part</p>

<pre><code>Endpoints:         10.36.0.5:80,10.36.1.5:80,10.36.100.5:80 + 114 more...
</code></pre>

<p>I was expecting to see 300 endpoints there, is that assumption correct?</p>

<p>(I also found <a href="https://engineering.dollarshaveclub.com/kubernetes-fixing-delayed-service-endpoint-updates-fd4d0a31852c" rel="noreferrer">this post</a>, which is about a similar issue, but there the author was experiencing only a few minutes delay until the endpoints were updated, but for me it didn't change even in half an hour.)</p>

<p>How could I troubleshoot what was going wrong? I read that this is done by the Endpoints controller, but I couldn't find any info about where to check its logs.</p>

<p><strong>Update</strong>: We managed to reproduce this a couple more times. Sometimes it was less severe, for example 381 endpoints instead of 445. One interesting thing we noticed is that if we retrieved the details of the endpoints:</p>

<pre><code>$ k describe endpoints my-app
Name:         my-app
Namespace:    production
Labels:       app=my-app
Annotations:  &lt;none&gt;
Subsets:
  Addresses:          10.36.0.5,10.36.1.5,10.36.10.5,...
  NotReadyAddresses:  10.36.199.5,10.36.209.5,10.36.239.2,...
</code></pre>

<p>Then a bunch of IPs were "stuck" in the <code>NotReadyAddresses</code> state (not the ones that were "missing" from the service though, if I summed the number of IPs in <code>Addresses</code> and <code>NotReadyAddresses</code>, that was still less than the total number of ready pods). Although I don't know if this is related at all, I couldn't find much info online about this <code>NotReadyAddresses</code> field.</p>

<p>Pod IPs can be added to <code>NotReadyAddresses</code> if a health/readiness probe is failing. This will in turn cause the pod IP to fail to be automatically added to the endpoints, meaning that the kubernetes service can't connect to the pod.</p>
