Can not fetch values from remote spring config from spring boot client in Kubernetes

7/10/2018

Here's my bootstrap.yml of my client

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

spring.application:
    name: microservices-client

spring.profiles:
    active: dev

Here's my spring config server bootstrap.yml

spring:
  application:
    name: microservices-client

  profiles:
    active: dev

  cloud:
    config:
      uri: http://localhost:8888

And here's my 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

When I run the config server locally I can pull values from spring boot client, but not when the server runs remotely as a docker image on Kubernetes.

I found one problem in client bootstrap.yml the label should be master and not Master! I went ahead and deployed the microservices to Kubernetes and now I'm getting this error from the log client on Kubernetes. I'm not getting this error when I login directly into the client container.

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

.

-- aQ123
kubernetes
spring-boot
spring-cloud
spring-cloud-config

1 Answer

8/6/2018

Please add bellow configuration to bootstrap.xml. I can fixed this issue by putting below configuration.

> spring:   cloud:
>     enabled: true
>     config:
>       uri: http://config-server:8888
>       failFast: true
>       retry:
>         maxAttempts: 20
-- WGSSAMINTHA
Source: StackOverflow