I have set up a Docker Swarm with the whoami
service that is replicated 20 times. From the gateway container when I do wget -qO - whoami
or the wget -qO - 10.0.x.x
IP address I get random whoami replicas. However, when I do a similar thing on Spring Cloud Gateway it keeps on hitting the same replica.
Is there something in Spring Cloud Gateway or Load Balancer that keeps the connection stuck to the same node?
Also is it possible to disable that so I can test round robin
BOM is set('springCloudVersion', "2021.0.1")
Relevant blocks of application.yml. No discovery just a simple route.
spring:
cloud:
gateway:
routes:
- id: after_route
uri: http://whoami2
predicates:
- Path=/who
Yields the following output
spring-docker rework [!⇡] via ☕ v17.32
❯ curl http://localhost:28080/who
Hostname: cef30a15e0e8
IP: 127.0.0.1
IP: 10.0.3.233
IP: 172.18.0.6
RemoteAddr: 10.0.3.22:54676
GET /who HTTP/1.1
Host: whoami2
User-Agent: curl/7.79.1
Accept: */*
Forwarded: proto=http;host="localhost:28080";for="10.0.0.2:36624"
X-B3-Parentspanid: 264246902b820058
X-B3-Sampled: 1
X-B3-Spanid: 2727f63f28f4f775
X-B3-Traceid: 264246902b820058
X-Forwarded-For: 10.0.0.2
X-Forwarded-Host: localhost:28080
X-Forwarded-Port: 28080
X-Forwarded-Proto: http
spring-docker rework [!⇡] via ☕ v17.32
❯ curl http://localhost:28080/who
Hostname: cef30a15e0e8
IP: 127.0.0.1
IP: 10.0.3.233
IP: 172.18.0.6
RemoteAddr: 10.0.3.22:54676
GET /who HTTP/1.1
Host: whoami2
User-Agent: curl/7.79.1
Accept: */*
Forwarded: proto=http;host="localhost:28080";for="10.0.0.2:36626"
X-B3-Parentspanid: 37f7bcc012a2f20e
X-B3-Sampled: 1
X-B3-Spanid: 9a39133b80384588
X-B3-Traceid: 37f7bcc012a2f20e
X-Forwarded-For: 10.0.0.2
X-Forwarded-Host: localhost:28080
X-Forwarded-Port: 28080
X-Forwarded-Proto: http
Older with the discovery
spring:
cache:
type: redis
cloud:
gateway:
# fail-on-route-definition-error: false
routes: []
discovery:
locator:
enabled: true
url-expression: "uri"
predicates:
- name: Path
args:
patterns: "metadata['path']"
filters:
- RemoveRequestHeader='Cookie'
- RemoveRequestHeader='X-B3-TraceId'
- name: Retry
args:
retries: 3
methods:
- GET
- name: RewritePath
args:
regexp: "metadata['path.regexp']"
replacement: "metadata['path.replacement']"
# inetutils:
# ignoredInterfaces:
# - docker0
# - veth.*
# - eth3
# loadbalancer:
## enabled: false
# ribbon:
# enabled: false
# cache:
# enabled: false