<p>Let say there's a deployment named my-deployment which is consisted of 3 pods, now we use port-forward forward a local port to this deployment :</p>
<pre><code>kubectl port-forward deployment/my-deployment 8888 9999
</code></pre>
<p>My question is : when I visit localhost:8888 serveral times then which pod would be forwarded to ? Always forward to a fixed pod(like first pod) ? Or forward it by random ? Or use round-roubin strategy ?</p>

chenxinlong
<p><code>when I visit localhost:8888 serveral times then which pod would be forwarded to ?</code></p>
<p>Will forward to the first pod sorted by name.</p>
<p><code>Always forward to a fixed pod(like first pod) ?</code></p>
<p>Fixed.</p>
<p><code>Or forward it by random ? Or use round-roubin strategy ?</code></p>
<p>Fixed to the first pod sorted by name.</p>
<p>Presumed you have performed a port-forward command and curl successfully. Now if you scale the deployment to 0; then scale up; if you curl again now you will get an error. This is because the pod that the port forwarded to has been terminated during the scale to 0.</p>
