github.com/kotalco/kotal@v0.3.0/apis/stacks/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  // StacksNetwork is Stacks network
     9  type StacksNetwork string
    10  
    11  const (
    12  	Mainnet StacksNetwork = "mainnet"
    13  	Testnet StacksNetwork = "testnet"
    14  	Xenon   StacksNetwork = "xenon"
    15  )
    16  
    17  // BitcoinNode is Bitcoin node
    18  type BitcoinNode struct {
    19  	// Endpoint is bitcoin node JSON-RPC endpoint
    20  	Endpoint string `json:"endpoint"`
    21  	// P2pPort is bitcoin node p2p port
    22  	P2pPort uint `json:"p2pPort"`
    23  	// RpcPort is bitcoin node JSON-RPC port
    24  	RpcPort uint `json:"rpcPort"`
    25  	// RpcUsername is bitcoin node JSON-RPC username
    26  	RpcUsername string `json:"rpcUsername"`
    27  	// RpcPasswordSecretName is k8s secret name holding bitcoin node JSON-RPC password
    28  	RpcPasswordSecretName string `json:"rpcPasswordSecretName"`
    29  }
    30  
    31  // NodeSpec defines the desired state of Node
    32  type NodeSpec struct {
    33  	// Image is Stacks node client image
    34  	Image string `json:"image,omitempty"`
    35  	// ExtraArgs is extra arguments to pass down to the cli
    36  	ExtraArgs shared.ExtraArgs `json:"extraArgs,omitempty"`
    37  	// Replicas is number of replicas
    38  	// +kubebuilder:validation:Enum=0;1
    39  	Replicas *uint `json:"replicas,omitempty"`
    40  	// Network is stacks network
    41  	// +kubebuilder:validation:Enum=mainnet;testnet;xenon
    42  	Network StacksNetwork `json:"network"`
    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  	// P2PPort is p2p bind port
    48  	P2PPort uint `json:"p2pPort,omitempty"`
    49  	// BitcoinNode is Bitcoin node
    50  	BitcoinNode BitcoinNode `json:"bitcoinNode"`
    51  	// Miner enables mining
    52  	Miner bool `json:"miner,omitempty"`
    53  	// SeedPrivateKeySecretName is k8s secret holding seed private key used for mining
    54  	SeedPrivateKeySecretName string `json:"seedPrivateKeySecretName,omitempty"`
    55  	// MineMicroblocks mines Stacks micro blocks
    56  	MineMicroblocks bool `json:"mineMicroblocks,omitempty"`
    57  	// NodePrivateKeySecretName is k8s secret holding node private key
    58  	NodePrivateKeySecretName string `json:"nodePrivateKeySecretName,omitempty"`
    59  	// Resources is node compute and storage resources
    60  	shared.Resources `json:"resources,omitempty"`
    61  }
    62  
    63  // NodeStatus defines the observed state of Node
    64  type NodeStatus struct {
    65  	Client string `json:"client,omitempty"`
    66  }
    67  
    68  // +kubebuilder:object:root=true
    69  // +kubebuilder:subresource:status
    70  
    71  // Node is the Schema for the nodes API
    72  // +kubebuilder:printcolumn:name="Network",type=string,JSONPath=".spec.network"
    73  // +kubebuilder:printcolumn:name="Client",type=string,JSONPath=".status.client"
    74  // +kubebuilder:printcolumn:name="Miner",type=boolean,JSONPath=".spec.miner"
    75  type Node struct {
    76  	metav1.TypeMeta   `json:",inline"`
    77  	metav1.ObjectMeta `json:"metadata,omitempty"`
    78  
    79  	Spec   NodeSpec   `json:"spec,omitempty"`
    80  	Status NodeStatus `json:"status,omitempty"`
    81  }
    82  
    83  // +kubebuilder:object:root=true
    84  
    85  // NodeList contains a list of Node
    86  type NodeList struct {
    87  	metav1.TypeMeta `json:",inline"`
    88  	metav1.ListMeta `json:"metadata,omitempty"`
    89  	Items           []Node `json:"items"`
    90  }
    91  
    92  func init() {
    93  	SchemeBuilder.Register(&Node{}, &NodeList{})
    94  }