<p>I think I have interesting use case so I would like to hear advices of the people with more knowledge.
I have my App (&quot;<strong>ads</strong>&quot;) which works in Kubernetes without any issue. It runs on port 9000.
It has args which have its instance name (<code>serverName</code>) and in the list of servers it has reference to all other servers as well (<code>servers</code>) in order to run those servers in so called <code>companion mode</code> needed for performance reasons.
Please have in mind that <strong>this is NOT a WEB SERVER</strong> and simple <strong>replicas will NOT</strong> work for what we need to achieve and that is to have multiple ADS servers working in so call companion mode in which the primary server sends the cached data to another server so that server also has the recent data and can take over in case of failure.</p>
<p>Extricate from the first ADS YAML file:</p>
<p>-in <code>serverName</code> we specify the name of the server instance
-in <code>servers</code> arg we specify regular ADS server address with its port.</p>
<pre><code>args:
....
  &quot;-serverName&quot;, &quot;ads&quot;
  &quot;-servers&quot;, &quot;{ { ads , ads-test:9000 }, { ads2 , ads-test2:9000}&quot;]
ports:
  - containerPort: 9000
..................
    kind: Service
    metadata:
      name: ads-test
    spec:
      type: ClusterIP
      ports:
      - protocol: TCP
        port: 9000
      selector:
        app: ads-test
</code></pre>
<p>So in the list of arguments we specify the Service through which we should access that ADS instance using the TCP connection (not HTTP connection) with <strong>ads-test:9000</strong>. Since this is containerized app I did not know what else I could specify as server address except of &quot;ServiceName:port&quot;, because development of this app did not suppose containerized app.</p>
<p>So the second one YAML should be different only with <code>serverName</code> info.
And I added additional Service <code>ads-test2</code></p>
<pre><code>args:
....
  &quot;-serverName&quot;, &quot;ads2&quot;
  &quot;-servers&quot;, &quot;{ { ads , ads-test:9000 }, { ads2 , ads-test2:9000}&quot;]
ports:
  - containerPort: 9000
..................
    kind: Service
    metadata:
      name: ads-test2
    spec:
      type: ClusterIP
      ports:
      - protocol: TCP
        port: 9000
      selector:
        app: ads-test2
</code></pre>
<p>Since this is actually the same App, but only with one argument different in its configuration (<code>serverName</code>) I was wondering if there is some way how I could simplify this and use single Service in order to access both ADS servers but to have this configuration within the <code>server</code> argument which actually activates this kind of <code>companion</code> mode which is needed for performance reasons for usage of different servers but to have information up to date on both servers.</p>
<p>Thank you</p>

<p>No you can not have single service for two logically different pods . Service normally does load balancing between replica pods. So user request on your pods will be automatically route to any of the pod by the service automatically.So in your case you don't want this to happen. Request for ads can lie to ads2 server pod.
recommended way is to have two different services for your pods or you can have multiple containers inside single pod and have single service in that case.
and argument for server name can be taken from environment.
Env:
key:
value:</p>
