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 :
kubectl port-forward deployment/my-deployment 8888 9999
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 ?
CodePudding user response:
when I visit localhost:8888 serveral times then which pod would be forwarded to ?
Will forward to the first pod sorted by name.
Always forward to a fixed pod(like first pod) ?
Fixed.
Or forward it by random ? Or use round-roubin strategy ?
Fixed to the first pod sorted by name.
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.