<p>I have one single node. On this node, I have 2 applications with multi instance (3 pods each)</p>
<p>App A want contact App B.</p>
<p>My issue is : App A contact all the time the same pod of App B.
I would like alternate pod (load balancing in round robin for example)
For example :
first request: AppPod3 respond
second request: AppPod1 respond
third request: AppPod2 respond</p>
<p>How i can do that ?</p>
<p>Thank you so much for your help ...
You can see below my conf of app B
I have tried to set timeoutSeconds for sessionaffinity but it's not working ...</p>
<pre><code>kind: Deployment
metadata:
  name: AppB
spec:
  selector:
    matchLabels:
      app: AppB
  replicas: 3
  template:
    metadata:
      labels:
        app: AppB
    spec:
      containers:
      - name: AppB-container
        image: image
        ports:
        - containerPort: 80
---
apiVersion: v1
kind: Service
metadata:
  name: AppB
  labels:
    app: svc-AppB
spec:
  ports:
  - port: 80
    protocol: TCP
    targetPort: 80
  selector:
    app: AppB
  sessionAffinity: ClientIP
  sessionAffinityConfig:
    clientIP:
      timeoutSeconds: 1```
</code></pre>

user3683760
<p>The service should use backend pods in round robin fashion by default. You don't need sessionAffinity settings if the pods are stateless; otherwise you will be redirected to the same pod based on the source ID.</p>
<p>Maybe you can add logging to the pods and observe when they are accessed. Subsequent calls to the service should be redirected to pods in round robin fashion with minimal service configuration.</p>
<p><strong>Update:</strong> this is the deployment I am using. It balances the pods as expected; each curl request sent to the service clusterip:port ends on a different pod. My k8s installation is on premise, v1.18.3.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
  name: baseDeployment
  labels:
    app: baseApp
  namespace: nm-app1
spec:
  replicas: 2
  selector:
    matchLabels:
      app: baseApp
  template:
    metadata:
      labels:
        app: baseApp
    spec:
      containers:
      - name: baseApp
        image: local-registry:5000/baseApp
        ports:
        - containerPort: 8080
---
kind: Service
apiVersion: v1
metadata:
  name: baseService
  namespace: nm-app1
spec:
  selector:
    app: baseApp 
  ports:
  - protocol: TCP
    port: 80
    targetPort: 8080
</code></pre>
