0
votes

I have a Client which listens to config server. Config Server is pointing to github. Things work fine with localhost. However when i deploy the application to Kubernetes the Client endpoint to refresh the properties doesn't work properly.

Endpoint (Post) : http://config-client.sbx.com/actuator/refresh

This returns an empty response on Postman "[]" and Response code is 200 OK. I am able to see that the Config server is up and running on K8s.

Any suggestion on what could be wrong?

P.S. I have enabled DEBUG logs but do not see much information there.

1
Can the kubernetes node hit GitHub? - spencergibb
Yes i am able to fetch the properties from Github on the config server. Somehow not able to access it from the client which is running on a different pod. Both the pods however are running on 8080 and i have added the property in bootstrap.yml on Client to have the actuator listening w/o SSL. - Tarun Pande

1 Answers

0
votes

Can you verify if the application link has got the hostname and the application name when doing the refresh. Because while doing a refresh in the localhost, it will just be springboot application locally, so there wont be any need for an additional path of application-name. Wherehas when you deploy to a server normally we have to give the path name of the application in addition to the hostname. In tomcat, the URL I use is as below,

http://<hostname>/**<application-name>**/actuator/refresh/

Normally when you hit this URL via postman, it will give you a 200 response with an empty body of []. And then, you should be able to see the below lines in the log files of the client application. [ Also I had the attribute @RefreshScope attribute at the main method of the application just below the @SpringBootApplication attribute to refresh the attributes of the application.]

INFO   o.s.c.c.c.ConfigServicePropertySourceLocator.getRemoteEnvironment:249 - Fetching config from server at : http://<hostname>/<Config-server-application-name>/
INFO   o.s.c.c.c.ConfigServicePropertySourceLocator.log:168 - Located environment: name=config-client, profiles=[development], label=null, version=ab36989c85922f1c9cf7803fac4, state=null
INFO   o.s.c.b.c.PropertySourceBootstrapConfiguration.initialize:112 - Located property source: [BootstrapPropertySource {name='bootstrapProperties-configClient'}, BootstrapPropertySource {name='bootstrapProperties-https://<gitlaburl>/<companyname>/config-server.git/config-client-development.yml'}]
INFO   o.s.boot.SpringApplication.logStartupProfileInfo:655 - The following profiles are active: development
INFO   o.s.boot.SpringApplication.logStarted:61 - Started application in 1.557 seconds (JVM running for 70689.032)

For Kubernetes,

Try using

kubectl apply

(instead of kubectl create configmap.)

To deploy the config map, just run the following command on Kubernetes:

kubectl apply -f config-map.yml

Make sure the name of the config map matches the name of the spring boot application .Also see the below link ,

https://github.com/spring-cloud/spring-cloud-kubernetes/issues/255

Also there is a spring cloud kuberenetes which you can explore as below,

https://cloud.spring.io/spring-cloud-static/spring-cloud-kubernetes/2.0.0.M1/reference/html/#why-do-you-need-spring-cloud-kubernetes