Skip to content

Commit 02ea158

Browse files
committed
3.0 etcd config
1 parent 63c1f8d commit 02ea158

File tree

8 files changed

+378
-63
lines changed

8 files changed

+378
-63
lines changed
+2-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
config:
22
etcd:
3-
prefix: /example
43
endpoints:
5-
- http://localhost:2379
4+
- http://localhost:2379
5+
prefix: /example
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
config:
2+
etcd:
3+
endpoints:
4+
- http://localhost:2379
5+
prefix: /example
6+
username: testuser
7+
password: foobar
8+
ssl:
9+
ca_file: ca.crt
10+
http:
11+
request:
12+
timeout: 3

doc/concepts/configuration/configuration_etcd.rst

+126-61
Original file line numberDiff line numberDiff line change
@@ -6,92 +6,157 @@ Storing configuration in etcd
66
.. admonition:: Enterprise Edition
77
:class: fact
88

9-
Centralized configuration is supported by the `Enterprise Edition <https://www.tarantool.io/compare/>`_ only.
9+
Storing configuration in etcd is supported by the `Enterprise Edition <https://www.tarantool.io/compare/>`_ only.
1010

11-
.. TODO
12-
https://github.com/tarantool/doc/issues/3658
11+
Tarantool enables you to store configuration data in one place using etcd.
12+
To achieve this, you need to define how to access etcd and put a :ref:`YAML configuration <configuration_file>` to an etcd server.
1313

14-
- Install and configure etcd (authentication, TLS)
15-
- Local etcd configuration (mention env vars)
16-
- endpoints
17-
- key prefix
18-
- auth
19-
- TLS
20-
- http (timeout, socket)
21-
- Put a remote config
22-
- etcdctl put
23-
- tt cluster publish
24-
- Show cluster config
25-
- etcdctl get
26-
- tt cluster show
27-
- Start app
28-
- Local config
29-
- Env vars
30-
- Reload config
31-
- auto
32-
- manual (config.reload)
3314

15+
.. _etcd_local_configuration:
3416

35-
Local config (``config.yaml``):
17+
Local etcd configuration
18+
------------------------
3619

37-
.. literalinclude:: /code_snippets/test/config/etcd.yaml
38-
:language: yaml
39-
:dedent:
20+
To store a cluster's configuration in etcd, you need to provide etcd connection settings in a local configuration file.
21+
These settings are used to :ref:`publish <etcd_publishing_configuration>` a cluster's configuration and :ref:`show <etcd_showing_configuration>` it.
4022

41-
Remote config (``remote_config.yaml``):
23+
Connection options for etcd should be specified in the ``config.etcd`` section of the configuration file.
24+
At least, the following options should be specified:
4225

43-
.. literalinclude:: /code_snippets/test/config/replicaset_manual.yaml
44-
:language: yaml
45-
:dedent:
26+
.. literalinclude:: /code_snippets/test/config/etcd.yaml
27+
:language: yaml
28+
:dedent:
4629

47-
Put a remote config:
30+
- :ref:`config.etcd.endpoints <config_etcd_endpoints>` specifies the list of etcd endpoints.
31+
- :ref:`config.etcd.prefix <config_etcd_prefix>` sets a key prefix used to search a configuration. Tarantool searches keys by the following path: ``/prefix/config/*``.
4832

49-
.. code-block:: console
5033

51-
$ etcdctl put /example/config/all.yaml < remote_config.yaml
34+
You can also provide additional etcd connection options:
5235

53-
Put a remote config using ``tt cluster``:
36+
.. literalinclude:: /code_snippets/test/config/etcd_full.yaml
37+
:language: yaml
38+
:dedent:
5439

55-
.. code-block:: console
40+
In this example, the following options are configured in addition to an etcd endpoint and key prefix:
5641

57-
$ tt cluster publish "http://localhost:2379/tt" remote_config.yaml
42+
- :ref:`config.etcd.username <config_etcd_username>` and :ref:`config.etcd.password <config_etcd_password>` specify credentials used for authentication.
43+
- :ref:`config.etcd.ssl.ca_file <config_etcd_ssl_ca_file>` specifies a path to a trusted certificate authorities (CA) file.
44+
- :ref:`config.etcd.http.request.timeout <config_etcd_http_request_timeout>` configures a timeout for connecting to an etcd server.
5845

59-
Searches keys by the following path: ``/prefix/config/*``.
60-
See https://github.com/tarantool/doc/issues/3725
46+
You can find all the available configuration options in the :ref:`etcd <configuration_reference_config_etcd>` section.
6147

62-
Manual:
6348

64-
.. code-block:: yaml
6549

66-
config:
67-
reload: 'manual'
50+
.. _etcd_publishing_configuration:
6851

69-
Reload config (on all instances):
52+
Publishing cluster's configuration to etcd
53+
------------------------------------------
7054

71-
.. code-block:: lua
55+
.. _etcd_publishing_configuration_tt:
7256

73-
require('config'):reload()
57+
Publishing configuration using the tt utility
58+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
7459

75-
Authentication:
60+
The tt utility provides the :ref:`tt cluster <tt-cluster>` command for managing a cluster's configuration.
61+
The ``tt cluster publish`` command can be used to publish a cluster's configuration to etcd.
7662

77-
.. code-block:: console
63+
The example below shows how a :ref:`layout <admin-start_stop_instance-multi-instance-layout>` of the application called ``app`` might look:
7864

79-
$ etcdctl --user root --password foobar role grant-permission tt readwrite /tt/config/all
80-
$ etcdctl --user root --password foobar role grant-permission tt --prefix=true readwrite /tt/
65+
.. code-block:: none
8166
82-
$ etcdctl --user root --password foobar user grant-role testuser tt
67+
instances.enabled
68+
└── app
69+
├── config.yaml
70+
├── cluster.yaml
71+
└── instances.yml
8372
73+
* ``config.yaml`` contains a :ref:`local configuration <etcd_local_configuration>` used to connect to etcd.
74+
* ``cluster.yaml`` contains a cluster's configuration to be published.
75+
* ``instances.yml`` specifies :ref:`instances <admin-start_stop_instance-multi-instance>` to run in the current environment. ``tt cluster publish`` ignores the configured instances.
8476

85-
.. code-block:: yaml
77+
To publish a cluster's configuration (``cluster.yaml``) to an etcd server, execute ``tt cluster publish`` as follows:
8678

87-
config:
88-
etcd:
89-
http:
90-
request:
91-
timeout: 3
92-
prefix: /tt
93-
endpoints:
94-
- http://localhost:2379
95-
username: testuser
96-
password: foobar
79+
.. code-block:: console
9780
81+
$ tt cluster publish "http://localhost:2379/example" instances.enabled/app/cluster.yaml
82+
83+
84+
.. _etcd_publishing_configuration_etcdctl:
85+
86+
Publishing configuration using etcdctl
87+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
88+
89+
To publish a cluster's configuration using the ``etcdctl`` utility, use the ``put`` command:
90+
91+
.. code-block:: console
92+
93+
$ etcdctl put /example/config/all < cluster.yaml
94+
95+
96+
97+
98+
.. _etcd_showing_configuration:
99+
100+
Showing a cluster's configuration
101+
---------------------------------
102+
103+
As for :ref:`publishing configuration <etcd_publishing_configuration>`, you can see a cluster's configuration in two ways:
104+
105+
- Using the :ref:`tt cluster show <tt-cluster>` command.
106+
- Using the ``etcdctl get`` command.
107+
108+
109+
.. _etcd_starting_instances:
110+
111+
Starting Tarantool instances
112+
----------------------------
113+
114+
To learn how to start Tarantool instances, see the :ref:`Starting Tarantool instances <configuration_run_instance>` section.
115+
116+
117+
.. _etcd_reloading_configuration:
118+
119+
Reloading configuration
120+
-----------------------
121+
122+
By default, Tarantool watches etcd keys with the :ref:`specified prefix <etcd_local_configuration>` for changes in a cluster's configuration and reloads a changed configuration automatically.
123+
If necessary, you can set the :ref:`config.reload <configuration_reference_config_reload>` option to ``manual`` to turn off configuration reloading:
124+
125+
.. code-block:: yaml
126+
127+
config:
128+
reload: 'manual'
129+
etcd:
130+
# ...
131+
132+
In this case, you can reload a configuration in the :ref:`application code <configuration_application>` using the ``reload()`` function provided by the :ref:`config <config-module>` module:
133+
134+
.. code-block:: lua
135+
136+
require('config'):reload()
137+
138+
139+
140+
141+
142+
143+
144+
145+
146+
..
147+
Generating certificates for testing:
148+
1) openssl genrsa -out ca.key 2048
149+
2) openssl req -new -x509 -days 365 -key ca.key -subj "/C=CN/ST=GD/L=SZ/O=Acme, Inc./CN=Acme Root CA" -out ca.cr
150+
3) openssl req -newkey rsa:2048 -nodes -keyout server.key -subj "/C=CN/ST=GD/L=SZ/O=Acme, Inc./CN=localhost" -out server.csr
151+
4) openssl x509 -req -extfile <(printf "subjectAltName=DNS:localhost,IP:127.0.0.1") -days 365 -in server.csr -CA ca.crt -CAkey ca.key -CAcreateserial -out server.crt
152+
5) sudo cp server.crt /etc/ssl/certs
153+
6) sudo cp server.key /etc/ssl/private
154+
155+
Starting etcd:
156+
etcd --cert-file=ssl/server.crt --key-file=ssl/server.key --advertise-client-urls=https://localhost:2379 --listen-client-urls=https://localhost:2379
157+
158+
Get keys:
159+
etcdctl get /tt/config/all --cert=ssl/server.crt --key=ssl/server.key
160+
161+
Test using curl:
162+
curl --cacert ssl/ca.crt https://localhost:2379/v2/keys/foo -XPUT -d value=bar -v

0 commit comments

Comments
 (0)