Я хочу самостоятельно обнаружить сервер eureka. Текущая конфигурация работает на локальном env и использует docker -композицию, но когда на kubernetes запускается то же самое изображение docker, я получаю:
> 2020-04-15 17:29:33.929 INFO 1 --- [a-EvictionTimer]
> c.n.e.registry.AbstractInstanceRegistry : Running the evict task with
> compensationTime 0ms 2020-04-15 17:29:34.205 ERROR 1 ---
> [nfoReplicator-0] c.n.d.s.t.d.RedirectingEurekaHttpClient : Request
> execution error. endpoint=DefaultEndpoint{
> serviceUrl='http://account_eureka:M8egvEsFfBg7W5Qt83a2isqT@server-discovery:8761/eureka/}
> com.sun.jersey.api.client.ClientHandlerException:
> org.apache.http.conn.ConnectTimeoutException: Connect to
> server-discovery:8761 timed out at
> com.sun.jersey.client.apache4.ApacheHttpClient4Handler.handle(ApacheHttpClient4Handler.java:187)
> ~[jersey-apache-client4-1.19.1.jar!/:1.19.1] at
> com.sun.jersey.api.client.filter.GZIPContentEncodingFilter.handle(GZIPContentEncodingFilter.java:123)
> ~[jersey-client-1.19.1.jar!/:1.19.1] at
> com.netflix.discovery.EurekaIdentityHeaderFilter.handle(EurekaIdentityHeaderFilter.java:27)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.sun.jersey.api.client.Client.handle(Client.java:652)
> ~[jersey-client-1.19.1.jar!/:1.19.1] at
> com.sun.jersey.api.client.WebResource.handle(WebResource.java:682)
> ~[jersey-client-1.19.1.jar!/:1.19.1] at
> com.sun.jersey.api.client.WebResource.access$200(WebResource.java:74)
> ~[jersey-client-1.19.1.jar!/:1.19.1] at
> com.sun.jersey.api.client.WebResource$Builder.post(WebResource.java:570)
> ~[jersey-client-1.19.1.jar!/:1.19.1] at
> com.netflix.discovery.shared.transport.jersey.AbstractJerseyEurekaHttpClient.register(AbstractJerseyEurekaHttpClient.java:57)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.netflix.discovery.shared.transport.decorator.MetricsCollectingEurekaHttpClient.execute(MetricsCollectingEurekaHttpClient.java:73)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.executeOnNewServer(RedirectingEurekaHttpClient.java:118)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.netflix.discovery.shared.transport.decorator.RedirectingEurekaHttpClient.execute(RedirectingEurekaHttpClient.java:79)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.netflix.discovery.shared.transport.decorator.RetryableEurekaHttpClient.execute(RetryableEurekaHttpClient.java:120)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator$1.execute(EurekaHttpClientDecorator.java:59)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.netflix.discovery.shared.transport.decorator.SessionedEurekaHttpClient.execute(SessionedEurekaHttpClient.java:77)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.netflix.discovery.shared.transport.decorator.EurekaHttpClientDecorator.register(EurekaHttpClientDecorator.java:56)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.netflix.discovery.DiscoveryClient.register(DiscoveryClient.java:850)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> com.netflix.discovery.InstanceInfoReplicator.run(InstanceInfoReplicator.java:121)
> ~[eureka-client-1.9.17.jar!/:1.9.17] at
> java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:515)
> ~[na:na] at
> java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
> ~[na:na] at
> java.base/java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:304)
> ~[na:na] at
> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
> ~[na:na] at
> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
> ~[na:na] at java.base/java.lang.Thread.run(Thread.java:830) ~[na:na]
2020-04-15 17:29:34.205 WARN 1 --- [nfoReplicator-0] c.n.d.s.t.d.RetryableEurekaHttpClient : Request execution failed with message: org.apache.http.conn.ConnectTimeoutException: Connect to server-discovery:8761 timed out
2020-04-15 17:29:34.205 WARN 1 --- [nfoReplicator-0] com.netflix.discovery.DiscoveryClient : DiscoveryClient_EUREKA/server-discovery-56dbdc4879-crwbr:eureka:8761 - registration failed Cannot execute request on any known server
com.netflix.discovery.shared.transport.TransportException: Cannot execute request on any known server
Другие службы регистрируются правильно.
Часть docker -композит:
server-discovery:
image: szastarek/food-delivery-server-discovery:${TAG}
container_name: server-discovery
environment:
- EUREKA_URL=http://account_eureka:password@server-discovery:8761/eureka/
- CONFIG_URI=http://config-server:8888
- ACTUATOR_PASSWORD=iN09KtaW59dqeRylgZFV4aSZ
- DASHBOARD_PASSWORD=password
- EUREKA_PASSWORD=password
- ENV=dev
ports:
- 8761:8761
depends_on:
- config-server
networks:
food-delivery-net:
aliases:
- "server-discovery"
И развертывание kubernetes:
apiVersion: apps/v1
kind: Deployment
metadata:
labels:
io.kompose.service: server-discovery
name: server-discovery
spec:
replicas: 1
selector:
matchLabels:
io.kompose.service: server-discovery
strategy: {}
template:
metadata:
annotations:
vault.security.banzaicloud.io/vault-addr: "https://vault:8200"
vault.security.banzaicloud.io/vault-tls-secret: "vault-tls"
labels:
io.kompose.service: server-discovery
spec:
containers:
- env:
- name: CONFIG_URI
value: http://config-server:8888
- name: ACTUATOR_PASSWORD
value: "vault:secret/data/actuator#ACTUATOR_PASSWORD"
- name: EUREKA_URL
value: "vault:secret/data/server-discovery#EUREKA_URL"
- name: DASHBOARD_PASSWORD
value: "vault:secret/data/server-discovery#DASHBOARD_PASSWORD"
- name: EUREKA_PASSWORD
value: "vault:secret/data/server-discovery#EUREKA_PASSWORD"
- name: ENV
value: dev
image: 'szastarek/food-delivery-server-discovery:0.0.1-SNAPSHOT'
imagePullPolicy: Always
name: server-discovery
ports:
- containerPort: 8761
resources: {}
restartPolicy: Always
serviceAccountName: ""
И в свойствах eureka у меня есть eureka.client.service-url.defaultZone = EUREKA_URL