My leegacy server uses TCP sockets to serve clients (also inside kubernetes). Clients also run inside the same cluster in which server is. Can we use NGINX to distribute traffic to server POD instances ? If so how ?
Kubernetes Service
does exactly that. You don't need nginx to do load balancing across pods inside the cluster.
If you want to to weighted distribution of traffic, look at istio
or envoy ambassador
.
https://istio.io/docs/tasks/traffic-management/tcp-traffic-shifting/ https://www.getambassador.io/reference/tcpmappings/
Yes its possible.The standard Kubernetes Ingress resources assume that all traffic is HTTP-based; they do not cater for the case of basic TCP or UDP load balancing. You need to use the stream-snippets ConfigMap key to embed the required TCP and UDP load-balancing configuration directly into the stream{} block of the NGINX configuration file. Here is the example.