github.com/kotalco/kotal@v0.3.0/apis/polkadot/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  // SynchronizationMode is the blockchain synchronization mode
     9  // +kubebuilder:validation:Enum=fast;full
    10  type SynchronizationMode string
    11  
    12  // +kubebuilder:validation:Enum=auto;paritydb;rocksdb
    13  type DatabaseBackend string
    14  
    15  const (
    16  	//FastSynchronization is the fast synchronization mode
    17  	FastSynchronization SynchronizationMode = "fast"
    18  	//FullSynchronization is the full archival synchronization mode
    19  	FullSynchronization SynchronizationMode = "full"
    20  )
    21  
    22  const (
    23  	// Auto databse backend
    24  	Auto DatabaseBackend = "auto"
    25  	// ParityDB databse backend
    26  	ParityDB DatabaseBackend = "paritydb"
    27  	// RocksDB databse backend
    28  	RocksDB DatabaseBackend = "rocksdb"
    29  )
    30  
    31  // NodeSpec defines the desired state of Node
    32  type NodeSpec struct {
    33  	// Image is Polkadot 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 the polkadot network/chain to join
    41  	// +kubebuilder:validation:Enum=polkadot;kusama;rococo;westend
    42  	Network string `json:"network"`
    43  	// P2PPort is p2p protocol tcp port
    44  	P2PPort uint `json:"p2pPort,omitempty"`
    45  	// NodePrivateKeySecretName is the secret name holding node Ed25519 private key
    46  	NodePrivateKeySecretName string `json:"nodePrivateKeySecretName,omitempty"`
    47  	// Validator enables validator mode
    48  	Validator bool `json:"validator,omitempty"`
    49  	// SyncMode is the blockchain synchronization mode
    50  	SyncMode SynchronizationMode `json:"syncMode,omitempty"`
    51  	// Pruning keeps recent or all blocks
    52  	Pruning *bool `json:"pruning,omitempty"`
    53  	// RetainedBlocks is the number of blocks to keep state for
    54  	RetainedBlocks uint `json:"retainedBlocks,omitempty"`
    55  	// Database is database backend
    56  	Database DatabaseBackend `json:"database,omitempty"`
    57  	// Logging is logging verboisty level
    58  	// +kubebuilder:validation:Enum=error;warn;info;debug;trace
    59  	Logging shared.VerbosityLevel `json:"logging,omitempty"`
    60  	// Telemetry enables connecting to telemetry server
    61  	Telemetry bool `json:"telemetry,omitempty"`
    62  	// TelemetryURL is telemetry service URL
    63  	TelemetryURL string `json:"telemetryURL,omitempty"`
    64  	// Prometheus exposes a prometheus exporter endpoint.
    65  	Prometheus bool `json:"prometheus,omitempty"`
    66  	// PrometheusPort is prometheus exporter port
    67  	PrometheusPort uint `json:"prometheusPort,omitempty"`
    68  	// RPC enables JSON-RPC server
    69  	RPC bool `json:"rpc,omitempty"`
    70  	// RPCPort is JSON-RPC server port
    71  	RPCPort uint `json:"rpcPort,omitempty"`
    72  	// WS enables Websocket server
    73  	WS bool `json:"ws,omitempty"`
    74  	// WSPort is Websocket server port
    75  	WSPort uint `json:"wsPort,omitempty"`
    76  	// CORSDomains is browser origins allowed to access the JSON-RPC HTTP and WS servers
    77  	// +listType=set
    78  	CORSDomains []string `json:"corsDomains,omitempty"`
    79  	// Resources is node compute and storage resources
    80  	shared.Resources `json:"resources,omitempty"`
    81  }
    82  
    83  // NodeStatus defines the observed state of Node
    84  type NodeStatus struct {
    85  }
    86  
    87  // +kubebuilder:object:root=true
    88  // +kubebuilder:subresource:status
    89  
    90  // Node is the Schema for the nodes API
    91  // +kubebuilder:printcolumn:name="Network",type=string,JSONPath=".spec.network"
    92  // +kubebuilder:printcolumn:name="Validator",type=boolean,JSONPath=".spec.validator"
    93  type Node struct {
    94  	metav1.TypeMeta   `json:",inline"`
    95  	metav1.ObjectMeta `json:"metadata,omitempty"`
    96  
    97  	Spec   NodeSpec   `json:"spec,omitempty"`
    98  	Status NodeStatus `json:"status,omitempty"`
    99  }
   100  
   101  // +kubebuilder:object:root=true
   102  
   103  // NodeList contains a list of Node
   104  type NodeList struct {
   105  	metav1.TypeMeta `json:",inline"`
   106  	metav1.ListMeta `json:"metadata,omitempty"`
   107  	Items           []Node `json:"items"`
   108  }
   109  
   110  func init() {
   111  	SchemeBuilder.Register(&Node{}, &NodeList{})
   112  }