source: trunk/docs/managed-grid.rst

Last change on this file was aed5061a, checked in by GitHub <noreply@…>, at 2023-02-28T00:33:53Z

wording

Co-authored-by: Jean-Paul Calderone <exarkun@…>

  • Property mode set to 100644
File size: 13.1 KB
Line 
1
2
3Managed Grid
4============
5
6This document explains the "Grid Manager" concept and the
7`grid-manager` command. Someone operating a grid may choose to use a
8Grid Manager. Operators of storage-servers and clients will then be
9given additional configuration in this case.
10
11
12Overview and Motivation
13-----------------------
14
15In a grid using an Introducer, a client will use any storage-server
16the Introducer announces (and the Introducer will announce any
17storage-server that connects to it). This means that anyone with the
18Introducer fURL can connect storage to the grid.
19
20Sometimes, this is just what you want!
21
22For some use-cases, though, you want to have clients only use certain
23servers. One case might be a "managed" grid, where some entity runs
24the grid; clients of this grid don't want their uploads to go to
25"unmanaged" storage if some other client decides to provide storage.
26
27One way to limit which storage servers a client connects to is via the
28"server list" (:ref:`server_list`) (aka "Introducerless"
29mode). Clients are given static lists of storage-servers, and connect
30only to those. This means manually updating these lists if the storage
31servers change, however.
32
33Another method is for clients to use `[client] peers.preferred=`
34configuration option (:ref:`Client Configuration`), which suffers
35from a similar disadvantage.
36
37
38Grid Manager
39------------
40
41A "grid-manager" consists of some data defining a keypair (along with
42some other details) and Tahoe sub-commands to manipulate the data and
43produce certificates to give to storage-servers. Certificates assert
44the statement: "Grid Manager X suggests you use storage-server Y to
45upload shares to" (X and Y are public-keys). Such a certificate
46consists of:
47
48 - the version of the format the certificate conforms to (`1`)
49 - the public-key of a storage-server
50 - an expiry timestamp
51 - a signature of the above
52
53A client will always use any storage-server for downloads (expired
54certificate, or no certificate) because clients check the ciphertext
55and re-assembled plaintext against the keys in the capability;
56"grid-manager" certificates only control uploads.
57
58Clients make use of this functionality by configuring one or more Grid Manager public keys.
59This tells the client to only upload to storage-servers that have a currently-valid certificate from any of the Grid Managers their client allows.
60In case none are configured, the default behavior (of using any storage server) prevails.
61
62
63Grid Manager Data Storage
64-------------------------
65
66The data defining the grid-manager is stored in an arbitrary
67directory, which you indicate with the ``--config`` option (in the
68future, we may add the ability to store the data directly in a grid,
69at which time you may be able to pass a directory-capability to this
70option).
71
72If you don't want to store the configuration on disk at all, you may
73use ``--config -`` (the last character is a dash) and write a valid
74JSON configuration to stdin.
75
76All commands require the ``--config`` option and they all behave
77similarly for "data from stdin" versus "data from disk". A directory
78(and not a file) is used on disk because in that mode, each
79certificate issued is also stored alongside the configuration
80document; in "stdin / stdout" mode, an issued certificate is only
81ever available on stdout.
82
83The configuration is a JSON document. It is subject to change as Grid
84Manager evolves. It contains a version number in the
85`grid_manager_config_version` key which will increment whenever the
86document schema changes.
87
88
89grid-manager create
90```````````````````
91
92Create a new grid-manager.
93
94If you specify ``--config -`` then a new grid-manager configuration is
95written to stdout. Otherwise, a new grid-manager is created in the
96directory specified by the ``--config`` option. It is an error if the
97directory already exists.
98
99
100grid-manager public-identity
101````````````````````````````
102
103Print out a grid-manager's public key. This key is derived from the
104private-key of the grid-manager, so a valid grid-manager config must
105be given via ``--config``
106
107This public key is what is put in clients' configuration to actually
108validate and use grid-manager certificates.
109
110
111grid-manager add
112````````````````
113
114Takes two args: ``name pubkey``. The ``name`` is an arbitrary local
115identifier for the new storage node (also sometimes called "a petname"
116or "nickname"). The pubkey is the tahoe-encoded key from a ``node.pubkey``
117file in the storage-server's node directory (minus any
118whitespace). For example, if ``~/storage0`` contains a storage-node,
119you might do something like this::
120
121   grid-manager --config ./gm0 add storage0 $(cat ~/storage0/node.pubkey)
122
123This adds a new storage-server to a Grid Manager's
124configuration. (Since it mutates the configuration, if you used
125``--config -`` the new configuration will be printed to stdout). The
126usefulness of the ``name`` is solely for reference within this Grid
127Manager.
128
129
130grid-manager list
131`````````````````
132
133Lists all storage-servers that have previously been added using
134``grid-manager add``.
135
136
137grid-manager sign
138`````````````````
139
140Takes two args: ``name expiry_days``. The ``name`` is a nickname used
141previously in a ``grid-manager add`` command and ``expiry_days`` is
142the number of days in the future when the certificate should expire.
143
144Note that this mutates the state of the grid-manager if it is on disk,
145by adding this certificate to our collection of issued
146certificates. If you used ``--config -``, the certificate isn't
147persisted anywhere except to stdout (so if you wish to keep it
148somewhere, that is up to you).
149
150This command creates a new "version 1" certificate for a
151storage-server (identified by its public key). The new certificate is
152printed to stdout. If you stored the config on disk, the new
153certificate will (also) be in a file named like ``alice.cert.0``.
154
155
156Enrolling a Storage Server: CLI
157-------------------------------
158
159
160tahoe admin add-grid-manager-cert
161`````````````````````````````````
162
163- `--filename`: the file to read the cert from
164- `--name`: the name of this certificate
165
166Import a "version 1" storage-certificate produced by a grid-manager A
167storage server may have zero or more such certificates installed; for
168now just one is sufficient. You will have to re-start your node after
169this. Subsequent announcements to the Introducer will include this
170certificate.
171
172.. note::
173
174   This command will simply edit the `tahoe.cfg` file and direct you
175   to re-start. In the Future(tm), we should consider (in exarkun's
176   words):
177
178       "A python program you run as a new process" might not be the
179       best abstraction to layer on top of the configuration
180       persistence system, though.  It's a nice abstraction for users
181       (although most users would probably rather have a GUI) but it's
182       not a great abstraction for automation.  So at some point it
183       may be better if there is CLI -> public API -> configuration
184       persistence system.  And maybe "public API" is even a network
185       API for the storage server so it's equally easy to access from
186       an agent implemented in essentially any language and maybe if
187       the API is exposed by the storage node itself then this also
188       gives you live-configuration-updates, avoiding the need for
189       node restarts (not that this is the only way to accomplish
190       this, but I think it's a good way because it avoids the need
191       for messes like inotify and it supports the notion that the
192       storage node process is in charge of its own configuration
193       persistence system, not just one consumer among many ... which
194       has some nice things going for it ... though how this interacts
195       exactly with further node management automation might bear
196       closer scrutiny).
197
198
199Enrolling a Storage Server: Config
200----------------------------------
201
202You may edit the ``[storage]`` section of the ``tahoe.cfg`` file to
203turn on grid-management with ``grid_management = true``. You then must
204also provide a ``[grid_management_certificates]`` section in the
205config-file which lists ``name = path/to/certificate`` pairs.
206
207These certificate files are issued by the ``grid-manager sign``
208command; these should be transmitted to the storage server operator
209who includes them in the config for the storage server. Relative paths
210are based from the node directory. Example::
211
212    [storage]
213    grid_management = true
214
215    [grid_management_certificates]
216    default = example_grid.cert
217
218This will cause us to give this certificate to any Introducers we
219connect to (and subsequently, the Introducer will give the certificate
220out to clients).
221
222
223Enrolling a Client: Config
224--------------------------
225
226You may instruct a Tahoe client to use only storage servers from given
227Grid Managers. If there are no such keys, any servers are used
228(but see https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3979).  If
229there are one or more keys, the client will only upload to a storage
230server that has a valid certificate (from any of the keys).
231
232To specify public-keys, add a ``[grid_managers]`` section to the
233config. This consists of ``name = value`` pairs where ``name`` is an
234arbitrary name and ``value`` is a public-key of a Grid
235Manager. Example::
236
237    [grid_managers]
238    example_grid = pub-v0-vqimc4s5eflwajttsofisp5st566dbq36xnpp4siz57ufdavpvlq
239
240See also https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3507 which
241proposes a command to edit the config.
242
243
244Example Setup of a New Managed Grid
245-----------------------------------
246
247This example creates an actual grid, but it's all just on one machine
248with different "node directories" and a separate tahoe process for
249each node. Usually of course each storage server would be on a
250separate computer.
251
252Note that we use the ``daemonize`` command in the following but that's
253only one way to handle "running a command in the background". You
254could instead run commands that start with ``daemonize ...`` in their
255own shell/terminal window or via something like ``systemd``
256
257We'll store our Grid Manager configuration on disk, in
258``./gm0``. To initialize this directory::
259
260    grid-manager --config ./gm0 create
261
262(If you already have a grid, you can :ref:`skip ahead <skip_ahead>`.)
263
264First of all, create an Introducer. Note that we actually have to run
265it briefly before it creates the "Introducer fURL" we want for the
266next steps::
267
268    tahoe create-introducer --listen=tcp --port=5555 --location=tcp:localhost:5555 ./introducer
269    daemonize tahoe -d introducer run
270
271Next, we attach a couple of storage nodes::
272
273    tahoe create-node --introducer $(cat introducer/private/introducer.furl) --nickname storage0 --webport 6001 --location tcp:localhost:6003 --port 6003 ./storage0
274    tahoe create-node --introducer $(cat introducer/private/introducer.furl) --nickname storage1 --webport 6101 --location tcp:localhost:6103 --port 6103 ./storage1
275    daemonize tahoe -d storage0 run
276    daemonize tahoe -d storage1 run
277
278.. _skip_ahead:
279
280We can now tell the Grid Manager about our new storage servers::
281
282    grid-manager --config ./gm0 add storage0 $(cat storage0/node.pubkey)
283    grid-manager --config ./gm0 add storage1 $(cat storage1/node.pubkey)
284
285To produce a new certificate for each node, we do this::
286
287    grid-manager --config ./gm0 sign storage0 > ./storage0/gridmanager.cert
288    grid-manager --config ./gm0 sign storage1 > ./storage1/gridmanager.cert
289
290Now, we want our storage servers to actually announce these
291certificates into the grid. We do this by adding some configuration
292(in ``tahoe.cfg``)::
293
294    [storage]
295    grid_management = true
296
297    [grid_manager_certificates]
298    default = gridmanager.cert
299
300Add the above bit to each node's ``tahoe.cfg`` and re-start the
301storage nodes. (Alternatively, use the ``tahoe add-grid-manager``
302command).
303
304Now try adding a new storage server ``storage2``. This client can join
305the grid just fine, and announce itself to the Introducer as providing
306storage::
307
308    tahoe create-node --introducer $(cat introducer/private/introducer.furl) --nickname storage2 --webport 6301 --location tcp:localhost:6303 --port 6303 ./storage2
309    daemonize tahoe -d storage2 run
310
311At this point any client will upload to any of these three
312storage-servers. Make a client "alice" and try!
313
314::
315
316    tahoe create-client --introducer $(cat introducer/private/introducer.furl) --nickname alice --webport 6401 --shares-total=3 --shares-needed=2 --shares-happy=3 ./alice
317    daemonize tahoe -d alice run
318    tahoe -d alice put README.rst  # prints out a read-cap
319    find storage2/storage/shares  # confirm storage2 has a share
320
321Now we want to make Alice only upload to the storage servers that the
322grid-manager has given certificates to (``storage0`` and
323``storage1``). We need the grid-manager's public key to put in Alice's
324configuration::
325
326    grid-manager --config ./gm0 public-identity
327
328Put the key printed out above into Alice's ``tahoe.cfg`` in section
329``client``::
330
331    [grid_managers]
332    example_name = pub-v0-vqimc4s5eflwajttsofisp5st566dbq36xnpp4siz57ufdavpvlq
333
334
335Now, re-start the "alice" client. Since we made Alice's parameters
336require 3 storage servers to be reachable (``--happy=3``), all their
337uploads should now fail (so ``tahoe put`` will fail) because they
338won't use storage2 and thus can't "achieve happiness".
339
340A proposal to expose more information about Grid Manager and
341certificate status in the Welcome page is discussed in
342https://tahoe-lafs.org/trac/tahoe-lafs/ticket/3506
Note: See TracBrowser for help on using the repository browser.