Does kubectl port-forward ignore loadBalance services?

后端 未结 2 642
眼角桃花
眼角桃花 2020-12-12 00:53

My Environment: Mac dev machine with latest Minikube/Docker

I built (locally) a simple docker image with a simple Django REST API \"hello world\".I\'m running a depl

相关标签:
2条回答
  • 2020-12-12 01:19

    The kubernetes API only provides Pod port forward operations (CREATE and GET). Similar API operations don't exist for Service endpoints.

    So I would say kubectl looks up a Pod from the service information provided on the command line and forwards directly to a Pod rather than forwarding to the ClusterIP/Service port and allowing the cluster to load balance the service like regular service traffic.

    kubectl code

    Here's a little bit of the flow from the kubectl code that seems to back that up (I'll just add that Go isn't my primary language)

    The portforward.go Complete function is where kubectl portforward does the first look up for a pod from options via AttachablePodForObjectFn:

    The AttachablePodForObjectFn is defined as attachablePodForObject in this interface, then here is the attachablePodForObject function.

    To my (inexperienced) Go eyes, it appears the attachablePodForObject is the thing kubectl uses to look up a Pod to from a Service defined on the command line.

    Then from there on everything deals with filling in the Pod specific PortForwardOptions (which doesn't include a service) and is passed to the kubernetes API.

    0 讨论(0)
  • 2020-12-12 01:27

    The reason was that my pods were randomly in a crashing state due to Python *.pyc files that were left in the container. This causes issues when Django is running in a multi-pod Kubernetes deployment. Once I removed this issue and all pods ran successfully, the round-robin started working.

    0 讨论(0)
提交回复
热议问题