Day 2
As we have created the IP pool and IP management now we are able to save the metadata in the metadata server but here we have to do the most important task for the node manager which is spinup a node as we hit on the register node API. for this we are going to use docker.
To achieve this functionality, we'll build a system where a Node Registration API spins up a new node dynamically, allocates IP addresses from a predefined IP pool, and updates the metadata storage. Here's the plan
Steps to Implement Node Registration with IP Allocation
Predefined IP Pool:
Maintain a list of available IPs in Redis (or a database table).
Ensure thread-safe allocation (e.g., using locks).
Node Spinning:
Use Docker SDK to programmatically spin up containers in the background.
Configure nodes with allocated IP addresses, ensuring the correct storage allocation.
Metadata Update:
Update PostgreSQL with:
Node ID
Allocated IP
Storage capacity
Status (e.g., running, healthy)
API Design:
Endpoint:
POST /register-node
Payload:
{ "storage_capacity": 100, "node_type": "worker" }
Response:
{ "node_id": "timebased_id", "ip": "192.168.0.5", "status": "registered" }
Error Handling:
Handle cases such as:
No available IPs.
Docker container failures.
Conflicts in database updates.
Last updated