Skip to content

Commit fe9585d

Browse files
p7novandreyaksenov
andauthored
Add tt cluster reference (#4046)
Resolves #3725, #3929 Co-authored-by: Andrey Aksenov <[email protected]>
1 parent 30933a5 commit fe9585d

File tree

1 file changed

+234
-6
lines changed

1 file changed

+234
-6
lines changed
Lines changed: 234 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,238 @@
1-
.. _tt-cluster:
1+
.. _tt-cluster2:
22

3-
Managing a cluster's configuration
4-
==================================
3+
Managing cluster configurations
4+
===============================
55

6-
.. code-block:: console
6+
.. code-block:: console
77
8-
$ tt cluster
8+
$ tt cluster COMMAND {APPLICATION[:APP_INSTANCE] | URI} [FILE] [OPTION ...]
99
10-
.. TODO: https://github.com/tarantool/doc/issues/3725
10+
``tt cluster`` manages :ref:`YAML configurations <configuration>` of Tarantool applications.
11+
This command works both with local configuration files in application directories
12+
and with centralized configuration storages (:ref:`etcd <configuration_etcd>` or Tarantool-based).
13+
14+
``COMMAND`` is one of the following:
15+
16+
* ``publish``: publish a cluster configuration using an arbitrary YAML file as a source.
17+
* ``show``: print a cluster configuration.
18+
19+
20+
.. _tt-cluster-local:
21+
22+
Managing local configurations
23+
-----------------------------
24+
25+
``tt cluster`` can read and modify local cluster configurations stored in
26+
``config.yaml`` files inside application directories.
27+
28+
To write a configuration to a local ``config.yaml``, run ``tt cluster publish``
29+
with two arguments:
30+
31+
* the application name.
32+
* the path to a YAML file from which the configuration should be taken.
33+
34+
.. code-block:: console
35+
36+
$ tt cluster publish myapp source.yaml
37+
38+
To print a local configuration from an application's ``config.yaml``, run
39+
``tt cluster show`` with the application name:
40+
41+
.. code-block:: console
42+
43+
$ tt cluster show myapp
44+
45+
.. _tt-cluster-centralized:
46+
47+
Managing configurations in centralized storages
48+
-----------------------------------------------
49+
50+
``tt cluster`` can manage centralized cluster configurations in storages of both
51+
supported types: :ref:`etcd <configuration_etcd>` or a Tarantool-based configuration storage.
52+
53+
To publish a configuration from a file to a centralized configuration storage,
54+
run ``tt cluster publish`` with a URI of this storage's
55+
instance as the target. For example, the command below publishes a configuration from ``source.yaml``
56+
to a local etcd instance running on the default port ``2379``:
57+
58+
.. code-block:: console
59+
60+
$ tt cluster publish "http://localhost:2379/myapp" source.yaml
61+
62+
A URI must include a prefix that is unique for the application. It can also include
63+
credentials and other connection parameters. Find the detailed description of the
64+
URI format in :ref:`tt-cluster-centralized-uri`.
65+
66+
To print a cluster configuration from a centralized storage, run ``tt cluster show``
67+
with a storage URI including the prefix identifying the application. For example, to print
68+
``myapp``'s configuration from a local etcd storage:
69+
70+
.. code-block:: console
71+
72+
$ tt cluster show "http://localhost:2379/myapp"
73+
74+
.. _tt-cluster-centralized-authentication:
75+
76+
Authentication
77+
~~~~~~~~~~~~~~
78+
79+
There are three ways to pass the credentials for connecting to the centralized configuration storage.
80+
They all apply to both etcd and Tarantool-based storages. The following list
81+
shows these ways ordered by precedence, from highest to lowest:
82+
83+
#. Credentials specified in the storage URI: ``https://username:password@host:port/prefix``:
84+
85+
.. code-block:: console
86+
87+
$ tt cluster show "http://myuser:p4$$w0rD@localhost:2379/myapp"
88+
89+
90+
#. ``tt cluster`` options ``-u``/``--username`` and ``-p``/``--password``:
91+
92+
.. code-block:: console
93+
94+
$ tt cluster show "http://localhost:2379/myapp" -u myuser -p p4$$w0rD
95+
96+
#. Environment variables ``TT_CLI_ETCD_USERNAME`` and ``TT_CLI_ETCD_PASSWORD``:
97+
98+
.. code-block:: console
99+
100+
$ export TT_CLI_ETCD_USERNAME=myuser
101+
$ export TT_CLI_ETCD_PASSWORD=p4$$w0rD
102+
$ tt cluster show "http://localhost:2379/myapp"
103+
104+
If connection encryption is enabled on the configuration storage, pass the required
105+
SSL parameters in the :ref:`URI arguments <tt-cluster-centralized-uri>`.
106+
107+
.. _tt-cluster-centralized-uri:
108+
109+
URI format
110+
~~~~~~~~~~
111+
112+
A URI of the cluster configuration storage has the following format:
113+
114+
.. code-block:: text
115+
116+
http(s)://[username:password@]host:port[/prefix][?arguments]
117+
118+
* ``username`` and ``password`` define credentials for connecting to the configuration storage.
119+
* ``prefix`` is a base path identifying a specific application in the storage.
120+
* ``arguments`` defines connection parameters. The following arguments are available:
121+
122+
* ``name`` -- a name of an instance in the cluster configuration.
123+
* ``key`` -- a target configuration key in the specified ``prefix``.
124+
* ``timeout`` -- a request timeout in seconds. Default: ``3.0``.
125+
* ``ssl_key_file`` -- a path to a private SSL key file.
126+
* ``ssl_cert_file`` -- a path to an SSL certificate file.
127+
* ``ssl_ca_file`` -- a path to a trusted certificate authorities (CA) file.
128+
* ``ssl_ca_path`` -- a path to a trusted certificate authorities (CA) directory.
129+
* ``verify_host`` -- verify the certificate’s name against the host. Default ``true``.
130+
* ``verify_peer`` -- verify the peer’s SSL certificate. Default ``true``.
131+
132+
.. _tt-cluster-instance:
133+
134+
Managing configurations of specific instances
135+
---------------------------------------------
136+
137+
In addition to whole cluster configurations, ``tt cluster`` can manage
138+
configurations of specific instances within applications. In this case, it operates
139+
with YAML fragments that describe a single :ref:`instance configuration section <configuration_overview>`.
140+
For example, the following YAML file can be a source when publishing an instance configuration:
141+
142+
.. code-block:: yaml
143+
144+
# instance_source.yaml
145+
iproto:
146+
listen:
147+
- uri: 127.0.0.1:3311
148+
149+
To send an instance configuration to a local ``config.yaml``, run ``tt cluster publish``
150+
with the ``application:instance`` pair as the target argument:
151+
152+
.. code-block:: console
153+
154+
$ tt cluster publish myapp:instance-002 instance_source.yaml
155+
156+
To send an instance configuration to a centralized configuration storage, specify
157+
the instance name in the ``name`` argument of the storage URI:
158+
159+
.. code-block:: console
160+
161+
$ tt cluster publish "http://localhost:2379/myapp?name=instance-002" instance_source.yaml
162+
163+
``tt cluster show`` can print configurations of specific cluster instances as well.
164+
To print an instance configuration from a local ``config.yaml``, use the ``application:instance``
165+
argument:
166+
167+
.. code-block:: console
168+
169+
$ tt cluster show myapp:instance-002
170+
171+
To print an instance configuration from a centralized configuration storage, specify
172+
the instance name in the ``name`` argument of the URI:
173+
174+
.. code-block:: console
175+
176+
$ tt cluster show "http://localhost:2379/myapp?name=instance-002"
177+
178+
.. _tt-cluster-validation:
179+
180+
Configuration validation
181+
------------------------
182+
183+
``tt cluster`` can validate configurations against the Tarantool configuration schema.
184+
185+
``tt cluster publish`` automatically performs the validation and aborts in case of an error.
186+
To skip the validation, add the ``--force`` option:
187+
188+
.. code-block:: console
189+
190+
$ tt cluster publish myapp source.yaml --force
191+
192+
To validate configurations when printing them with ``tt cluster show``, enable the
193+
validation by adding the ``--validate`` option:
194+
195+
.. code-block:: console
196+
197+
$ tt cluster show "http://localhost:2379/myapp" --validate
198+
199+
200+
.. _tt-cluster-options:
201+
202+
Options
203+
-------
204+
205+
.. option:: -u, --username STRING
206+
207+
A username for connecting to the configuration storage.
208+
209+
See also: :ref:`tt-cluster-centralized-authentication`.
210+
211+
.. option:: -p, --password STRING
212+
213+
A password for connecting to the configuration storage.
214+
215+
See also: :ref:`tt-cluster-centralized-authentication`.
216+
217+
.. option:: --force
218+
219+
**Applicable to:** ``publish``
220+
221+
Skip validation when publishing. Default: `false` (validation is enabled).
222+
223+
.. option:: --validate
224+
225+
**Applicable to:** ``show``
226+
227+
Validate the printed configuration. Default: `false` (validation is disabled).
228+
229+
.. option:: --with-integrity-check STRING
230+
231+
.. admonition:: Enterprise Edition
232+
:class: fact
233+
234+
This option is supported by the `Enterprise Edition <https://www.tarantool.io/compare/>`_ only.
235+
236+
**Applicable to:** ``publish``
237+
238+
Generate hashes and signatures for integrity checks.

0 commit comments

Comments
 (0)