beekeeper
beekeeper copied to clipboard
feat(cmd): implement staking command
PR Description: Implement Staking Feature for Bee Nodes
Implements: #517
Overview
This PR implements a comprehensive staking feature for Beekeeper that allows users to manage BZZ stakes on Bee nodes through a centralized CLI interface. The feature supports both Kubernetes namespace targeting and Beekeeper cluster targeting with parallel execution and robust error handling.
Changes
- Added
beekeeper stake depositcommand to deposit BZZ stake on targeted Bee nodes - Added
beekeeper stake getcommand to retrieve current stake amounts from targeted nodes - Added
beekeeper stake withdrawcommand to withdraw (migrate) stake from targeted nodes - Implemented cluster mode targeting with
--cluster-nameflag - Implemented namespace mode targeting with
--namespaceand--label-selectorflags - Added node group filtering with
--node-groupsflag (defaults to "bee" nodes) - Added parallel execution support with
--parallelflag for better performance - Implemented comprehensive error handling with user-friendly messages
- Added proper K8s client initialization with
PreRunEfor namespace mode - Refactored code to eliminate duplication and improve maintainability
Usage Examples
# Deposit 1000 WEI stake on all bee nodes in a cluster
beekeeper stake deposit --amount 1000 --cluster-name local-dns
# Get current stake amounts from nodes in a namespace
beekeeper stake get --namespace local --label-selector app=bee
# Withdraw stake from specific node groups
beekeeper stake withdraw --cluster-name local-dns --node-groups bee,light
# Use parallel execution for better performance
beekeeper stake deposit --amount 5000 --cluster-name local-dns --parallel 10
Technical Details
- Uses existing
pkg/bee/api/stake.goAPI endpoints - Leverages
pkg/orchestrationfor cluster management - Integrates with
pkg/nodefor namespace-based discovery - Utilizes
math/bigfor precise WEI amount handling - Implements parallel processing with goroutines and channels
- Provides comprehensive input validation and error handling