Skip to content

Commit c71f5fd

Browse files
committed
Add TCM config reference
1 parent 5cf032a commit c71f5fd

File tree

2 files changed

+1999
-0
lines changed

2 files changed

+1999
-0
lines changed
Lines changed: 219 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,219 @@
1+
.. _tcm_configuration:
2+
3+
Configuration
4+
=============
5+
6+
.. TODO: write specific configuration tutorials for http, security, logging, and so on.
7+
8+
This topic describes the |tcm_full_name| configuration model. For the complete
9+
list of |tcm| configuration parameters, see the :ref:`TCM configuration reference <tcm_configuration_reference>`.
10+
11+
Configuration structure
12+
-----------------------
13+
14+
|tcm_full_name| configuration is a set of parameters that define various aspects
15+
of |tcm| functioning. Parameters are grouped by the particular aspect that they
16+
affect. There are the following groups:
17+
18+
* HTTP
19+
* logging
20+
* configuration storage
21+
* security
22+
* add-ons
23+
* limits
24+
* |tcm| running mode
25+
26+
Parameter groups can be nested. For example, in the ``http`` group there are
27+
``tls`` and ``websession-cookie`` groups, which define TLS encryption and
28+
cookie settings.
29+
30+
Parameter names are the full paths from the top-level group to the specific parameter.
31+
For example:
32+
33+
* ``http.host`` is the ``host`` parameter that is defined directly in the ``http`` group.
34+
* ``http.tls.enabled`` is the ``enabled`` parameter that is defined in the ``tls``
35+
nested group within ``http``.
36+
37+
.. _tcm_configuration_ways:
38+
39+
Ways to pass configuration parameters
40+
-------------------------------------
41+
42+
There are three ways to pass |tcm| configuration parameters:
43+
44+
- a YAML file
45+
- environment variables
46+
- command-line options of the |tcm| executable
47+
48+
.. _tcm_configuration_ways_yaml:
49+
50+
YAML file
51+
~~~~~~~~~
52+
53+
|tcm| configuration can be stored in a YAML file. Its structure must reflect the
54+
configuration parameters hierarchy.
55+
56+
The example below shows a shows a fragment of a |tcm| configuration file:
57+
58+
.. code-block:: yaml
59+
60+
# a fragment of a YAML configuration file
61+
cluster: # top-level group
62+
on-air-limit: 4096
63+
connection-rate-limit: 512
64+
tarantool-timeout: 10s
65+
tarantool-ping-timeout: 5s
66+
http: # top-level group
67+
basic-auth: # nested group
68+
enabled: false
69+
network: tcp
70+
host: 127.0.0.1
71+
port: 8080
72+
request-size: 1572864
73+
websocket: # nested group
74+
read-buffer-size: 16384
75+
write-buffer-size: 16384
76+
keepalive-ping-interval: 20s
77+
handshake-timeout: 10s
78+
init-timeout: 15s
79+
80+
To start |tcm| with a YAML configuration, pass the location of the configuration
81+
file in the ``-c`` command-line option:
82+
83+
.. code-block:: console
84+
85+
tcm -c=config.yml
86+
87+
.. _tcm_configuration_ways_env:
88+
89+
Environment variables
90+
~~~~~~~~~~~~~~~~~~~~~
91+
92+
|tcm| can take values of its configuration parameters from environment variables.
93+
The variable names start with ``TCM_``. Then goes the full path to the parameter,
94+
converted to upper case. All delimiters are replaced with underscores (``_``).
95+
Examples:
96+
97+
- ``TCM_HTTP_HOST`` is a variable for the ``http.host`` parameter.
98+
- ``TCM_HTTP_WEBSESSION_COOKIE_NAME`` is a variable for the ``http.websession-cookie.name`` parameter.
99+
100+
The example below shows how to start |tcm| passing configuration parameters in
101+
environment variables:
102+
103+
.. code-block:: console
104+
105+
export TCM_HTTP_HOST=0.0.0.0
106+
export TCM_HTTP_PORT=8888
107+
tcm
108+
109+
.. _tcm_configuration_ways_cli:
110+
111+
Command-line arguments
112+
~~~~~~~~~~~~~~~~~~~~~~
113+
114+
The |tcm| executable has ``--`` command-line options for each configuration parameter.
115+
Their names reflect the full path to the parameter, with all delimiters replaced by
116+
hyphens (``-``). Examples:
117+
118+
- ``--http-host`` is an option for ``http.host``.
119+
- ``--http-websession-cookie-name`` is an option for ``http.websession-cookie.name``.
120+
121+
The example below shows how to start |tcm| passing configuration parameters in
122+
command-line options:
123+
124+
.. code-block:: console
125+
126+
./tcm --storage.etcd.embed.enabled --addon.enabled --http.host=0.0.0.0 --http.port=8888
127+
128+
129+
.. _tcm_configuration_precedence:
130+
131+
Configuration precedence
132+
~~~~~~~~~~~~~~~~~~~~~~~~
133+
134+
|tcm| configuration options are applied from multiple sources with the following precedence,
135+
from highest to lowest:
136+
137+
#. ``tcm`` executable arguments.
138+
#. `TCM_*` environment variables.
139+
#. Configuration from a YAML file.
140+
141+
If the same option is defined in two or more locations, the option with the highest
142+
precedence is applied. For options that aren't defined in any location, the default
143+
values are used.
144+
145+
You can combine different ways of |tcm| configuration for efficient management of
146+
multiple |tcm| installations:
147+
148+
- A single YAML file for all installations can contain the common configuration parts.
149+
For example, the |tcm| configuration storage used for all installations or
150+
TLS settings.
151+
- Environment variables that set specific parameters for each server, such as
152+
local directories and paths.
153+
- Command-line options for parameters that must be unique for different |tcm| instances
154+
running on a single server. For example, ``http.port``.
155+
156+
Configuration parameter types
157+
-----------------------------
158+
159+
|tcm| configuration parameters have the `Go <https://go.dev/>`__ language
160+
types. Note that this is different from the :ref:`Tarantool configuration parameters <configuration_reference>`,
161+
which have Lua types.
162+
163+
Most options have the Go's basic types: `bool`, `string`, `int`, and other numeric types.
164+
Their values are passed as strings:
165+
166+
.. code-block:: yaml
167+
168+
http:
169+
basic-auth:
170+
enabled: false # bool
171+
network: tcp # string
172+
host: 127.0.0.1 #string
173+
port: 8080 # int
174+
request-size: 1572864 # int64
175+
176+
Parameters that can take multiple values are arrays. In YAML, they are passed as
177+
YAML arrays (each item on a new line, starting with a dash). In environment variables
178+
and command line options, the items of such arrays are passed in a semicolon-separated string.
179+
180+
.. code-block:: yaml
181+
182+
storage:
183+
provider: etcd
184+
etcd:
185+
endpoints: # array
186+
- https://192.168.0.1:2379 # item 1
187+
- https://192.168.0.2:2379 # item 2
188+
189+
Parameters that set timeouts, TTLs, and other duration values, have the Go's `time.Duration <https://pkg.go.dev/time#Duration>`__
190+
type. Their values can be passed in time-formatted strings such as ``4h30m25s``.
191+
192+
.. code-block:: yaml
193+
194+
cluster:
195+
tarantool-timeout: 10s # duration
196+
tarantool-ping-timeout: 5s # duration
197+
198+
Finally, there are parameters whose values are constants defined in Go packages.
199+
For example, :ref:`http.websession-cookie.same-site <tcm_configuration_reference_http_websession-cookie_same-site> `
200+
values are constants from the Go's `http.SameSite <https://pkg.go.dev/net/http#SameSite>`__
201+
type. To find out the exact values available for such parameters, refer to `Go
202+
packages documentation <https://pkg.go.dev/>`__.
203+
204+
.. code-block:: yaml
205+
206+
http:
207+
tls:
208+
cipher-suites:
209+
- TLS_RSA_WITH_RC4_128_SHA # Go constant
210+
211+
Creating configuration template
212+
-------------------------------
213+
214+
You can create a YAML configuration template for |tcm| by running the ``tcm``
215+
executable with the ``generate-config`` option:
216+
217+
.. code-block:: console
218+
219+
tcm generate-config

0 commit comments

Comments
 (0)