<p>I have the following scenario at hand and i would like to get the lowest possible latency between pods ( i do not wish to deploy all containers to same pod). So the following scenario is what i would like to achieve: </p>

<p>Lets say you have a Kubernetes cluster with 4 nodes:
- on each node you have a sqlproxy to central database that is not part of kubernetes
- on each node you have 4 pods that call database through that sqlproxy</p>

<p>As far as I have learned when I create a service that, service distributes traffic "randomly" between pods in service. Meaning that pod from node 1 could call sqlproxy on node 4 and pod on node 2 could call sqlproxy on node 3 and so on.</p>

<p>I would like to achieve that pods on node 1 call whenever possible sqlproxy on node 1, so it has the minimum latency.</p>

<p>Is this even possible or are the delays between nodes so small they can be disregarded?</p>

Nejc
<p>Deploy the SQL proxy as a side car to your app (two containers in one pod, one being the app, one being the proxy) .</p>

<p>Your deployment will look something like this:</p>

<pre><code>apiVersion: extensions/v1beta1
kind: Deployment
metadata:
  namespace: ...
  name: my-app
  labels:
    app: my-app

spec:
  replicas: 3
  template:
    metadata:
      labels:
        app: my-app
    spec:
      containers:
        - name: app
          image: &lt;&lt; app image &gt;&gt;
          ports:
            - containerPort: 8080
        - name: sql-proxy
          image: &lt;&lt; SQL proxy image &gt;&gt;
          ports:
            - containerPort: 3306
</code></pre>

<p>Now make the app connect to <code>localhost:3306</code> to connect to the SQL proxy running in the same pod. In that way you avoid the potentially expensive cross-node hop and keep the connection local.</p>
