Skip to content

Commit 85307ff

Browse files
docs: revise multiple nodes management tutorial to improve clarity and node designation
Update the 'Managing Multiple Nodes' tutorial to enhance readability and practical application. Rename 'nodeA' to 'nodeB' to align with Shell B designation, streamline environment configuration steps, and clarify the process of sharing vaults between nodes. These changes aim to simplify the tutorial's execution and improve its educational value for new Polykey users.
1 parent b0e2992 commit 85307ff

File tree

1 file changed

+130
-1
lines changed

1 file changed

+130
-1
lines changed
Lines changed: 130 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,130 @@
1-
# Managing Multiple Nodes
1+
# Managing Multiple Local Nodes
2+
3+
Managing multiple local
4+
5+
nodes in Polykey can serve various purposes. For example, you might maintain one node for personal projects and another for professional work. This segregation ensures that the vaults and their respective contents remain distinct based on their usage context.
6+
7+
This approach is particularly advantageous for demonstrations or training purposes, as it allows you to simulate sharing vaults between two nodes on the network without requiring another live user. It also enables a robust environment for testing node interactions and features in a controlled manner.
8+
9+
Each node in Polykey operates with its own dedicated agent, and nodes are stored locally with specified node paths. When you first initialize Polykey, a default node and its path are created. This default node path can be viewed by running specific Polykey commands, which we will cover. To manage multiple nodes effectively, each node you create will have its designated node path that directs all operations specifically to that node's environment.
10+
11+
## Understanding Node Paths
12+
13+
The default node, which you bootstrap when you first install Polykey, resides at a standard location on your file system. This location can be found using:
14+
15+
```bash
16+
polykey nodes --help
17+
```
18+
19+
For any additional nodes, such as nodeB, you will specify a new node path during their creation. This is critical because each node operates independently, requiring its unique path for all interactions:
20+
21+
```bash
22+
polykey agent start --node-path ./nodeB --background
23+
```
24+
25+
This command initializes a Polykey agent using the nodePath flag to specify the node we are starting an agent for. If unsure of the syntax to use for command operations, adding the --help at the end of each subcommand provides useful context.
26+
27+
:::note
28+
If a node has not been created before, initializing the Polykey agent for it will also initiate the bootstrap process.
29+
:::
30+
31+
When working with multiple nodes, specifying the node path in each command can become cumbersome. To streamline this process in your terminal shell session, you can set an environment variable for the node path, which we will demonstrate later.
32+
33+
## Steps to Manage Multiple Nodes Locally
34+
35+
### 1. Initialize Your Nodes
36+
37+
Open two terminal sessions (Shell A for your default node and Shell B for your new node that we will save a new path called nodeB). If you have not already started the Polykey agent for your default node, you can start it as follows:
38+
39+
**Shell A (default node):**
40+
41+
```bash
42+
polykey agent start --background
43+
```
44+
45+
This initializes your default node in the background. The command does not specify a node path, so it automatically targets the default node path.
46+
47+
**Shell B (for your new node, nodeB):**
48+
49+
```bash
50+
polykey agent super_start --node-path ./nodeB --background
51+
```
52+
53+
This command starts a new Polykey agent for nodeB in the background. The first time you run this, it will prompt you to set a password, just like bootstrapping any new node. Remember, each node operates with its dedicated agent, ensuring that their operations are isolated from each other.
54+
55+
### 2. Configure Node Environment
56+
57+
To avoid having to specify the node path for every command in a session:
58+
59+
#### **Export the environment variable in Shell B:**
60+
61+
```bash
62+
export PK_NODE_PATH='./nodeB'
63+
```
64+
65+
This sets the environment for nodeB in Shell B, allowing you to execute Polykey commands specific to nodeB without constantly adding the node-path flag.
66+
67+
### 3. Verify Node Status
68+
69+
In both shell sessions, check that each node is active:
70+
71+
```bash
72+
polykey agent status
73+
```
74+
75+
This command confirms the node's status and provides the nodeId, which is crucial for the next steps.
76+
77+
### 4. Node Discovery and Trust Establishment
78+
79+
Before sharing any vaults, both nodes need to discover each other and establish trust. Use the `nodeId` obtained from the status output:
80+
81+
#### **Shell A (default node):**
82+
83+
```bash
84+
polykey identities discover <nodeB_Id>
85+
polykey identities trust <nodeB_Id>
86+
```
87+
88+
#### **Shell B (nodeB):**
89+
90+
```bash
91+
polykey identities discover <default_nodeId>
92+
polykey identities trust <default_nodeId>
93+
```
94+
95+
### 5. Share a Vault from the Default Node to nodeB
96+
97+
Choose a vault to share, for example, `Weather-Ops`.
98+
99+
#### **Shell A (default node):**
100+
101+
```bash
102+
polykey vaults share Weather-Ops <nodeB_Id>
103+
```
104+
105+
### 6. Access the Shared Vault from nodeB
106+
107+
#### **Shell B (nodeB):**
108+
109+
```bash
110+
polykey vaults scan <default_nodeId>
111+
polykey vaults clone Weather-Ops <default_nodeId>
112+
```
113+
114+
These commands list and then clone the shared vault to nodeB's local storage.
115+
116+
### 7. Validate the Operation
117+
118+
Check that the vault is now available in nodeB:
119+
120+
#### **Shell B (nodeB):**
121+
122+
```bash
123+
polykey vaults list
124+
```
125+
126+
## Conclusion
127+
128+
This tutorial demonstrated how to set up and manage multiple local nodes using Polykey. You learned to initialize nodes, configure sessions, discover and trust other nodes, share vaults, and access shared resources. Such a setup is invaluable for developers managing separate environments for different projects or testing functionality without another user.
129+
130+
This approach not only streamlines the management of multiple nodes but also ensures that all operations are performed securely and efficiently within controlled environments.

0 commit comments

Comments
 (0)