We have a Zuul proxy (wraped with Spring Cloud/Boot) deployed that fetches configuration from the Spring Config Server. Every time I do changes in the routes I restart Zuul application and I wonder if there is a better approach that can be taken (like refresh of Zuul config information)? :)
Thank you,
You can issue a refresh command via rest:
curl -X POST http://<host>:<port>/refresh
I wrote a simple bash script that commits all my changes to the config file in the Git repository and then issue curl request to all my services.
If you wanted to be fancy you could write a script that first queries your Eureka server to get the list of all services and then refresh them all :)
Zuul Routes could be dynamically refreshed when configuring them in a Git backend for instance, fronted by Spring Cloud Config server and Spring Cloud Bus.
I have covered this scenario in a recent blog post Routing requests and dynamically refreshing routes using Spring Cloud Zuul Server
For #1, Spring cloud config introduced the #RefreshScope annotation which will expose the /refresh endpoint (over HTTP or JMX)
For #2, after '/refresh', spring cloud config will take the latest git commit, For the config changes, essentially there are two ways, 1) pull the changes 2) push the changes, spring cloud bus approach is based on the rabbitmq to push the config changes.
Check out this article
And this also
Many respositories such as github are able to configure Webhook POST endpoints.
Besides the previously mentioned way of manually executing a request to the /refresh endpoint, you could configure your github config repository to use the /request endpoint as the webhook endpoint. That way, you could automatically refresh the properties on push.
Related
I'm using spring cloud config together with spring cloud bus.
I set up a webhook from my git repository (hosted in bitbucket) to notify the config server when a push occurs. In order to reduce throughput and use a minimal caching I set the refresh rate for 2 minutes:
spring.cloud.config.server.git.refresh-rate=120
Now when I push to the repository, the config server is being notified via the webhook and send a message to the clients. The client is asking for the configuration again from the server, but because the refresh rate is set to two minutes, and the notifications chain is faster the configuration server returns the previous configuration.
Is there a way to cancel the refresh rate on a webhook (a request to /monitor)? Maybe other way to overcome this issue?
Goal:
Call actuators refresh endpoint to reload an override specified in spring cloud config server
Background:
Spring cloud config server provides a way to push out default configuration to all clients through the overrides property (https://cloud.spring.io/spring-cloud-config/single/spring-cloud-config.html#_property_overrides)
spring.cloud.config.server.overrides.foo=bar
Spring actuator provides a /refresh endpoint to reload configuration properties while the application is running.
Problem:
When a new override is pushed into spring cloud config server and the refresh point refreshes that property, the override value is not updated.
Therefore, an update like spring.cloud.config.server.overrides.foo=baz shows baz under actuators /env endpoint, but the clients still see foo=bar.
Question:
Is this just a missing feature of spring cloud config server?
I have a Spring-Cloud-Gateway app (V. Finchley.SR1) and need the routing config to be externalized and refreshable. I'm currently able to configure the Gateway to pull config from a Cloud-Config app and refresh the routes by hitting the /actuator/refresh endpoint on the cloud app. However, I'd like to configure the route refresh to be automatic via a schedule rather than requiring a client to POST to /actuator/refresh. How can this be achieved?
I have ACL on for Consul, and have tried many ways to specify the token to use for service discovery. The config ACL token works fine, and the discovery ACL token works for registration (I can see my services in the Consul UI). I see the code for AgentConsulClient.agentServiceRegister() supports the token with this:
UrlParameters tokenParam = token != null ? new SingleUrlParameters("token", token) : null;
Nothing similar is supported in CatalogConsulClient, as far as I can tell. When called from Spring Cloud's ConsulDiscoveryClient, no token is passed, regardless of how it is set. Logs show the call being made without the token, and getting back a valid response with none of the registered services listed. I don't see how to have ACL on for registration but off for discovery. What am I missing? Is nobody actually using ACL if using discovery? (It works fine in the development environment with no ACL). Do I need to edit the source to add the token support from the agent service to the catalog service? Has anybody had success doing that?
BTW, could not tag this with spring-cloud-consul. Add it if you can.
ACL support for Consul catalog services is in consul-api v1.1.11 and will be (I hope) part of spring-cloud-consul 1.0.3.RELEASE. The 1.0.2.RELEASE version still uses consul-api-1.1.10. Update: confirmed to be in Camden.SR3.
Gradle:
'com.ecwid.consul:consul-api:1.1.11',
'org.springframework.cloud:spring-cloud-consul-dependencies:1.0.3.RELEASE'
I have a webapp deployed in aws ec2 instance. I recently got to know about Github Webhook. Now i am trying to setup webhook service for my ec2 server. Can someone pls give a walk-through about:
1. How to receive the webhook payload for server endpoint.
2. What will be the Payload URL that one have to write in github webhook service.
First you need to go to your repo, and click through this sequence:
Settings -> Webhooks & Services -> Add webhook
Then paste the url where github will submit data for each new commit. You can find examples of payload in example.
Then implement the logic needed in the backend to work with info about new commits.