-
Notifications
You must be signed in to change notification settings - Fork 43
Tarantool config storage #4056
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Tarantool config storage #4056
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# Centralized configuration storages | ||
|
||
Sample applications demonstrating how to store configuration data in one place using Tarantool or etcd-based storage. Learn more at [Centralized configuration storages](https://www.tarantool.io/en/doc/latest/concepts/configuration/configuration_etcd/). |
11 changes: 11 additions & 0 deletions
11
doc/code_snippets/snippets/centralized_config/etcd_config_storage.sh
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
#!/usr/bin/env bash | ||
|
||
# 1. Remove the 'default.etcd' directory to reset etcd to initial state. | ||
# 2. Start etcd by executing the 'etcd' command. | ||
# 3. Execute this script to enable authentication. | ||
etcdctl user add root:topsecret | ||
etcdctl role add myapp_config_manager | ||
etcdctl role grant-permission myapp_config_manager --prefix=true readwrite /myapp/ | ||
etcdctl user add sampleuser:123456 | ||
etcdctl user grant-role sampleuser myapp_config_manager | ||
etcdctl auth enable |
13 changes: 13 additions & 0 deletions
13
...de_snippets/snippets/centralized_config/instances.enabled/config_etcd/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# etcd configuration storage | ||
|
||
A sample application demonstrating how to obtain a cluster's configuration from the etcd-based configuration storage. | ||
|
||
## Running | ||
|
||
Before running this sample, start etcd and enable authentication by executing [etcd_config_storage.sh](../../etcd_config_storage.sh). | ||
|
||
To start all instances, execute the following command in the [centralized_config](../../../centralized_config) directory: | ||
|
||
```console | ||
$ tt start config_etcd | ||
``` |
10 changes: 10 additions & 0 deletions
10
doc/code_snippets/snippets/centralized_config/instances.enabled/config_etcd/config.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
config: | ||
etcd: | ||
endpoints: | ||
- http://localhost:2379 | ||
prefix: /myapp | ||
username: sampleuser | ||
password: '123456' | ||
http: | ||
request: | ||
timeout: 3 |
File renamed without changes.
13 changes: 13 additions & 0 deletions
13
...snippets/snippets/centralized_config/instances.enabled/config_storage/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
# Tarantool configuration storage | ||
|
||
A sample application demonstrating how to obtain a cluster's configuration from the Tarantool-based configuration storage. | ||
|
||
## Running | ||
|
||
Before running this sample, start a Tarantool-based configuration storage: [tarantool_config_storage](../tarantool_config_storage). | ||
|
||
To start all instances, execute the following command in the [centralized_config](../../../centralized_config) directory: | ||
|
||
```console | ||
$ tt start config_storage | ||
``` |
19 changes: 19 additions & 0 deletions
19
doc/code_snippets/snippets/centralized_config/instances.enabled/config_storage/config.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
config: | ||
storage: | ||
endpoints: | ||
- uri: '127.0.0.1:4401' | ||
login: sampleuser | ||
password: '123456' | ||
- uri: '127.0.0.1:4402' | ||
login: sampleuser | ||
password: '123456' | ||
- uri: '127.0.0.1:4403' | ||
login: sampleuser | ||
password: '123456' | ||
prefix: /myapp | ||
timeout: 3 | ||
reconnect_after: 5 | ||
|
||
# Watch key changes | ||
app: | ||
file: 'myapp.lua' |
File renamed without changes.
6 changes: 6 additions & 0 deletions
6
doc/code_snippets/snippets/centralized_config/instances.enabled/config_storage/myapp.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
net_box = require('net.box') | ||
local conn = net_box.connect('127.0.0.1:4401') | ||
local log = require('log') | ||
conn:watch('config.storage:/myapp/config/all', function(key, value) | ||
log.info("Configuration stored by the '/myapp/config/all' key is changed") | ||
end) |
11 changes: 11 additions & 0 deletions
11
...nippets/centralized_config/instances.enabled/tarantool_config_storage/README.md
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
# Setting up Tarantool configuration storage | ||
|
||
A sample application demonstrating how to set up Tarantool configuration storage. | ||
|
||
## Running | ||
|
||
To start all instances of the configuration storage, execute the following command in the [centralized_config](../../../centralized_config) directory: | ||
|
||
```console | ||
$ tt start tarantool_config_storage | ||
``` |
49 changes: 49 additions & 0 deletions
49
...ippets/snippets/centralized_config/instances.enabled/tarantool_config_storage/config.yaml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
credentials: | ||
users: | ||
sampleuser: | ||
password: '123456' | ||
privileges: | ||
- permissions: [ read, write ] | ||
spaces: [ config_storage, config_storage_meta ] | ||
- permissions: [ execute ] | ||
universe: true | ||
replicator: | ||
password: 'topsecret' | ||
roles: [ replication ] | ||
|
||
iproto: | ||
advertise: | ||
peer: | ||
login: replicator | ||
|
||
replication: | ||
failover: election | ||
|
||
database: | ||
use_mvcc_engine: true | ||
|
||
groups: | ||
group001: | ||
replicasets: | ||
replicaset001: | ||
roles: [ config.storage ] | ||
roles_cfg: | ||
config.storage: | ||
status_check_interval: 3 | ||
instances: | ||
instance001: | ||
iproto: | ||
listen: | ||
- uri: '127.0.0.1:4401' | ||
instance002: | ||
iproto: | ||
listen: | ||
- uri: '127.0.0.1:4402' | ||
instance003: | ||
iproto: | ||
listen: | ||
- uri: '127.0.0.1:4403' | ||
|
||
# Interact with config storage | ||
app: | ||
file: 'myapp.lua' |
3 changes: 3 additions & 0 deletions
3
...pets/snippets/centralized_config/instances.enabled/tarantool_config_storage/instances.yml
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
instance001: | ||
instance002: | ||
instance003: |
37 changes: 37 additions & 0 deletions
37
...snippets/snippets/centralized_config/instances.enabled/tarantool_config_storage/myapp.lua
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
function put_config() | ||
local fio = require('fio') | ||
local cluster_config_handle = fio.open('../../source.yaml') | ||
local cluster_config = cluster_config_handle:read() | ||
local response = config.storage.put('/myapp/config/all', cluster_config) | ||
cluster_config_handle:close() | ||
return response | ||
end | ||
|
||
function get_config_by_path() | ||
local response = config.storage.get('/myapp/config/all') | ||
return response | ||
end | ||
|
||
function get_config_by_prefix() | ||
local response = config.storage.get('/myapp/') | ||
return response | ||
end | ||
|
||
function make_txn_request() | ||
local response = config.storage.txn({ | ||
predicates = { { 'value', '==', 'v0', '/myapp/config/all' } }, | ||
on_success = { { 'put', '/myapp/config/all', 'v1' } }, | ||
on_failure = { { 'get', '/myapp/config/all' } } | ||
}) | ||
return response | ||
end | ||
|
||
function delete_config() | ||
local response = config.storage.delete('/myapp/config/all') | ||
return response | ||
end | ||
|
||
function delete_all_configs() | ||
local response = config.storage.delete('/') | ||
return response | ||
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
# A sample cluster config used to demonstrate a centralized configuration storage. | ||
# Learn more: https://www.tarantool.io/en/doc/latest/concepts/configuration/configuration_etcd. | ||
credentials: | ||
users: | ||
replicator: | ||
password: 'topsecret' | ||
roles: [replication] | ||
|
||
iproto: | ||
advertise: | ||
peer: | ||
login: replicator | ||
|
||
replication: | ||
failover: manual | ||
|
||
groups: | ||
group001: | ||
replicasets: | ||
replicaset001: | ||
leader: instance001 | ||
instances: | ||
instance001: | ||
iproto: | ||
listen: | ||
- uri: '127.0.0.1:3301' | ||
instance002: | ||
iproto: | ||
listen: | ||
- uri: '127.0.0.1:3302' | ||
instance003: | ||
iproto: | ||
listen: | ||
- uri: '127.0.0.1:3303' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
modules: | ||
# Directory where the external modules are stored. | ||
directory: modules | ||
|
||
env: | ||
# Restart instance on failure. | ||
restart_on_failure: false | ||
|
||
# Directory that stores binary files. | ||
bin_dir: bin | ||
|
||
# Directory that stores Tarantool header files. | ||
inc_dir: include | ||
|
||
# Path to directory that stores all applications. | ||
# The directory can also contain symbolic links to applications. | ||
instances_enabled: instances.enabled | ||
|
||
# Tarantoolctl artifacts layout compatibility: if set to true tt will not create application | ||
# sub-directories for control socket, pid files, log files, etc.. Data files (wal, vinyl, | ||
# snap) and multi-instance applications are not affected by this option. | ||
tarantoolctl_layout: false | ||
|
||
app: | ||
# Directory that stores various instance runtime | ||
# artifacts like console socket, PID file, etc. | ||
run_dir: var/run | ||
|
||
# Directory that stores log files. | ||
log_dir: var/log | ||
|
||
# Directory where write-ahead log (.xlog) files are stored. | ||
wal_dir: var/lib | ||
|
||
# Directory where memtx stores snapshot (.snap) files. | ||
memtx_dir: var/lib | ||
|
||
# Directory where vinyl files or subdirectories will be stored. | ||
vinyl_dir: var/lib | ||
|
||
# Path to file with credentials for downloading Tarantool Enterprise Edition. | ||
# credential_path: /path/to/file | ||
ee: | ||
credential_path: | ||
|
||
templates: | ||
# The path to templates search directory. | ||
- path: templates | ||
|
||
repo: | ||
# Directory where local rocks files could be found. | ||
rocks: | ||
# Directory that stores installation files. | ||
distfiles: distfiles |
5 changes: 0 additions & 5 deletions
5
doc/code_snippets/snippets/config/instances.enabled/etcd/config.yaml
This file was deleted.
Oops, something went wrong.
12 changes: 0 additions & 12 deletions
12
doc/code_snippets/snippets/config/instances.enabled/etcd_full/config.yaml
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nit: there can also be other connection parameters, maybe say it in a more general wording?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This sample shows this minimum configuration and works more like a demo version of a centralized storage.