Skip to content

Commit 99fa56a

Browse files
committed
3.0 etcd config
1 parent 5e23cd3 commit 99fa56a

File tree

12 files changed

+384
-74
lines changed

12 files changed

+384
-74
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
config:
2+
etcd:
3+
endpoints:
4+
- http://localhost:2379
5+
prefix: /example
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
instance001:
2+
instance002:
3+
instance003:
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
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
instance001:
2+
instance002:
3+
instance003:

doc/code_snippets/test/config/etcd.yaml

-5
This file was deleted.

doc/concepts/configuration.rst

+4-8
Original file line numberDiff line numberDiff line change
@@ -272,18 +272,14 @@ Centralized configuration
272272
Tarantool enables you to store configuration data in one reliable place using etcd.
273273
To achieve this, you need to:
274274

275-
1. Put a YAML file with a cluster's configuration to an etcd server:
275+
1. Provide a local YAML configuration with an etcd endpoint address and key prefix in the ``config`` section:
276276

277-
.. code-block:: console
278-
279-
$ etcdctl put /example/config/all.yaml < remote_config.yaml
280-
281-
2. Provide a local YAML configuration with an etcd endpoint address and key prefix in the ``config`` section:
282-
283-
.. literalinclude:: /code_snippets/test/config/etcd.yaml
277+
.. literalinclude:: /code_snippets/snippets/config/instances.enabled/etcd/config.yaml
284278
:language: yaml
285279
:dedent:
286280

281+
2. Publish a cluster's configuration to an etcd server.
282+
287283
Learn more from the following guide: :ref:`Storing configuration in etcd <configuration_etcd>`.
288284

289285

doc/concepts/configuration/configuration_etcd.rst

+119-61
Original file line numberDiff line numberDiff line change
@@ -6,92 +6,150 @@ 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/snippets/config/instances.enabled/etcd/config.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/snippets/config/instances.enabled/etcd_full/config.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 a 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+
.. NOTE::
84+
85+
You can see a cluster's configuration using the :ref:`tt cluster show <tt-cluster>` command.
86+
87+
88+
.. _etcd_publishing_configuration_etcdctl:
89+
90+
Publishing configuration using etcdctl
91+
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
92+
93+
To publish a cluster's configuration using the ``etcdctl`` utility, use the ``put`` command:
94+
95+
.. code-block:: console
96+
97+
$ etcdctl put /example/config/all < cluster.yaml
98+
99+
100+
101+
102+
.. _etcd_starting_instances:
103+
104+
Starting Tarantool instances
105+
----------------------------
106+
107+
To learn how to start Tarantool instances, see the :ref:`Starting Tarantool instances <configuration_run_instance>` section.
108+
109+
110+
.. _etcd_reloading_configuration:
111+
112+
Reloading configuration
113+
-----------------------
114+
115+
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.
116+
If necessary, you can set the :ref:`config.reload <configuration_reference_config_reload>` option to ``manual`` to turn off configuration reloading:
117+
118+
.. code-block:: yaml
119+
120+
config:
121+
reload: 'manual'
122+
etcd:
123+
# ...
124+
125+
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:
126+
127+
.. code-block:: lua
128+
129+
require('config'):reload()
130+
131+
132+
133+
134+
135+
136+
137+
138+
139+
..
140+
Generating certificates for testing:
141+
1) openssl genrsa -out ca.key 2048
142+
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
143+
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
144+
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
145+
5) sudo cp server.crt /etc/ssl/certs
146+
6) sudo cp server.key /etc/ssl/private
147+
148+
Starting etcd:
149+
etcd --cert-file=ssl/server.crt --key-file=ssl/server.key --advertise-client-urls=https://localhost:2379 --listen-client-urls=https://localhost:2379
150+
151+
Get keys:
152+
etcdctl get /tt/config/all --cert=ssl/server.crt --key=ssl/server.key
153+
154+
Test using curl:
155+
curl --cacert ssl/ca.crt https://localhost:2379/v2/keys/foo -XPUT -d value=bar -v

0 commit comments

Comments
 (0)