Config Server is a Cross-Platform key/value store which dynamically converts yaml files into rest services.
- Config server fetchs yaml files from git repo (or any remote)
- Hierarchically saves all keys in all yaml files to the state file. In case of restart or crash, first task of config server is reloading this file to cache.
- Hierarchically caches each key and it's value. You should take care of cached objects because currently there is no capacity limitation or caching policy like LRU,MRU,etc.
- Creates routes for each cached keys and each routes return cached values.
- If a new yaml file or key is added it will be remarked by config server and .
- If a yaml file or key is deleted, related routes will be deleted from cache and state file. Deleted routes will start to get http 404.
Actually it is up to you. schedules/get-repo.ps1
file is responsible from getting yamls from remote and by default, config server assumes that yaml files are kept in a git repository.
But it is possible to add custom logic to get/sync yaml files or completely disabling and working on existing local yaml files by changing schedules/get-repo.ps1
.
Assume that you have 2 yaml files test1.yaml
and test2.yaml
;
- test1.yaml
nested:
array:
- this
- is
- an
myKey: world1
- test2.yaml
myKey2: myValue2
Config server will convert all keys in all yaml files to the following endpoints:
- /test1/nested/array
- /test1/myKey
- /test2/myKey2
There is no prerequisites for
cnsn/config-server
base image, all requirements are already installed inside docker image.
If you want to run config-server out of container, first thing you need is Powershell Core (PS > 6.0). Also
git
should be installed and finally config-server should be able to reach repos defined in Powershell Gallery. When you startconfig-server.ps1
for the first time, following modules will be installed from Powershell Gallery if they are not installed already:
- Powershell-Yaml (Powershell Module)
- Pode (Powershell Module)
- PSCache (Powershell Module)
If you want to install them manually, you can use following commands:
Install-Module -Name "powershell-yaml" -RequiredVersion 0.4.1 -Force -Scope CurrentUser
Install-Module -Name "pode" -RequiredVersion 1.6.1 -Force -Scope CurrentUser
Install-Module -Name "pscache" -RequiredVersion 0.1.0 -Force -Scope CurrentUser
Config server will use environment variables during server startup to configure itself. They are:
repo
: Remote git repo address that config server will clone and pull periodically. Default: https://github.com/haidouks/configsPodePort
: Port that will config server will be listening. Default: 8085ThreadCount
: Dedicated thread count for all routes. Default: 5VerbosePreference
: Enable verbose logging. Default: SilentlyContinueenableAuthentation
: Enable authentication. Default: FalseauthenticatedRoutes
: List of routes that will be authenticated. Default: NulldefaultAuthToken
: Bearer token for default authencation type. Default:QweAsdZxc123
Example 1: Quick start
docker run -d -p 8085:8085 cnsn/config-server:latest
Now browse http://localhost:8085/test/myKey
:
test
is the name of yaml file in default source repository:https://github.com/haidouks/configs
myKey
is a key in test.yaml
Response should see something like {"value":"world1"}
which is the value of key myKey
Example 2: Configure variables
docker run -d -p 8085:8085 \
-e VerbosePreference=Continue \
-e ThreadCount=10 \
-e repo=https://github.com/haidouks/configs \
cnsn/config-server
Example 3: Authenticate some routes
docker run -d -p 8085:8085 \
-e repo=https://github.com/haidouks/configs \
-e enableAuthentation=true \
-e authenticatedRoutes=test/*:DefaultAuth \
-e defaultAuthToken=Qweasd123 \
cnsn/config-server
- Just in time synchronizer -> DONE
- Configure cache capacity and policy