Skip to content

Commit

Permalink
Merge pull request #93 from Chia-Network/service-configuration
Browse files Browse the repository at this point in the history
Add more granular Services and config
  • Loading branch information
Starttoaster committed Jun 20, 2024
2 parents c406bbb + ca33e03 commit 9724489
Show file tree
Hide file tree
Showing 50 changed files with 3,215 additions and 809 deletions.
45 changes: 35 additions & 10 deletions api/v1/chiacommon_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,6 @@ type CommonSpec struct {
// +optional
Storage *StorageConfig `json:"storage,omitempty"`

// ServiceType is the type of the service that governs this ChiaNode StatefulSet.
// +optional
// +kubebuilder:default="ClusterIP"
ServiceType string `json:"serviceType,omitempty"`

// ImagePullPolicy is the pull policy for containers in the pod
// +optional
// +kubebuilder:default="Always"
Expand Down Expand Up @@ -59,9 +54,6 @@ type CommonSpecChia struct {
// +optional
Image string `json:"image,omitempty"`

// CASecretName is the name of the secret that contains the CA crt and key.
CASecretName string `json:"caSecretName"`

// Testnet is set to true if the Chia container should switch to the latest default testnet's settings
// +optional
Testnet *bool `json:"testnet,omitempty"`
Expand Down Expand Up @@ -92,6 +84,24 @@ type CommonSpecChia struct {
// +optional
LogLevel *string `json:"logLevel,omitempty"`

// PeerService defines settings for the default Service installed with any Chia component resource.
// This Service usually contains ports for peer connections, or in the case of seeders port 53.
// This Service will default to being enabled with a ClusterIP Service type.
// +optional
PeerService *Service `json:"peerService,omitempty"`

// DaemonService defines settings for the daemon Service installed with any Chia component resource.
// This Service usually contains the port for the Chia daemon that runs alongside any Chia instance.
// This Service will default to being enabled with a ClusterIP Service type.
// +optional
DaemonService *Service `json:"daemonService,omitempty"`

// RPCService defines settings for the RPC Service installed with any Chia component resource.
// This Service contains the port for the Chia RPC API.
// This Service will default to being enabled with a ClusterIP Service type.
// +optional
RPCService *Service `json:"rpcService,omitempty"`

// Periodic probe of container liveness.
// +optional
LivenessProbe *corev1.Probe `json:"livenessProbe,omitempty"`
Expand Down Expand Up @@ -125,9 +135,11 @@ type SpecChiaExporter struct {
// +optional
Image string `json:"image,omitempty"`

// Labels is a map of string keys and values to attach to the chia exporter k8s Service
// Service defines settings for the Service installed with any chia-exporter resource.
// This Service contains the port for chia-exporter's web exporter.
// This Service will default to being enabled with a ClusterIP Service type if chia-exporter is enabled.
// +optional
ServiceLabels map[string]string `json:"serviceLabels,omitempty"`
Service *Service `json:"service,omitempty"`
}

// ChiaSecretKey defines the name of a kubernetes secret and key in that namespace that contains the Chia mnemonic
Expand Down Expand Up @@ -181,6 +193,19 @@ type StorageConfig struct {
Plots *PlotsConfig `json:"plots,omitempty"`
}

// Service contains kubernetes Service related configuration options
type Service struct {
AdditionalMetadata `json:",inline"`

// Enabled is a boolean selector for a Service if it should be generated.
// +optional
Enabled *bool `json:"enabled,omitempty"`

// ServiceType is the Type of the Service. Defaults to ClusterIP
// +optional
ServiceType *corev1.ServiceType `json:"type,omitempty"`
}

// ChiaRootConfig optional config for CHIA_ROOT persistent storage, likely only needed for Chia full_nodes, but may help in startup time for other components.
// Both options may be specified but only one can be used, therefore PersistentVolumeClaims will be respected over HostPath volumes if both are specified.
type ChiaRootConfig struct {
Expand Down
8 changes: 8 additions & 0 deletions api/v1/chiafarmer_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Copyright 2023 Chia Network Inc.
package v1

import (
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -14,12 +15,19 @@ type ChiaFarmerSpec struct {

// ChiaConfig defines the configuration options available to Chia component containers
ChiaConfig ChiaFarmerSpecChia `json:"chia"`

// Strategy describes how to replace existing pods with new ones.
// +optional
Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"`
}

// ChiaFarmerSpecChia defines the desired state of Chia component configuration
type ChiaFarmerSpecChia struct {
CommonSpecChia `json:",inline"`

// CASecretName is the name of the secret that contains the CA crt and key. Not required for seeders.
CASecretName string `json:"caSecretName"`

// SecretKey defines the k8s Secret name and key for a Chia mnemonic
SecretKey ChiaSecretKey `json:"secretKey"`

Expand Down
5 changes: 1 addition & 4 deletions api/v1/chiafarmer_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,6 @@ spec:
Spec: ChiaFarmerSpec{
ChiaConfig: ChiaFarmerSpecChia{
CommonSpecChia: CommonSpecChia{
CASecretName: "chiaca-secret",
Testnet: &testnet,
Timezone: &timezone,
LogLevel: &logLevel,
Expand All @@ -78,6 +77,7 @@ spec:
IntroducerAddress: &introducerAddress,
DNSIntroducerAddress: &dnsIntroducerAddress,
},
CASecretName: "chiaca-secret",
FullNodePeer: "node.default.svc.cluster.local:58444",
SecretKey: ChiaSecretKey{
Name: "chiakey-secret",
Expand All @@ -87,9 +87,6 @@ spec:
CommonSpec: CommonSpec{
ChiaExporterConfig: SpecChiaExporter{
Enabled: true,
ServiceLabels: map[string]string{
"network": "testnet",
},
},
},
},
Expand Down
8 changes: 8 additions & 0 deletions api/v1/chiaharvester_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Copyright 2023 Chia Network Inc.
package v1

import (
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -14,12 +15,19 @@ type ChiaHarvesterSpec struct {

// ChiaConfig defines the configuration options available to Chia component containers
ChiaConfig ChiaHarvesterSpecChia `json:"chia"`

// Strategy describes how to replace existing pods with new ones.
// +optional
Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"`
}

// ChiaHarvesterSpecChia defines the desired state of Chia component configuration
type ChiaHarvesterSpecChia struct {
CommonSpecChia `json:",inline"`

// CASecretName is the name of the secret that contains the CA crt and key. Not required for seeders.
CASecretName string `json:"caSecretName"`

// FarmerAddress defines the harvester's farmer peer's hostname. The farmer's port is inferred.
// In Kubernetes this is likely to be <farmer service name>.<namespace>.svc.cluster.local
FarmerAddress string `json:"farmerAddress"`
Expand Down
5 changes: 1 addition & 4 deletions api/v1/chiaharvester_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ spec:
Spec: ChiaHarvesterSpec{
ChiaConfig: ChiaHarvesterSpecChia{
CommonSpecChia: CommonSpecChia{
CASecretName: "chiaca-secret",
Testnet: &testnet,
Network: &network,
NetworkPort: &networkPort,
Expand All @@ -75,14 +74,12 @@ spec:
Timezone: &timezone,
LogLevel: &logLevel,
},
CASecretName: "chiaca-secret",
FarmerAddress: "farmer.default.svc.cluster.local:58444",
},
CommonSpec: CommonSpec{
ChiaExporterConfig: SpecChiaExporter{
Enabled: true,
ServiceLabels: map[string]string{
"network": "testnet",
},
},
},
},
Expand Down
8 changes: 8 additions & 0 deletions api/v1/chianode_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Copyright 2023 Chia Network Inc.
package v1

import (
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -19,12 +20,19 @@ type ChiaNodeSpec struct {
// +optional
// +kubebuilder:default=1
Replicas int32 `json:"replicas,omitempty"`

// UpdateStrategy indicates the strategy that the StatefulSet controller will use to perform updates.
// +optional
UpdateStrategy *appsv1.StatefulSetUpdateStrategy `json:"updateStrategy,omitempty"`
}

// ChiaNodeSpecChia defines the desired state of Chia component configuration
type ChiaNodeSpecChia struct {
CommonSpecChia `json:",inline"`

// CASecretName is the name of the secret that contains the CA crt and key. Not required for seeders.
CASecretName string `json:"caSecretName"`

// TrustedCIDRs is a list of CIDRs that this chia component should trust peers from
// See: https://docs.chia.net/faq/?_highlight=trust#what-are-trusted-peers-and-how-do-i-add-them
// +optional
Expand Down
5 changes: 1 addition & 4 deletions api/v1/chianode_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,6 @@ spec:
Spec: ChiaNodeSpec{
ChiaConfig: ChiaNodeSpecChia{
CommonSpecChia: CommonSpecChia{
CASecretName: "chiaca-secret",
Testnet: &testnet,
Network: &network,
NetworkPort: &networkPort,
Expand All @@ -81,14 +80,12 @@ spec:
Timezone: &timezone,
LogLevel: &logLevel,
},
CASecretName: "chiaca-secret",
TrustedCIDRs: &expectCIDRs,
},
CommonSpec: CommonSpec{
ChiaExporterConfig: SpecChiaExporter{
Enabled: true,
ServiceLabels: map[string]string{
"network": "testnet",
},
},
},
},
Expand Down
8 changes: 8 additions & 0 deletions api/v1/chiaseeder_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Copyright 2023 Chia Network Inc.
package v1

import (
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -14,6 +15,10 @@ type ChiaSeederSpec struct {

// ChiaConfig defines the configuration options available to Chia component containers
ChiaConfig ChiaSeederSpecChia `json:"chia"`

// Strategy describes how to replace existing pods with new ones.
// +optional
Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"`
}

// ChiaSeederSpecChia defines the desired state of Chia component configuration
Expand All @@ -37,6 +42,9 @@ type ChiaSeederSpecChia struct {
// Rname an administrator's email address with '@' replaced with '.'
Rname string `json:"rname"`

// CASecretName is the name of the secret that contains the CA crt and key. Not required for seeders.
CASecretName *string `json:"caSecretName"`

// TTL field on DNS records that controls the length of time that a record is considered valid
// +optional
TTL *uint32 `json:"ttl"`
Expand Down
6 changes: 2 additions & 4 deletions api/v1/chiaseeder_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ spec:
domainName = "seeder.example.com."
nameserver = "example.com."
rname = "admin.example.com."
caSecret = "chiaca-secret"
)
expect := ChiaSeeder{
TypeMeta: metav1.TypeMeta{
Expand All @@ -75,7 +76,6 @@ spec:
Spec: ChiaSeederSpec{
ChiaConfig: ChiaSeederSpecChia{
CommonSpecChia: CommonSpecChia{
CASecretName: "chiaca-secret",
Testnet: &testnet,
Network: &network,
NetworkPort: &networkPort,
Expand All @@ -84,6 +84,7 @@ spec:
Timezone: &timezone,
LogLevel: &logLevel,
},
CASecretName: &caSecret,
BootstrapPeer: &bootstrapPeer,
MinimumHeight: &minimumHeight,
DomainName: domainName,
Expand All @@ -93,9 +94,6 @@ spec:
CommonSpec: CommonSpec{
ChiaExporterConfig: SpecChiaExporter{
Enabled: true,
ServiceLabels: map[string]string{
"network": "testnet",
},
},
},
},
Expand Down
8 changes: 8 additions & 0 deletions api/v1/chiatimelord_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Copyright 2023 Chia Network Inc.
package v1

import (
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -14,12 +15,19 @@ type ChiaTimelordSpec struct {

// ChiaConfig defines the configuration options available to Chia component containers
ChiaConfig ChiaTimelordSpecChia `json:"chia"`

// Strategy describes how to replace existing pods with new ones.
// +optional
Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"`
}

// ChiaTimelordSpecChia defines the desired state of Chia component configuration
type ChiaTimelordSpecChia struct {
CommonSpecChia `json:",inline"`

// CASecretName is the name of the secret that contains the CA crt and key. Not required for seeders.
CASecretName string `json:"caSecretName"`

// FullNodePeer defines the timelord's full_node peer in host:port format.
// In Kubernetes this is likely to be <node service name>.<namespace>.svc.cluster.local:8555
FullNodePeer string `json:"fullNodePeer"`
Expand Down
5 changes: 1 addition & 4 deletions api/v1/chiatimelord_types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,6 @@ spec:
Spec: ChiaTimelordSpec{
ChiaConfig: ChiaTimelordSpecChia{
CommonSpecChia: CommonSpecChia{
CASecretName: "chiaca-secret",
Testnet: &testnet,
Timezone: &timezone,
LogLevel: &logLevel,
Expand All @@ -75,14 +74,12 @@ spec:
IntroducerAddress: &introducerAddress,
DNSIntroducerAddress: &dnsIntroducerAddress,
},
CASecretName: "chiaca-secret",
FullNodePeer: "node.default.svc.cluster.local:58444",
},
CommonSpec: CommonSpec{
ChiaExporterConfig: SpecChiaExporter{
Enabled: true,
ServiceLabels: map[string]string{
"network": "testnet",
},
},
},
},
Expand Down
8 changes: 8 additions & 0 deletions api/v1/chiawallet_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ Copyright 2023 Chia Network Inc.
package v1

import (
appsv1 "k8s.io/api/apps/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

Expand All @@ -14,12 +15,19 @@ type ChiaWalletSpec struct {

// ChiaConfig defines the configuration options available to Chia component containers
ChiaConfig ChiaWalletSpecChia `json:"chia"`

// Strategy describes how to replace existing pods with new ones.
// +optional
Strategy *appsv1.DeploymentStrategy `json:"strategy,omitempty"`
}

// ChiaWalletSpecChia defines the desired state of Chia component configuration
type ChiaWalletSpecChia struct {
CommonSpecChia `json:",inline"`

// CASecretName is the name of the secret that contains the CA crt and key. Not required for seeders.
CASecretName string `json:"caSecretName"`

// SecretKey defines the k8s Secret name and key for a Chia mnemonic
SecretKey ChiaSecretKey `json:"secretKey"`

Expand Down
Loading

0 comments on commit 9724489

Please sign in to comment.