golem-vm-provider 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- golem_vm_provider-0.1.0/PKG-INFO +398 -0
- golem_vm_provider-0.1.0/README.md +359 -0
- golem_vm_provider-0.1.0/provider/__init__.py +3 -0
- golem_vm_provider-0.1.0/provider/api/__init__.py +19 -0
- golem_vm_provider-0.1.0/provider/api/models.py +108 -0
- golem_vm_provider-0.1.0/provider/api/routes.py +159 -0
- golem_vm_provider-0.1.0/provider/config.py +160 -0
- golem_vm_provider-0.1.0/provider/discovery/__init__.py +6 -0
- golem_vm_provider-0.1.0/provider/discovery/advertiser.py +179 -0
- golem_vm_provider-0.1.0/provider/discovery/resource_tracker.py +152 -0
- golem_vm_provider-0.1.0/provider/main.py +125 -0
- golem_vm_provider-0.1.0/provider/network/port_verifier.py +287 -0
- golem_vm_provider-0.1.0/provider/security/ethereum.py +41 -0
- golem_vm_provider-0.1.0/provider/utils/ascii_art.py +79 -0
- golem_vm_provider-0.1.0/provider/utils/logging.py +82 -0
- golem_vm_provider-0.1.0/provider/utils/port_display.py +204 -0
- golem_vm_provider-0.1.0/provider/utils/retry.py +48 -0
- golem_vm_provider-0.1.0/provider/vm/__init__.py +31 -0
- golem_vm_provider-0.1.0/provider/vm/cloud_init.py +67 -0
- golem_vm_provider-0.1.0/provider/vm/models.py +205 -0
- golem_vm_provider-0.1.0/provider/vm/multipass.py +427 -0
- golem_vm_provider-0.1.0/provider/vm/name_mapper.py +108 -0
- golem_vm_provider-0.1.0/provider/vm/port_manager.py +196 -0
- golem_vm_provider-0.1.0/provider/vm/proxy_manager.py +239 -0
- golem_vm_provider-0.1.0/pyproject.toml +63 -0
@@ -0,0 +1,398 @@
|
|
1
|
+
Metadata-Version: 2.1
|
2
|
+
Name: golem-vm-provider
|
3
|
+
Version: 0.1.0
|
4
|
+
Summary: VM on Golem Provider Node - Run your own provider node to offer VMs on the Golem Network
|
5
|
+
Home-page: https://github.com/cryptobench/vm-on-golem
|
6
|
+
Keywords: golem,vm,provider,cloud,decentralized
|
7
|
+
Author: Phillip Jensen
|
8
|
+
Author-email: phillip+vm-on-golem@golemgrid.com
|
9
|
+
Requires-Python: >=3.9,<4.0
|
10
|
+
Classifier: Development Status :: 4 - Beta
|
11
|
+
Classifier: Environment :: Console
|
12
|
+
Classifier: Intended Audience :: System Administrators
|
13
|
+
Classifier: Operating System :: POSIX :: Linux
|
14
|
+
Classifier: Programming Language :: Python :: 3
|
15
|
+
Classifier: Programming Language :: Python :: 3.9
|
16
|
+
Classifier: Programming Language :: Python :: 3.10
|
17
|
+
Classifier: Programming Language :: Python :: 3.11
|
18
|
+
Classifier: Programming Language :: Python :: 3.12
|
19
|
+
Classifier: Programming Language :: Python :: 3.13
|
20
|
+
Classifier: Topic :: System :: Distributed Computing
|
21
|
+
Requires-Dist: aiohttp (>=3.8.1,<4.0.0)
|
22
|
+
Requires-Dist: colorlog (>=6.8.0,<7.0.0)
|
23
|
+
Requires-Dist: cryptography (>=3.4.7,<4.0.0)
|
24
|
+
Requires-Dist: eth-account (>=0.8.0,<0.9.0)
|
25
|
+
Requires-Dist: fastapi (>=0.68.0,<0.69.0)
|
26
|
+
Requires-Dist: psutil (>=5.9.0,<6.0.0)
|
27
|
+
Requires-Dist: pydantic (>=1.8.2,<2.0.0)
|
28
|
+
Requires-Dist: python-dotenv (>=1.0.0,<2.0.0)
|
29
|
+
Requires-Dist: python-jose[cryptography] (>=3.3.0,<4.0.0)
|
30
|
+
Requires-Dist: python-multipart (>=0.0.5,<0.0.6)
|
31
|
+
Requires-Dist: pyyaml (>=6.0.1,<7.0.0)
|
32
|
+
Requires-Dist: requests (>=2.31.0,<3.0.0)
|
33
|
+
Requires-Dist: rich (>=13.7.0,<14.0.0)
|
34
|
+
Requires-Dist: setuptools (>=69.0.3,<70.0.0)
|
35
|
+
Requires-Dist: uvicorn (>=0.15.0,<0.16.0)
|
36
|
+
Project-URL: Repository, https://github.com/cryptobench/vm-on-golem
|
37
|
+
Description-Content-Type: text/markdown
|
38
|
+
|
39
|
+
# VM on Golem Provider Node
|
40
|
+
|
41
|
+
The Provider Node enables participation in the Golem Network by managing virtual machines and computing resources. It handles VM lifecycle management, resource allocation, network proxying, and automated discovery advertisement.
|
42
|
+
|
43
|
+
## System Architecture
|
44
|
+
|
45
|
+
```mermaid
|
46
|
+
graph TB
|
47
|
+
API[FastAPI Service] --> VMM[VM Manager]
|
48
|
+
API --> RT[Resource Tracker]
|
49
|
+
API --> PV[Port Verifier]
|
50
|
+
VMM --> MP[Multipass Provider]
|
51
|
+
VMM --> PM[Proxy Manager]
|
52
|
+
RT --> RM[Resource Monitor]
|
53
|
+
RT --> AD[Resource Advertiser]
|
54
|
+
AD --> DS[Discovery Service]
|
55
|
+
PM --> SSH[SSH Proxy]
|
56
|
+
PV --> PM
|
57
|
+
MP --> VM1[VM 1]
|
58
|
+
MP --> VM2[VM 2]
|
59
|
+
```
|
60
|
+
|
61
|
+
The Provider Node implements a clean, modular architecture where each component handles a specific responsibility:
|
62
|
+
|
63
|
+
## Core Components
|
64
|
+
|
65
|
+
### Port Verification
|
66
|
+
|
67
|
+
The port verification system ensures proper network connectivity:
|
68
|
+
|
69
|
+
```mermaid
|
70
|
+
sequenceDiagram
|
71
|
+
participant S as Startup
|
72
|
+
participant PV as Port Verifier
|
73
|
+
participant PM as Port Manager
|
74
|
+
participant D as Display
|
75
|
+
|
76
|
+
S->>PV: Initialize
|
77
|
+
PV->>PV: Check Local Ports
|
78
|
+
PV->>PV: Verify External Access
|
79
|
+
PV->>D: Update Status
|
80
|
+
D-->>S: Show Progress
|
81
|
+
PV->>PM: Register Verified Ports
|
82
|
+
PM-->>S: Verification Result
|
83
|
+
```
|
84
|
+
|
85
|
+
- Comprehensive port accessibility verification
|
86
|
+
- Real-time status display with progress indicators
|
87
|
+
- Local and external port validation
|
88
|
+
- Automatic port allocation management
|
89
|
+
|
90
|
+
### Future Developments
|
91
|
+
|
92
|
+
The current port verification system uses dedicated port check servers to verify external accessibility. In future releases, this functionality will be integrated into the Golem Network's verifier nodes, providing:
|
93
|
+
|
94
|
+
- Decentralized port verification through the network
|
95
|
+
- Increased reliability with multiple verification sources
|
96
|
+
- Consensus-based verification results
|
97
|
+
- Reduced dependency on centralized services
|
98
|
+
- Enhanced security through the network's trust system
|
99
|
+
|
100
|
+
This integration aligns with Golem's vision of a fully decentralized computing platform, moving critical infrastructure services like port verification into the network itself.
|
101
|
+
|
102
|
+
### Resource Management
|
103
|
+
|
104
|
+
The resource management system ensures optimal allocation and utilization of system resources:
|
105
|
+
|
106
|
+
- Real-time monitoring of CPU, memory, and storage
|
107
|
+
- Intelligent resource allocation with minimum requirement enforcement
|
108
|
+
- Threshold-based resource protection
|
109
|
+
- Automatic resource reclamation
|
110
|
+
|
111
|
+
```mermaid
|
112
|
+
sequenceDiagram
|
113
|
+
participant API as API
|
114
|
+
participant RT as Resource Tracker
|
115
|
+
participant RM as Resource Monitor
|
116
|
+
participant AD as Advertiser
|
117
|
+
|
118
|
+
API->>RT: Request Resource Allocation
|
119
|
+
RT->>RM: Check Available Resources
|
120
|
+
RM-->>RT: Resource Status
|
121
|
+
RT->>RT: Validate Requirements
|
122
|
+
RT-->>API: Allocation Result
|
123
|
+
RT->>AD: Notify Resource Update
|
124
|
+
AD->>DS: Update Advertisement
|
125
|
+
```
|
126
|
+
|
127
|
+
### VM Management
|
128
|
+
|
129
|
+
VM operations are handled through Multipass integration:
|
130
|
+
|
131
|
+
```mermaid
|
132
|
+
sequenceDiagram
|
133
|
+
participant API as API
|
134
|
+
participant MP as Multipass
|
135
|
+
participant CI as Cloud Init
|
136
|
+
participant VM as Virtual Machine
|
137
|
+
|
138
|
+
API->>MP: Create VM Request
|
139
|
+
MP->>CI: Generate Config
|
140
|
+
CI-->>MP: SSH Configuration
|
141
|
+
MP->>VM: Launch Instance
|
142
|
+
VM-->>MP: Status Update
|
143
|
+
MP-->>API: VM Info
|
144
|
+
```
|
145
|
+
|
146
|
+
- Automated VM provisioning with cloud-init
|
147
|
+
- Secure SSH key management
|
148
|
+
- Status monitoring and health checks
|
149
|
+
- Automatic cleanup procedures
|
150
|
+
|
151
|
+
### Network Proxy System
|
152
|
+
|
153
|
+
A pure Python implementation manages SSH connections:
|
154
|
+
|
155
|
+
```mermaid
|
156
|
+
sequenceDiagram
|
157
|
+
participant C as Client
|
158
|
+
participant PM as Proxy Manager
|
159
|
+
participant P as Proxy
|
160
|
+
participant VM as Virtual Machine
|
161
|
+
|
162
|
+
C->>PM: SSH Connection
|
163
|
+
PM->>P: Create Proxy
|
164
|
+
P->>VM: Forward Connection
|
165
|
+
VM-->>P: Response
|
166
|
+
P-->>C: Forward Response
|
167
|
+
```
|
168
|
+
|
169
|
+
- Dynamic port allocation and management
|
170
|
+
- Connection state persistence
|
171
|
+
- Clean connection handling
|
172
|
+
- Automatic proxy cleanup
|
173
|
+
|
174
|
+
## Installation
|
175
|
+
|
176
|
+
1. Prerequisites:
|
177
|
+
- Python 3.9+
|
178
|
+
- Multipass
|
179
|
+
- Poetry
|
180
|
+
|
181
|
+
2. Install dependencies:
|
182
|
+
```bash
|
183
|
+
cd provider-server
|
184
|
+
poetry install
|
185
|
+
```
|
186
|
+
|
187
|
+
3. Configure environment:
|
188
|
+
```bash
|
189
|
+
cp .env.example .env
|
190
|
+
# Edit .env with your settings
|
191
|
+
```
|
192
|
+
|
193
|
+
## Configuration
|
194
|
+
|
195
|
+
Key configuration options in `.env`:
|
196
|
+
|
197
|
+
```bash
|
198
|
+
# Provider Settings
|
199
|
+
GOLEM_PROVIDER_ID="your-provider-id"
|
200
|
+
GOLEM_PROVIDER_NAME="your-provider-name"
|
201
|
+
GOLEM_PROVIDER_COUNTRY="SE"
|
202
|
+
|
203
|
+
# Resource Limits
|
204
|
+
GOLEM_PROVIDER_MAX_VMS=10
|
205
|
+
GOLEM_PROVIDER_MIN_CPU_CORES=1
|
206
|
+
GOLEM_PROVIDER_MIN_MEMORY_GB=1
|
207
|
+
GOLEM_PROVIDER_MIN_STORAGE_GB=10
|
208
|
+
|
209
|
+
# Port Verification Settings
|
210
|
+
GOLEM_PROVIDER_PORT={provider_port} # Default: 7466
|
211
|
+
GOLEM_PROVIDER_PORT_CHECK_SERVERS=[
|
212
|
+
"https://ports1.golem.network",
|
213
|
+
"https://ports2.golem.network"
|
214
|
+
]
|
215
|
+
|
216
|
+
# Network Settings
|
217
|
+
GOLEM_PROVIDER_PORT_RANGE_START={start_port} # Default: 50800
|
218
|
+
GOLEM_PROVIDER_PORT_RANGE_END={end_port} # Default: 50900
|
219
|
+
GOLEM_PROVIDER_PUBLIC_IP="auto"
|
220
|
+
|
221
|
+
# Discovery Settings
|
222
|
+
GOLEM_PROVIDER_DISCOVERY_URL="http://discovery.golem.network:7465"
|
223
|
+
GOLEM_PROVIDER_ADVERTISEMENT_INTERVAL=240
|
224
|
+
```
|
225
|
+
|
226
|
+
## API Reference
|
227
|
+
|
228
|
+
### Create VM
|
229
|
+
|
230
|
+
```bash
|
231
|
+
POST /api/v1/vms
|
232
|
+
```
|
233
|
+
|
234
|
+
Request:
|
235
|
+
```json
|
236
|
+
{
|
237
|
+
"name": "my-webserver",
|
238
|
+
"cpu_cores": 2,
|
239
|
+
"memory_gb": 4,
|
240
|
+
"storage_gb": 20
|
241
|
+
}
|
242
|
+
```
|
243
|
+
|
244
|
+
Response:
|
245
|
+
```json
|
246
|
+
{
|
247
|
+
"id": "golem-my-webserver-20250219-130424",
|
248
|
+
"name": "my-webserver",
|
249
|
+
"status": "running",
|
250
|
+
"ip_address": "192.168.64.2",
|
251
|
+
"ssh_port": 50800,
|
252
|
+
"resources": {
|
253
|
+
"cpu": 2,
|
254
|
+
"memory": 4,
|
255
|
+
"storage": 20
|
256
|
+
}
|
257
|
+
}
|
258
|
+
```
|
259
|
+
|
260
|
+
### VM Operations
|
261
|
+
|
262
|
+
- List VMs: `GET /api/v1/vms`
|
263
|
+
- Get VM Status: `GET /api/v1/vms/{vm_id}`
|
264
|
+
- Delete VM: `DELETE /api/v1/vms/{vm_id}`
|
265
|
+
- Get Access Info: `GET /api/v1/vms/{vm_id}/access`
|
266
|
+
|
267
|
+
## Operations
|
268
|
+
|
269
|
+
### Starting the Provider
|
270
|
+
|
271
|
+
```bash
|
272
|
+
poetry run python run.py
|
273
|
+
```
|
274
|
+
|
275
|
+
The provider will:
|
276
|
+
1. Verify port accessibility
|
277
|
+
- Check discovery port (7466)
|
278
|
+
- Verify SSH ports (50800-50900)
|
279
|
+
- Display verification progress
|
280
|
+
2. Initialize resource monitoring
|
281
|
+
3. Start the proxy manager
|
282
|
+
4. Begin resource advertisement
|
283
|
+
5. Listen for VM requests
|
284
|
+
|
285
|
+
### Resource Advertisement Flow
|
286
|
+
|
287
|
+
```mermaid
|
288
|
+
sequenceDiagram
|
289
|
+
participant P as Provider
|
290
|
+
participant RT as Resource Tracker
|
291
|
+
participant AD as Advertiser
|
292
|
+
participant DS as Discovery Service
|
293
|
+
|
294
|
+
P->>RT: Initialize
|
295
|
+
RT->>AD: Register Callback
|
296
|
+
loop Every 4 minutes
|
297
|
+
AD->>RT: Get Resources
|
298
|
+
RT-->>AD: Available Resources
|
299
|
+
AD->>DS: Post Advertisement
|
300
|
+
DS-->>AD: Confirmation
|
301
|
+
end
|
302
|
+
```
|
303
|
+
|
304
|
+
### Monitoring
|
305
|
+
|
306
|
+
The provider includes comprehensive logging:
|
307
|
+
- Resource allocation events
|
308
|
+
- VM lifecycle changes
|
309
|
+
- Network proxy operations
|
310
|
+
- Discovery service interactions
|
311
|
+
|
312
|
+
## Technical Details
|
313
|
+
|
314
|
+
### Security
|
315
|
+
|
316
|
+
- Resource isolation through Multipass
|
317
|
+
- Secure SSH key provisioning
|
318
|
+
- Connection proxying for network isolation
|
319
|
+
- Rate limiting on API endpoints
|
320
|
+
|
321
|
+
### Performance
|
322
|
+
|
323
|
+
- Asynchronous operations with FastAPI
|
324
|
+
- Efficient resource tracking
|
325
|
+
- Connection pooling for proxy servers
|
326
|
+
- Optimized VM provisioning
|
327
|
+
|
328
|
+
### Resource Protection
|
329
|
+
|
330
|
+
- CPU threshold: 90%
|
331
|
+
- Memory threshold: 85%
|
332
|
+
- Storage threshold: 90%
|
333
|
+
- Minimum resource guarantees
|
334
|
+
|
335
|
+
## Troubleshooting
|
336
|
+
|
337
|
+
Common issues and solutions:
|
338
|
+
|
339
|
+
### Port Verification Issues
|
340
|
+
|
341
|
+
1. Provider Port ({provider_port}) Issues
|
342
|
+
- Check if port is already in use
|
343
|
+
- Verify port forwarding on router
|
344
|
+
- Check firewall rules
|
345
|
+
- Ensure provider is accessible to requestors
|
346
|
+
|
347
|
+
2. VM Access Port Range ({start_port}-{end_port}) Issues
|
348
|
+
- Verify port range availability
|
349
|
+
- Check for port conflicts
|
350
|
+
- Configure router port forwarding
|
351
|
+
- Review firewall settings for range
|
352
|
+
|
353
|
+
3. External Access Issues
|
354
|
+
- Verify internet connectivity
|
355
|
+
- Check port check servers are accessible
|
356
|
+
- Review router NAT/firewall settings
|
357
|
+
- Consider using alternative port check servers
|
358
|
+
|
359
|
+
### Port Verification Monitoring
|
360
|
+
|
361
|
+
The provider includes real-time port verification status:
|
362
|
+
- Visual progress indicators
|
363
|
+
- Port accessibility status
|
364
|
+
- Critical issues detection
|
365
|
+
- Quick fix suggestions
|
366
|
+
- Links to troubleshooting documentation
|
367
|
+
|
368
|
+
Example status output:
|
369
|
+
```bash
|
370
|
+
🌟 Port Verification Status
|
371
|
+
==========================
|
372
|
+
[✅] Provider Port {provider_port}: External ✓ | Internal ✓
|
373
|
+
[✅] VM Access Ports: 3 ports available ({start_port}-{start_port+2})
|
374
|
+
[✅] Overall Status: Provider Ready
|
375
|
+
└─ Can handle up to {n} concurrent VMs
|
376
|
+
```
|
377
|
+
|
378
|
+
### Resource Allocation Issues
|
379
|
+
- Check system resource availability
|
380
|
+
- Verify minimum requirements
|
381
|
+
- Monitor resource thresholds
|
382
|
+
- Review resource allocation logs
|
383
|
+
|
384
|
+
### Discovery Service Issues
|
385
|
+
- Check network connectivity
|
386
|
+
- Verify discovery service URL
|
387
|
+
- Check advertisement interval
|
388
|
+
- Monitor advertisement responses
|
389
|
+
- Verify provider registration status
|
390
|
+
|
391
|
+
## Contributing
|
392
|
+
|
393
|
+
1. Fork the repository
|
394
|
+
2. Create a feature branch
|
395
|
+
3. Make your changes
|
396
|
+
4. Run the tests
|
397
|
+
5. Submit a pull request
|
398
|
+
|