spring-cloud-kubernetes icon indicating copy to clipboard operation
spring-cloud-kubernetes copied to clipboard

Configuration Watcher and Service Names

Open sdaskam1 opened this issue 3 years ago • 10 comments

For the Configuration Watcher to be able to make a refresh call to the application actuator, it looks like the Kubernetes service name has to match the spring boot app name (and config map name) or it won't be able to locate it to make the call. Currently, our services have a naming convention that is [app-name]-svc which is causing the Configuration Watcher to skip the update because it can't find a service with the correct name. Is there another way to tell the Configuration Watcher which service to look for without having to make the names match? We are just wondering if we are going to have to change the names of all our existing services to remove the -svc suffix.

sdaskam1 avatar Jan 11 '22 19:01 sdaskam1

No they must match at the moment but this is a reasonable enhancement

ryanjbaxter avatar Jan 11 '22 21:01 ryanjbaxter

ok, thanks for the verification Ryan!

sdaskam1 avatar Jan 11 '22 22:01 sdaskam1

Hey @ryanjbaxter, the newer Spring boot version over 2.3.12 does not provide /actuator/refresh endpoint. Are you aware of it or do I miss some point?

mbaykara avatar Jan 20 '22 16:01 mbaykara

That endpoint has existed and continues to exist for a long while now, you might need to enable it and expose it

ryanjbaxter avatar Jan 20 '22 16:01 ryanjbaxter

I did as follow but still getting 404. Is it wrong? @ryanjbaxter application.yml

management:
    endpoints:
        web:
            exposure:
                include: '*'
    endpoint:
      restart:
        enabled: true
      refresh:
        enabled: true

here is the full with the version below =>2.3.12 it expose 18 endpoints and with newer version only 13 EP

mbaykara avatar Jan 20 '22 16:01 mbaykara

When I go to http://localhost:8080/actuator I see the refresh endpoint using your example

{
"_links": {
"self": {
"href": "http://localhost:8080/actuator",
"templated": false
},
"refresh": {
"href": "http://localhost:8080/actuator/refresh",
"templated": false
}
}
}

ryanjbaxter avatar Jan 21 '22 02:01 ryanjbaxter

@ryanjbaxter The reason why they are now available is that after I added the following deps this and this . AFAIU without any cloud dependency, it is not possible to get /refresh entpoint. With following pom you cannot set the /refresh ep.

mbaykara avatar Jan 21 '22 10:01 mbaykara

That's why we suggest you use the Spring Cloud Bom and let it manage the dependencies for you. The refresh endpoint is part of Spring Cloud Commons not Sprint Cloud Kubernetes https://docs.spring.io/spring-cloud-commons/docs/current/reference/html/#endpoints

ryanjbaxter avatar Jan 21 '22 10:01 ryanjbaxter

Hey @ryanjbaxter, I see that this has been added to 2021.0.1 and 2022.0.0-M2. Just wanted to see if you guys had a ballpark estimate on when this might be implemented? Thanks!

sdaskam1 avatar Feb 07 '22 17:02 sdaskam1

Not sure. Any help would be appreciated though, the team is very busy.

ryanjbaxter avatar Feb 07 '22 21:02 ryanjbaxter

@sdaskam1 @ryanjbaxter but we already have such support via : https://docs.spring.io/spring-cloud-kubernetes/docs/current/reference/html/#monitoring-configmaps-and-secrets, specifically:

spring.cloud.kubernetes.configmap.apps

shouldn't this issue be closed?

wind57 avatar Mar 23 '23 19:03 wind57

But I am not sure the config map watcher will take that into account. I think it was added after I implemented the config map watcher

ryanjbaxter avatar Mar 23 '23 20:03 ryanjbaxter

I think it was added after I implemented the config map watcher

That is correct.

But I am not sure the config map watcher will take that into account

We have an integration test that enforces this actually: https://github.com/spring-cloud/spring-cloud-kubernetes/tree/main/spring-cloud-kubernetes-integration-tests/spring-cloud-kubernetes-client-configmap-event-reload-multiple-apps

wind57 avatar Mar 24 '23 05:03 wind57

Ah OK, then yes I think we can close this.

ryanjbaxter avatar Mar 24 '23 12:03 ryanjbaxter