Config server is a golang proof of concept where environment settings are constantly updated. By executing this job the environment configuration should be always up to date without performing a new deployment.
Docker and docker compose.
Config server uses Hashicorp Consul as service discovery and environment key-value pairs provider.
When the server starts it performs a polling job into consul getting services addresses and application service key-value pairs. In case of consul hit failure, it should try to get local environment variable with the same key.
-
Build an image by performing
docker build -t config-server .
-
Inside docker-compose.yaml file you should be able to find commands into
command
key in config-server service. There is some params that may be passed to run the http server:
-n, --app-name string Application name. (default "config-server")
--auto-refresh Refresh key-value pairs from consult integration. (default true)
--auto-refresh-duration int Interval between key-value pairs refreshes in seconds. (default 5)
--consul-port string Port to be used on consul. (default ":8500")
--consul-prefix string Consul key value prefix. (default "config")
--consul-url string Consul URL. (default "consul")
-h, --help help for http
-p, --port string Port to be used on http server. (default ":4040")
-
After filling up with the desired configuration, you may start the local environment by executing
docker-compose up
-
You should be able to see logging config variables by config-server or getting them by performing a cURL to
<local_config_server_address>:<local_config_server_port>
. If you leave the default values, the config-server address should belocalhost:4040
and the consul ui addresslocalhost:8500
. -
Insert some key-value pairs into consul. If you leave the default values, you should:
- Access
localhost:8500
- Click on
Key/Value
nav bar option - Click on
Create
button - Insert
config/config-server/<any_key>
onKey or Folder
input - Insert
<any_value>
intoValue
input - Click on
Save
button
- Access
-
Now you can see the config variable changing dynamically