Spring 无法连接kubernetes中一个吊舱内的容器

Spring 无法连接kubernetes中一个吊舱内的容器,spring,kubernetes,containers,spring-cloud,spring-cloud-config,Spring,Kubernetes,Containers,Spring Cloud,Spring Cloud Config,这是我客户的bootstrap.yml spring: cloud: config: enabled: true uri: http://localhost:8888 label: master spring.application: name: microservices-client spring.profiles: active: dev 这是我的spring配置服务器bootstrap.yml spring: ap

这是我客户的bootstrap.yml

spring:
  cloud:
    config:
      enabled: true
      uri: http://localhost:8888
      label: master

spring.application:
    name: microservices-client

spring.profiles:
    active: dev
这是我的spring配置服务器bootstrap.yml

spring:
  application:
    name: microservices-client

  profiles:
    active: dev

  cloud:
    config:
      uri: http://localhost:8888
这是我的spring config application.yml

server:
  port: 8888

spring:
  cloud:
    config:
      server:
        git:
          uri: ssh://git@riscm.company.com/sem/some_repo.git
          ignoreLocalSshSettings: true
          privateKey:        | 
                             -----BEGIN RSA PRIVATE KEY-----
                             MIIJKgIBAAKCAgEA3iOtvDLAez5Azk6fYt2ApS8smK3mGZVt9Uu/mqsZxijx9hEG
                             Q4oPHhebR1sX/AstBZAWvcx7O9fb7CfA1/Zsy3x520FbGAEH+rQtiVfafJ27ZfDm

                             xtiAKzX1bGWVV51WcgCF8A9NcXOqoIF6yXeyGgBmMwHG3vi/Yc0JzqLsqcqLdQ==
                             -----END RSA PRIVATE KEY-----


endpoints:
  health:
    sensitive: true

management:
  security:
    enabled: false
  health:
    solr:
      enabled: false
当spring引导客户端无法连接到kubernetes上的spring云配置时。我从Kubernetes上的日志客户端得到这个错误。但是当我直接登录到客户机容器时,我没有收到这个错误

2018-07-11 19:20:02.455  INFO 1 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://localhost:8888 
2018-07-11 19:20:02.545  INFO 1 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://localhost:8888 . Will be trying the next url if available
2018-07-11 19:20:02.545  WARN 1 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://localhost:8888/microservices-client/dev/master":  Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
2018-07-11 19:20:02.547  INFO 1 --- [           main] com.regen.rest.Application               : The following profiles are active: dev

播客规格:

apiVersion: apps/v1beta1
kind: Deployment
metadata:
  name: my-deploy
spec:
  replicas: 1
  selector:
    matchLabels:
      app:  myapp
  template:
    metadata:
      labels:
        app: myapplbl
    spec:
      containers:
      - name: config-svr
        image: on-amazonaws.com:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 8888
          name: configsvr     
      - name: client-dev
        image: on-amazonawimage:latest
        imagePullPolicy: Always
        ports:
        - containerPort: 8098
          name: server
这是客户的日志。这一次,我使用主机名和我为端口32752上的服务器定义的服务来指向它。但它仍然给我同样的错误

2018-07-12 13:31:36.731  INFO 1 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Fetching config from server at : http://ccvocab-server-service.ccv.svc:32752 
2018-07-12 13:31:36.851  INFO 1 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Connect Timeout Exception on Url - http://ccvocab-server-service.ccv.svc:32752 . Will be trying the next url if available
2018-07-12 13:31:36.851  WARN 1 --- [           main] c.c.c.ConfigServicePropertySourceLocator : Could not locate PropertySource: I/O error on GET request for "http://ccvocab-server-service.ccv.svc:32752/microservices-client/dev/master":  Connection refused (Connection refused); nested exception is java.net.ConnectException: Connection refused (Connection refused)
2018-07-12 13:31:36.853  INFO 1 --- [           main] com.regen.rest.Application               : The following profiles are active: dev
2018-07-12 13:31:36.866  INFO 1 --- [           main] ConfigServletWebServerApplicationContext : Refreshing org.springframework.boot.web.servlet.context.AnnotationConfigServletWebServerApplicationContext@31dc339b: startup date [Thu Jul 12 13:31:36 UTC 2018]; parent: org.springframework.context.annotation.AnnotationConfigApplicationContext@48140564
2018-07-12 13:31:38.240  INFO 1 --- [           main] o.s.b.f.s.DefaultListableBeanFactory     : Overriding bean definition for bean 'httpRequestHandlerAdapter' with a different definition: replacing [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.boot.autoconfigure.web.servlet.WebMvcAutoConfiguration$EnableWebMvcConfiguration; factoryMethodName=httpRequestHandlerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/boot/autoconfigure/web/servlet/WebMvcAutoConfiguration$EnableWebMvcConfiguration.class]] with [Root bean: class [null]; scope=; abstract=false; lazyInit=false; autowireMode=3; dependencyCheck=0; autowireCandidate=true; primary=false; factoryBeanName=org.springframework.data.rest.webmvc.config.RepositoryRestMvcConfiguration; factoryMethodName=httpRequestHandlerAdapter; initMethodName=null; destroyMethodName=(inferred); defined in class path resource [org/springframework/data/rest/webmvc/config/RepositoryRestMvcConfiguration.class]]
2018-07-12 13:31:38.723  INFO 1 --- [           main] o.s.cloud.context.scope.GenericScope     : BeanFactory id=fedabff9-2282-310c-8521-2dcdb31a9300
2018-07-12 13:31:39.110  INFO 1 --- [           main] trationDelegate$BeanPostProcessorChecker : Bean 'org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration' of type [org.springframework.cloud.autoconfigure.ConfigurationPropertiesRebinderAutoConfiguration$$EnhancerBySpringCGLIB$$9b0dbd2c] is not eligible for getting processed by all BeanPostProcessors (for example: not eligible for auto-proxying)
2018-07-12 13:31:39.373  INFO 1 --- [           main] o.s.b.w.embedded.tomcat.TomcatWebServer  : Tomcat initialized with port(s): 8098 (http)
2018-07-12 13:31:39.398  INFO 1 --- [           main] o.apache.catalina.core.StandardService   : Starting service [Tomcat]
2018-07-12 13:31:39.399  INFO 1 --- [           main] org.apache.catalina.core.StandardEngine  : Starting Servlet Engine: Apache Tomcat/8.5.31
2018-07-12 13:31:39.409  INFO 1 --- [ost-startStop-1] o.a.catalina.core.AprLifecycleListener   : The APR based Apache Tomcat Native library which allows optimal performance in production environments was not found on the java.library.path: [/usr/java/packages/lib/amd64:/usr/lib/x86_64-linux-gnu/jni:/lib/x86_64-linux-gnu:/usr/lib/x86_64-linux-gnu:/usr/lib/jni:/lib:/usr/lib]
2018-07-12 13:31:39.506  INFO 1 --- [ost-startStop-1] o.a.c.c.C.[Tomcat].[localhost].[/]       : Initializing Spring embedded WebApplicationContext
2018-07-12 13:31:39.506  INFO 1 --- [ost-startStop-1] o.s.web.context.ContextLoader            : Root WebApplicationContext: initialization completed in 2640 ms
2018-07-12 13:31:40.247  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.ServletRegistrationBean  : Servlet dispatcherServlet mapped to [/]
2018-07-12 13:31:40.250  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'characterEncodingFilter' to: [/*]
2018-07-12 13:31:40.251  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'hiddenHttpMethodFilter' to: [/*]
2018-07-12 13:31:40.251  INFO 1 --- [ost-startStop-1] o.s.b.w.servlet.FilterRegistrationBean   : Mapping filter: 'httpPutFormContentFilter' to: [/*]

我通过将配置服务部署到另一个pod解决了这个问题。客户端无法在同一pod内连接(通过引导)的原因是服务器未准备就绪。

为什么
http://localhost:8888
work?两者都部署在同一个pod中,因此可以通过localhost进行通信。如果没有
PodSpec
描述符和更多Spring日志输出,我们将无法帮助您,特别是显示端口绑定文本(即:当jetty或tomcat在引导过程中实际开始侦听时),您为什么要这样做?可能重复