mirror of
https://github.com/hanzoai/nchain.git
synced 2026-10-30 18:27:22 +00:00
Single API deployment serves all brands via hostname-based routing.
Per-brand env vars use BRAND_{UPPER}_* format with ENABLE_MULTI_TENANT.
One API Ingress handles all api.*/ws.* domains; per-brand web Ingresses.
ClusterTarget type maps brands to K8s clusters for NodeCluster CR creation.
Also adds Solana, Bitcoin, Cosmos protocol drivers with recommended
hardware specs (RecommendedResources/RecommendedStorage on Driver interface).
56 lines
2.2 KiB
Go
56 lines
2.2 KiB
Go
package protocol
|
|
|
|
import (
|
|
corev1 "k8s.io/api/core/v1"
|
|
|
|
"github.com/hanzoai/nchain/api/v1alpha1"
|
|
)
|
|
|
|
// Driver encapsulates all protocol-specific logic for a blockchain node.
|
|
// Each supported blockchain implements this interface to generate the correct
|
|
// container commands, environment variables, volumes, health checks, and ports.
|
|
type Driver interface {
|
|
// Name returns the protocol identifier (e.g., "lux", "ethereum", "generic").
|
|
Name() string
|
|
|
|
// DefaultImage returns the default container image for this protocol.
|
|
DefaultImage() string
|
|
|
|
// BuildCommand generates the container command and args for the node.
|
|
BuildCommand(spec *v1alpha1.NodeClusterSpec) (command []string, args []string)
|
|
|
|
// BuildEnv generates protocol-specific environment variables.
|
|
BuildEnv(spec *v1alpha1.NodeClusterSpec) []corev1.EnvVar
|
|
|
|
// BuildVolumeMounts generates protocol-specific volume mounts.
|
|
BuildVolumeMounts(spec *v1alpha1.NodeClusterSpec) []corev1.VolumeMount
|
|
|
|
// BuildVolumes generates protocol-specific volumes.
|
|
BuildVolumes(spec *v1alpha1.NodeClusterSpec) []corev1.Volume
|
|
|
|
// HealthEndpoint returns the HTTP health check path and port.
|
|
HealthEndpoint(spec *v1alpha1.NodeClusterSpec) (path string, port int32)
|
|
|
|
// ReadinessEndpoint returns the HTTP readiness check path and port.
|
|
ReadinessEndpoint(spec *v1alpha1.NodeClusterSpec) (path string, port int32)
|
|
|
|
// DefaultPorts returns the default port configuration.
|
|
DefaultPorts() v1alpha1.PortConfig
|
|
|
|
// BuildInitContainers generates protocol-specific init containers.
|
|
BuildInitContainers(spec *v1alpha1.NodeClusterSpec) []corev1.Container
|
|
|
|
// NeedsConfigMap returns true if the protocol generates a ConfigMap.
|
|
NeedsConfigMap(spec *v1alpha1.NodeClusterSpec) bool
|
|
|
|
// BuildConfigMap generates protocol-specific ConfigMap data.
|
|
BuildConfigMap(spec *v1alpha1.NodeClusterSpec) map[string]string
|
|
|
|
// RecommendedResources returns the recommended K8s resource requirements for this protocol.
|
|
// Returns min (requests) and recommended (limits) for validator, fullnode, and archive roles.
|
|
RecommendedResources(role string) (requests, limits corev1.ResourceList)
|
|
|
|
// RecommendedStorage returns the recommended storage size for this protocol and role.
|
|
RecommendedStorage(role string) string
|
|
}
|