Skip to content

Commit f06a700

Browse files
Add node config init and config generate commands (#16479)
Co-authored-by: anton-bobkov <anton-bobkov@ydb.tech>
1 parent 639a53a commit f06a700

File tree

2 files changed

+230
-84
lines changed

2 files changed

+230
-84
lines changed

ydb/docs/en/core/reference/ydb-cli/configs.md

Lines changed: 118 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,59 +1,132 @@
1-
## Working with configuration
1+
## Managing {{ ydb-short-name }} configuration
22

3-
### Common command flags
3+
{% note info %}
44

5-
* `-f, --filename <filename.yaml>` — read input from a file, `-` for STDIN. It can be specified multiple times for commands accepting multiple files (e.g., resolve). The metadata field will determine the file type.
6-
* `--output-directory <dir>` — dump/resolve files to a directory.
7-
* `--strip-metadata` — remove the metadata field from the output.
8-
* `--all` — extend command output to the entire configuration (see advanced configuration).
9-
* `--allow-unknown-fields` — allow ignoring unknown fields in the configuration.
5+
Before YDB CLI 2.20.0, the `{{ ydb-cli }} admin cluster config` commands had the following format: `{{ ydb-cli }} admin config`.
106

11-
```bash
12-
# Apply the configuration dynconfig.yaml to the cluster
13-
{{ ydb-cli }} admin config replace -f dynconfig.yaml
14-
# Check if it is possible to apply the configuration dynconfig.yaml to the cluster (validate all validators, version, and cluster match)
15-
{{ ydb-cli }} admin config replace -f dynconfig.yaml --dry-run
16-
# Apply the configuration dynconfig.yaml to the cluster, ignoring version and cluster checks (version and cluster will still be overwritten with correct ones)
17-
{{ ydb-cli }} admin config replace -f dynconfig.yaml --force
18-
# Fetch the main cluster configuration
19-
{{ ydb-cli }} admin config fetch
20-
# Fetch all current configuration files of the cluster
21-
{{ ydb-cli }} admin config fetch --all
22-
# Generate all possible final configurations for dynconfig.yaml
23-
{{ ydb-cli }} admin config resolve --all -f dynconfig.yaml
24-
# Generate the final configuration for dynconfig.yaml with labels tenant=/Root/test and canary=true
25-
{{ ydb-cli }} admin config resolve -f dynconfig.yaml --label tenant=/Root/test --label canary=true
26-
# Generate the final configuration for dynconfig.yaml for labels from node 1003
27-
{{ ydb-cli }} admin config resolve -f dynconfig.yaml --node-id 1003
28-
# Fetch all temporary configurations of the cluster
29-
{{ ydb-cli }} admin volatile-config fetch --all --output-directory <dir>
30-
# Fetch the temporary configuration with id 1 from the cluster
31-
{{ ydb-cli }} admin volatile-config fetch --id 1
32-
# Apply the temporary configuration volatile.yaml to the cluster
33-
{{ ydb-cli }} admin volatile-config add -f volatile.yaml
34-
# Delete temporary configurations with ids 1 and 3 on the cluster
35-
{{ ydb-cli }} admin volatile-config drop --id 1 --id 3
36-
# Delete all temporary configurations on the cluster
37-
{{ ydb-cli }} admin volatile-config drop --all
38-
```
7+
{% endnote %}
8+
9+
This section contains commands for managing the {{ ydb-short-name }} [cluster configuration](../../maintenance/manual/config-overview.md).
10+
11+
- Apply the `dynconfig.yaml` configuration to the cluster:
12+
13+
```bash
14+
{{ ydb-cli }} admin cluster config replace -f dynconfig.yaml
15+
```
16+
17+
- Check if it is possible to apply the configuration dynconfig.yaml to the cluster (check all validators, the configuration version in the yaml file must be 1 higher than the cluster configuration version, the cluster name must match):
18+
19+
```bash
20+
{{ ydb-cli }} admin cluster config replace -f dynconfig.yaml --dry-run
21+
```
22+
23+
- Apply the `dynconfig.yaml` configuration to the cluster, ignoring version and cluster checks (the version and cluster values will be overwritten with correct values):
24+
25+
```bash
26+
{{ ydb-cli }} admin cluster config replace -f dynconfig.yaml --force
27+
```
28+
29+
- Fetch the main cluster configuration:
30+
31+
```bash
32+
{{ ydb-cli }} admin cluster config fetch
33+
```
34+
35+
- Generate all possible final configurations for `dynconfig.yaml`:
36+
37+
```bash
38+
{{ ydb-cli }} admin cluster config resolve --all -f dynconfig.yaml
39+
```
40+
41+
- Generate the final configuration for `dynconfig.yaml` with the `tenant=/Root/test` and `canary=true` labels:
42+
43+
```bash
44+
{{ ydb-cli }} admin cluster config resolve -f dynconfig.yaml --label tenant=/Root/test --label canary=true
45+
```
46+
47+
- Generate the final configuration for `dynconfig.yaml` for labels from node 100:
48+
49+
```bash
50+
{{ ydb-cli }} admin cluster config resolve -f dynconfig.yaml --node-id 100
51+
```
52+
53+
- Generate a dynamic configuration file, based on a static configuration on the cluster:
54+
55+
```bash
56+
{{ ydb-cli }} admin cluster config genereate
57+
```
58+
59+
- Initialize a directory with the configuration, using the path to the configuration file:
60+
61+
```bash
62+
{{ ydb-cli }} admin node config init --config-dir <path_to_directory> --from-config <path_to_configuration_file>
63+
```
64+
65+
- Initialize a directory with the configuration, using the configuration from the cluster:
66+
67+
```bash
68+
{{ ydb-cli }} admin node config init --config-dir <path_to_directory> --seed-node <cluster_node_endpoint>
69+
```
70+
71+
## Managing temporary configuration
72+
73+
This section contains commands for managing [temporary configurations](../../maintenance/manual/dynamic-config-volatile-config.md).
74+
75+
- Fetch all temporary configurations from the cluster:
76+
77+
```bash
78+
{{ ydb-cli }} admin volatile-config fetch --all --output-directory <dir>
79+
```
80+
81+
- Fetch the temporary configuration with id 1 from the cluster:
82+
83+
```bash
84+
{{ ydb-cli }} admin volatile-config fetch --id 1
85+
```
86+
87+
- Apply the `volatile.yaml` temporary configuration to the cluster:
88+
89+
```bash
90+
{{ ydb-cli }} admin volatile-config add -f volatile.yaml
91+
```
92+
93+
- Delete temporary configurations with ids 1 and 3 on the cluster:
94+
95+
```bash
96+
{{ ydb-cli }} admin volatile-config drop --id 1 --id 3
97+
```
98+
99+
- Delete all temporary configurations on the cluster:
100+
101+
```bash
102+
{{ ydb-cli }} admin volatile-config drop --all
103+
```
104+
105+
## Parameters
106+
107+
* `-f, --filename <filename.yaml>`read input from a file, `-` for STDIN. For commands that accept multiple files (e.g., resolve), you can specify it multiple times, the file type will be determined by the metadata field
108+
* `--output-directory <dir>` — dump/resolve files to a directory
109+
* `--strip-metadata` — remove the metadata field from the output
110+
* `--all` — extends the output of commands to the entire configuration (see advanced configuration)
111+
* `--allow-unknown-fields` — allows ignoring unknown fields in the configuration
39112

40113
## Scenarios
41114

42115
### Update the main cluster configuration
43116

44-
```bash
117+
```bash
45118
# Fetch the cluster configuration
46-
{{ ydb-cli }} admin config fetch > dynconfig.yaml
119+
{{ ydb-cli }} admin cluster config fetch > dynconfig.yaml
47120
# Edit the configuration with your favorite editor
48121
vim dynconfig.yaml
49122
# Apply the configuration dynconfig.yaml to the cluster
50-
{{ ydb-cli }} admin config replace -f dynconfig.yaml
123+
{{ ydb-cli }} admin cluster config replace -f dynconfig.yaml
51124
```
52125

53126
Similarly, in one line:
54127

55128
```bash
56-
{{ ydb-cli }} admin config fetch | yq '.config.actor_system_config.scheduler.resolution = 128' | {{ ydb-cli }} admin config replace -f -
129+
{{ ydb-cli }} admin cluster config fetch | yq '.config.actor_system_config.scheduler.resolution = 128' | {{ ydb-cli }} admin cluster config replace -f -
57130
```
58131

59132
Command output:
@@ -65,7 +138,7 @@ OK
65138
### View the configuration for a specific set of labels
66139

67140
```bash
68-
{{ ydb-cli }} admin config resolve --remote --label tenant=/Root/db1 --label canary=true
141+
{{ ydb-cli }} admin cluster config resolve --remote --label tenant=/Root/db1 --label canary=true
69142
```
70143

71144
Command output:
@@ -86,7 +159,7 @@ config:
86159
### View the configuration for a specific node
87160

88161
```bash
89-
{{ ydb-cli }} admin config resolve --remote --node-id <node_id>
162+
{{ ydb-cli }} admin cluster config resolve --remote --node-id <node_id>
90163
```
91164

92165
Command output:
@@ -107,7 +180,7 @@ config:
107180
### Save all configurations locally
108181

109182
```bash
110-
{{ ydb-cli }} admin config fetch --all --output-directory <configs_dir>
183+
{{ ydb-cli }} admin cluster config fetch --all --output-directory <configs_dir>
111184
ls <configs_dir>
112185
```
113186

@@ -120,7 +193,7 @@ dynconfig.yaml volatile_1.yaml volatile_3.yaml
120193
### View all configurations locally
121194

122195
```bash
123-
{{ ydb-cli }} admin config fetch --all
196+
{{ ydb-cli }} admin cluster config fetch --all
124197
```
125198

126199
Command output:
@@ -158,7 +231,7 @@ selectors:
158231
### View the final configuration for a specific node from the locally saved original configuration
159232

160233
```bash
161-
{{ ydb-cli }} admin config resolve -k <configs_dir> --node-id <node_id>
234+
{{ ydb-cli }} admin cluster config resolve -k <configs_dir> --node-id <node_id>
162235
```
163236

164237
Command output:
@@ -174,4 +247,4 @@ config:
174247
use_auto_config: true
175248
node_type: COMPUTE
176249
cpu_count: 4
177-
```
250+
```

0 commit comments

Comments
 (0)