github.com/kotalco/kotal@v0.3.0/apis/bitcoin/v1alpha1/node.go (about)

     1  package v1alpha1
     2  
     3  import (
     4  	"github.com/kotalco/kotal/apis/shared"
     5  	metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
     6  )
     7  
     8  // BitcoinNetwork is Bitcoin network
     9  type BitcoinNetwork string
    10  
    11  // Bitcoin networks
    12  const (
    13  	Mainnet BitcoinNetwork = "mainnet"
    14  	Testnet BitcoinNetwork = "testnet"
    15  )
    16  
    17  // RPCUsers is JSON-RPC users credentials
    18  type RPCUser struct {
    19  	// Username is JSON-RPC username
    20  	Username string `json:"username"`
    21  	// PasswordSecretName is k8s secret name holding JSON-RPC user password
    22  	PasswordSecretName string `json:"passwordSecretName"`
    23  }
    24  
    25  // NodeSpec defines the desired state of Node
    26  type NodeSpec struct {
    27  	// Image is Bitcoin node client image
    28  	Image string `json:"image,omitempty"`
    29  	// ExtraArgs is extra arguments to pass down to the cli
    30  	ExtraArgs shared.ExtraArgs `json:"extraArgs,omitempty"`
    31  	// Replicas is number of replicas
    32  	// +kubebuilder:validation:Enum=0;1
    33  	Replicas *uint `json:"replicas,omitempty"`
    34  	// Network is Bitcoin network to join and sync
    35  	// +kubebuilder:validation:Enum=mainnet;testnet
    36  	Network BitcoinNetwork `json:"network"`
    37  	// Listen accepts connections from outside
    38  	Listen *bool `json:"listen,omitempty"`
    39  	// P2PPort is p2p communications port
    40  	P2PPort uint `json:"p2pPort,omitempty"`
    41  	// MaxConnections is maximum connections to peers
    42  	MaxConnections *uint `json:"maxConnections,omitempty"`
    43  	// RPC enables JSON-RPC server
    44  	RPC bool `json:"rpc,omitempty"`
    45  	// RPCPort is JSON-RPC server port
    46  	RPCPort uint `json:"rpcPort,omitempty"`
    47  	// RPCUsers is JSON-RPC users credentials
    48  	RPCUsers []RPCUser `json:"rpcUsers,omitempty"`
    49  	// RPCWhitelist is a list of whitelisted rpc method
    50  	// +listType=set
    51  	RPCWhitelist []string `json:"rpcWhitelist,omitempty"`
    52  	// Wallet load wallet and enables wallet RPC calls
    53  	Wallet bool `json:"wallet,omitempty"`
    54  	// TransactionIndex maintains a full tx index
    55  	TransactionIndex bool `json:"txIndex,omitempty"`
    56  	// CoinStatsIndex maintains coinstats index used by the gettxoutsetinfo RPC
    57  	CoinStatsIndex bool `json:"coinStatsIndex,omitempty"`
    58  	// ReIndex rebuild chain state and block index
    59  	ReIndex bool `json:"reIndex,omitempty"`
    60  	// Pruning allows pruneblockchain RPC to delete specific blocks
    61  	Pruning bool `json:"pruning,omitempty"`
    62  	// BlocksOnly rejects transactions from network peers
    63  	// https://bitcointalk.org/index.php?topic=1377345.0
    64  	BlocksOnly bool `json:"blocksOnly,omitempty"`
    65  	// DBCacheSize is database cache size
    66  	// +kubebuilder:validation:Minimum=4
    67  	// +kubebuilder:validation:Maximum=16384
    68  	DBCacheSize uint `json:"dbCacheSize,omitempty"`
    69  	// Resources is node compute and storage resources
    70  	shared.Resources `json:"resources,omitempty"`
    71  }
    72  
    73  // NodeStatus defines the observed state of Node
    74  type NodeStatus struct {
    75  	Client string `json:"client,omitempty"`
    76  }
    77  
    78  // +kubebuilder:object:root=true
    79  // +kubebuilder:subresource:status
    80  
    81  // Node is the Schema for the nodes API
    82  // +kubebuilder:printcolumn:name="Network",type=string,JSONPath=".spec.network"
    83  // +kubebuilder:printcolumn:name="Client",type=string,JSONPath=".status.client"
    84  type Node struct {
    85  	metav1.TypeMeta   `json:",inline"`
    86  	metav1.ObjectMeta `json:"metadata,omitempty"`
    87  
    88  	Spec   NodeSpec   `json:"spec,omitempty"`
    89  	Status NodeStatus `json:"status,omitempty"`
    90  }
    91  
    92  // +kubebuilder:object:root=true
    93  
    94  // NodeList contains a list of Node
    95  type NodeList struct {
    96  	metav1.TypeMeta `json:",inline"`
    97  	metav1.ListMeta `json:"metadata,omitempty"`
    98  	Items           []Node `json:"items"`
    99  }
   100  
   101  func init() {
   102  	SchemeBuilder.Register(&Node{}, &NodeList{})
   103  }