diff --git a/api/v1/chiacommon_types.go b/api/v1/chiacommon_types.go index 521f163..2a8e999 100644 --- a/api/v1/chiacommon_types.go +++ b/api/v1/chiacommon_types.go @@ -6,6 +6,37 @@ package v1 import corev1 "k8s.io/api/core/v1" +// CommonSpec represents the common configuration options for controller APIs at the top-spec level +type CommonSpec struct { + AdditionalMetadata `json:",inline"` + + // ChiaExporterConfig defines the configuration options available to Chia component containers + // +optional + ChiaExporterConfig ChiaExporterConfigSpec `json:"chiaExporter,omitempty"` + + //StorageConfig defines the Chia container's CHIA_ROOT storage config + // +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" + ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` + + // NodeSelector selects a node by key value pairs + // +optional + NodeSelector map[string]string `json:"nodeSelector,omitempty"` + + // PodSecurityContext defines the security context for the pod + // +optional + PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` +} + // CommonChiaConfigSpec represents the common configuration options for a chia spec type CommonChiaConfigSpec struct { // Image defines the image to use for the chia component containers diff --git a/api/v1/chiafarmer_types.go b/api/v1/chiafarmer_types.go index 78b42fe..0062cd5 100644 --- a/api/v1/chiafarmer_types.go +++ b/api/v1/chiafarmer_types.go @@ -5,42 +5,15 @@ Copyright 2023 Chia Network Inc. package v1 import ( - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // ChiaFarmerSpec defines the desired state of ChiaFarmer type ChiaFarmerSpec struct { - AdditionalMetadata `json:",inline"` + CommonSpec `json:",inline"` // ChiaConfig defines the configuration options available to Chia component containers ChiaConfig ChiaFarmerConfigSpec `json:"chia"` - - // ChiaExporterConfig defines the configuration options available to Chia component containers - // +optional - ChiaExporterConfig ChiaExporterConfigSpec `json:"chiaExporter,omitempty"` - - //StorageConfig defines the Chia container's CHIA_ROOT storage config - // +optional - Storage *StorageConfig `json:"storage,omitempty"` - - // ServiceType is the type of the service for the farmer instance - // +optional - // +kubebuilder:default="ClusterIP" - ServiceType string `json:"serviceType"` - - // ImagePullPolicy is the pull policy for containers in the pod - // +optional - // +kubebuilder:default="Always" - ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` - - // NodeSelector selects a node by key value pairs - // +optional - NodeSelector map[string]string `json:"nodeSelector,omitempty"` - - // PodSecurityContext defines the security context for the pod - // +optional - PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` } // ChiaFarmerConfigSpec defines the desired state of Chia component configuration diff --git a/api/v1/chiaharvester_types.go b/api/v1/chiaharvester_types.go index 21f134d..32c3e1f 100644 --- a/api/v1/chiaharvester_types.go +++ b/api/v1/chiaharvester_types.go @@ -5,89 +5,24 @@ Copyright 2023 Chia Network Inc. package v1 import ( - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // ChiaHarvesterSpec defines the desired state of ChiaHarvester type ChiaHarvesterSpec struct { - AdditionalMetadata `json:",inline"` + CommonSpec `json:",inline"` // ChiaConfig defines the configuration options available to Chia component containers ChiaConfig ChiaHarvesterConfigSpec `json:"chia"` - - // ChiaExporterConfig defines the configuration options available to Chia component containers - // +optional - ChiaExporterConfig ChiaExporterConfigSpec `json:"chiaExporter,omitempty"` - - //StorageConfig defines the Chia container's CHIA_ROOT storage config - // +optional - Storage *StorageConfig `json:"storage,omitempty"` - - // ServiceType is the type of the service for the harvester instance - // +optional - // +kubebuilder:default="ClusterIP" - ServiceType string `json:"serviceType"` - - // ImagePullPolicy is the pull policy for containers in the pod - // +optional - // +kubebuilder:default="Always" - ImagePullPolicy *corev1.PullPolicy `json:"imagePullPolicy,omitempty"` - - // NodeSelector selects a node by key value pairs - // +optional - NodeSelector map[string]string `json:"nodeSelector,omitempty"` - - // PodSecurityContext defines the security context for the pod - // +optional - PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` } // ChiaHarvesterConfigSpec defines the desired state of Chia component configuration type ChiaHarvesterConfigSpec struct { - // CASecretName is the name of the secret that contains the CA crt and key. - CASecretName string `json:"caSecretName"` + CommonChiaConfigSpec `json:",inline"` // FarmerAddress defines the harvester's farmer peer's hostname. The farmer's port is inferred. // In Kubernetes this is likely to be ..svc.cluster.local FarmerAddress string `json:"farmerAddress"` - - // Testnet is set to true if the Chia container should switch to the latest default testnet's settings - // +optional - Testnet *bool `json:"testnet,omitempty"` - - // LogLevel is set to the desired chia config log_level - // +optional - LogLevel *string `json:"logLevel,omitempty"` - - // Timezone can be set to your local timezone for accurate timestamps. Defaults to UTC - // +optional - Timezone *string `json:"timezone,omitempty"` - - // Image defines the image to use for the chia component containers - // +kubebuilder:default="ghcr.io/chia-network/chia:latest" - // +optional - Image string `json:"image"` - - // Periodic probe of container liveness. - // +optional - LivenessProbe *corev1.Probe `json:"livenessProbe,omitempty"` - - // Periodic probe of container service readiness. - // +optional - ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty"` - - // StartupProbe indicates that the Pod has successfully initialized. - // +optional - StartupProbe *corev1.Probe `json:"startupProbe,omitempty"` - - // Resources defines the compute resources for the Chia container - // +optional - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` - - // SecurityContext defines the security context for the chia container - // +optional - SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"` } // ChiaHarvesterStatus defines the observed state of ChiaHarvester diff --git a/api/v1/chianode_types.go b/api/v1/chianode_types.go index d51c29f..cac7012 100644 --- a/api/v1/chianode_types.go +++ b/api/v1/chianode_types.go @@ -5,47 +5,20 @@ Copyright 2023 Chia Network Inc. package v1 import ( - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // ChiaNodeSpec defines the desired state of ChiaNode type ChiaNodeSpec struct { - AdditionalMetadata `json:",inline"` + CommonSpec `json:",inline"` // ChiaConfig defines the configuration options available to Chia component containers ChiaConfig ChiaNodeConfigSpec `json:"chia"` - // ChiaExporterConfig defines the configuration options available to Chia component containers - // +optional - ChiaExporterConfig ChiaExporterConfigSpec `json:"chiaExporter,omitempty"` - - //StorageConfig defines the Chia container's CHIA_ROOT storage config - // +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"` - - // ImagePullPolicy is the pull policy for containers in the pod - // +optional - // +kubebuilder:default="Always" - ImagePullPolicy corev1.PullPolicy `json:"imagePullPolicy,omitempty"` - // Replicas is the desired number of replicas of the given Statefulset. defaults to 1. // +optional // +kubebuilder:default=1 Replicas int32 `json:"replicas,omitempty"` - - // NodeSelector selects a node by key value pairs - // +optional - NodeSelector map[string]string `json:"nodeSelector,omitempty"` - - // PodSecurityContext defines the security context for the pod - // +optional - PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` } // ChiaConfigSpec defines the desired state of Chia component configuration diff --git a/api/v1/chiatimelord_types.go b/api/v1/chiatimelord_types.go index 7c81958..84f1531 100644 --- a/api/v1/chiatimelord_types.go +++ b/api/v1/chiatimelord_types.go @@ -5,89 +5,24 @@ Copyright 2023 Chia Network Inc. package v1 import ( - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // ChiaTimelordSpec defines the desired state of ChiaTimelord type ChiaTimelordSpec struct { - AdditionalMetadata `json:",inline"` + CommonSpec `json:",inline"` // ChiaConfig defines the configuration options available to Chia component containers ChiaConfig ChiaTimelordConfigSpec `json:"chia"` - - // ChiaExporterConfig defines the configuration options available to Chia component containers - // +optional - ChiaExporterConfig ChiaExporterConfigSpec `json:"chiaExporter"` - - //StorageConfig defines the Chia container's CHIA_ROOT storage config - // +optional - Storage *StorageConfig `json:"storage,omitempty"` - - // ServiceType is the type of the service for the timelord instance - // +optional - // +kubebuilder:default="ClusterIP" - ServiceType string `json:"serviceType"` - - // ImagePullPolicy is the pull policy for containers in the pod - // +optional - // +kubebuilder:default="Always" - ImagePullPolicy *corev1.PullPolicy `json:"imagePullPolicy,omitempty"` - - // NodeSelector selects a node by key value pairs - // +optional - NodeSelector map[string]string `json:"nodeSelector,omitempty"` - - // PodSecurityContext defines the security context for the pod - // +optional - PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` } // ChiaTimelordConfigSpec defines the desired state of Chia component configuration type ChiaTimelordConfigSpec struct { - // CASecretName is the name of the secret that contains the CA crt and key. - CASecretName string `json:"caSecretName"` + CommonChiaConfigSpec `json:",inline"` // FullNodePeer defines the timelord's full_node peer in host:port format. // In Kubernetes this is likely to be ..svc.cluster.local:8555 FullNodePeer string `json:"fullNodePeer"` - - // Testnet is set to true if the Chia container should switch to the latest default testnet's settings - // +optional - Testnet *bool `json:"testnet,omitempty"` - - // LogLevel is set to the desired chia config log_level - // +optional - LogLevel *string `json:"logLevel,omitempty"` - - // Timezone can be set to your local timezone for accurate timestamps. Defaults to UTC - // +optional - Timezone *string `json:"timezone,omitempty"` - - // Image defines the image to use for the chia component containers - // +kubebuilder:default="ghcr.io/chia-network/chia:latest" - // +optional - Image string `json:"image"` - - // Periodic probe of container liveness. - // +optional - LivenessProbe *corev1.Probe `json:"livenessProbe,omitempty"` - - // Periodic probe of container service readiness. - // +optional - ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty"` - - // StartupProbe indicates that the Pod has successfully initialized. - // +optional - StartupProbe *corev1.Probe `json:"startupProbe,omitempty"` - - // Resources defines the compute resources for the Chia container - // +optional - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` - - // SecurityContext defines the security context for the chia container - // +optional - SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"` } // ChiaTimelordStatus defines the observed state of ChiaTimelord diff --git a/api/v1/chiawallet_types.go b/api/v1/chiawallet_types.go index 725cdfa..0f3770a 100644 --- a/api/v1/chiawallet_types.go +++ b/api/v1/chiawallet_types.go @@ -5,48 +5,20 @@ Copyright 2023 Chia Network Inc. package v1 import ( - corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" ) // ChiaWalletSpec defines the desired state of ChiaWallet type ChiaWalletSpec struct { - AdditionalMetadata `json:",inline"` + CommonSpec `json:",inline"` // ChiaConfig defines the configuration options available to Chia component containers ChiaConfig ChiaWalletConfigSpec `json:"chia"` - - // ChiaExporterConfig defines the configuration options available to Chia component containers - // +optional - ChiaExporterConfig ChiaExporterConfigSpec `json:"chiaExporter,omitempty"` - - //StorageConfig defines the Chia container's CHIA_ROOT storage config - // +optional - Storage *StorageConfig `json:"storage,omitempty"` - - // ServiceType is the type of the service for the harvester instance - // +optional - // +kubebuilder:default="ClusterIP" - ServiceType string `json:"serviceType"` - - // ImagePullPolicy is the pull policy for containers in the pod - // +optional - // +kubebuilder:default="Always" - ImagePullPolicy *corev1.PullPolicy `json:"imagePullPolicy,omitempty"` - - // NodeSelector selects a node by key value pairs - // +optional - NodeSelector map[string]string `json:"nodeSelector,omitempty"` - - // PodSecurityContext defines the security context for the pod - // +optional - PodSecurityContext *corev1.PodSecurityContext `json:"podSecurityContext,omitempty"` } // ChiaWalletConfigSpec defines the desired state of Chia component configuration type ChiaWalletConfigSpec struct { - // CASecretName is the name of the secret that contains the CA crt and key. - CASecretName string `json:"caSecretName"` + CommonChiaConfigSpec `json:",inline"` // SecretKeySpec defines the k8s Secret name and key for a Chia mnemonic SecretKeySpec ChiaKeysSpec `json:"secretKey"` @@ -54,43 +26,6 @@ type ChiaWalletConfigSpec struct { // FullNodePeer defines the farmer's full_node peer in host:port format. // In Kubernetes this is likely to be ..svc.cluster.local:8555 FullNodePeer string `json:"fullNodePeer"` - - // Testnet is set to true if the Chia container should switch to the latest default testnet's settings - // +optional - Testnet *bool `json:"testnet,omitempty"` - - // LogLevel is set to the desired chia config log_level - // +optional - LogLevel *string `json:"logLevel,omitempty"` - - // Timezone can be set to your local timezone for accurate timestamps. Defaults to UTC - // +optional - Timezone *string `json:"timezone,omitempty"` - - // Image defines the image to use for the chia component containers - // +kubebuilder:default="ghcr.io/chia-network/chia:latest" - // +optional - Image string `json:"image"` - - // Periodic probe of container liveness. - // +optional - LivenessProbe *corev1.Probe `json:"livenessProbe,omitempty"` - - // Periodic probe of container service readiness. - // +optional - ReadinessProbe *corev1.Probe `json:"readinessProbe,omitempty"` - - // StartupProbe indicates that the Pod has successfully initialized. - // +optional - StartupProbe *corev1.Probe `json:"startupProbe,omitempty"` - - // Resources defines the compute resources for the Chia container - // +optional - Resources *corev1.ResourceRequirements `json:"resources,omitempty"` - - // SecurityContext defines the security context for the chia container - // +optional - SecurityContext *corev1.SecurityContext `json:"securityContext,omitempty"` } // ChiaWalletStatus defines the observed state of ChiaWallet diff --git a/api/v1/zz_generated.deepcopy.go b/api/v1/zz_generated.deepcopy.go index b156c99..3b698aa 100644 --- a/api/v1/zz_generated.deepcopy.go +++ b/api/v1/zz_generated.deepcopy.go @@ -245,26 +245,8 @@ func (in *ChiaFarmerList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ChiaFarmerSpec) DeepCopyInto(out *ChiaFarmerSpec) { *out = *in - in.AdditionalMetadata.DeepCopyInto(&out.AdditionalMetadata) + in.CommonSpec.DeepCopyInto(&out.CommonSpec) in.ChiaConfig.DeepCopyInto(&out.ChiaConfig) - in.ChiaExporterConfig.DeepCopyInto(&out.ChiaExporterConfig) - if in.Storage != nil { - in, out := &in.Storage, &out.Storage - *out = new(StorageConfig) - (*in).DeepCopyInto(*out) - } - if in.NodeSelector != nil { - in, out := &in.NodeSelector, &out.NodeSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.PodSecurityContext != nil { - in, out := &in.PodSecurityContext, &out.PodSecurityContext - *out = new(corev1.PodSecurityContext) - (*in).DeepCopyInto(*out) - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChiaFarmerSpec. @@ -322,46 +304,7 @@ func (in *ChiaHarvester) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ChiaHarvesterConfigSpec) DeepCopyInto(out *ChiaHarvesterConfigSpec) { *out = *in - if in.Testnet != nil { - in, out := &in.Testnet, &out.Testnet - *out = new(bool) - **out = **in - } - if in.LogLevel != nil { - in, out := &in.LogLevel, &out.LogLevel - *out = new(string) - **out = **in - } - if in.Timezone != nil { - in, out := &in.Timezone, &out.Timezone - *out = new(string) - **out = **in - } - if in.LivenessProbe != nil { - in, out := &in.LivenessProbe, &out.LivenessProbe - *out = new(corev1.Probe) - (*in).DeepCopyInto(*out) - } - if in.ReadinessProbe != nil { - in, out := &in.ReadinessProbe, &out.ReadinessProbe - *out = new(corev1.Probe) - (*in).DeepCopyInto(*out) - } - if in.StartupProbe != nil { - in, out := &in.StartupProbe, &out.StartupProbe - *out = new(corev1.Probe) - (*in).DeepCopyInto(*out) - } - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = new(corev1.ResourceRequirements) - (*in).DeepCopyInto(*out) - } - if in.SecurityContext != nil { - in, out := &in.SecurityContext, &out.SecurityContext - *out = new(corev1.SecurityContext) - (*in).DeepCopyInto(*out) - } + in.CommonChiaConfigSpec.DeepCopyInto(&out.CommonChiaConfigSpec) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChiaHarvesterConfigSpec. @@ -409,31 +352,8 @@ func (in *ChiaHarvesterList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ChiaHarvesterSpec) DeepCopyInto(out *ChiaHarvesterSpec) { *out = *in - in.AdditionalMetadata.DeepCopyInto(&out.AdditionalMetadata) + in.CommonSpec.DeepCopyInto(&out.CommonSpec) in.ChiaConfig.DeepCopyInto(&out.ChiaConfig) - in.ChiaExporterConfig.DeepCopyInto(&out.ChiaExporterConfig) - if in.Storage != nil { - in, out := &in.Storage, &out.Storage - *out = new(StorageConfig) - (*in).DeepCopyInto(*out) - } - if in.ImagePullPolicy != nil { - in, out := &in.ImagePullPolicy, &out.ImagePullPolicy - *out = new(corev1.PullPolicy) - **out = **in - } - if in.NodeSelector != nil { - in, out := &in.NodeSelector, &out.NodeSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.PodSecurityContext != nil { - in, out := &in.PodSecurityContext, &out.PodSecurityContext - *out = new(corev1.PodSecurityContext) - (*in).DeepCopyInto(*out) - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChiaHarvesterSpec. @@ -554,26 +474,8 @@ func (in *ChiaNodeList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ChiaNodeSpec) DeepCopyInto(out *ChiaNodeSpec) { *out = *in - in.AdditionalMetadata.DeepCopyInto(&out.AdditionalMetadata) + in.CommonSpec.DeepCopyInto(&out.CommonSpec) in.ChiaConfig.DeepCopyInto(&out.ChiaConfig) - in.ChiaExporterConfig.DeepCopyInto(&out.ChiaExporterConfig) - if in.Storage != nil { - in, out := &in.Storage, &out.Storage - *out = new(StorageConfig) - (*in).DeepCopyInto(*out) - } - if in.NodeSelector != nil { - in, out := &in.NodeSelector, &out.NodeSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.PodSecurityContext != nil { - in, out := &in.PodSecurityContext, &out.PodSecurityContext - *out = new(corev1.PodSecurityContext) - (*in).DeepCopyInto(*out) - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChiaNodeSpec. @@ -656,46 +558,7 @@ func (in *ChiaTimelord) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ChiaTimelordConfigSpec) DeepCopyInto(out *ChiaTimelordConfigSpec) { *out = *in - if in.Testnet != nil { - in, out := &in.Testnet, &out.Testnet - *out = new(bool) - **out = **in - } - if in.LogLevel != nil { - in, out := &in.LogLevel, &out.LogLevel - *out = new(string) - **out = **in - } - if in.Timezone != nil { - in, out := &in.Timezone, &out.Timezone - *out = new(string) - **out = **in - } - if in.LivenessProbe != nil { - in, out := &in.LivenessProbe, &out.LivenessProbe - *out = new(corev1.Probe) - (*in).DeepCopyInto(*out) - } - if in.ReadinessProbe != nil { - in, out := &in.ReadinessProbe, &out.ReadinessProbe - *out = new(corev1.Probe) - (*in).DeepCopyInto(*out) - } - if in.StartupProbe != nil { - in, out := &in.StartupProbe, &out.StartupProbe - *out = new(corev1.Probe) - (*in).DeepCopyInto(*out) - } - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = new(corev1.ResourceRequirements) - (*in).DeepCopyInto(*out) - } - if in.SecurityContext != nil { - in, out := &in.SecurityContext, &out.SecurityContext - *out = new(corev1.SecurityContext) - (*in).DeepCopyInto(*out) - } + in.CommonChiaConfigSpec.DeepCopyInto(&out.CommonChiaConfigSpec) } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChiaTimelordConfigSpec. @@ -743,31 +606,8 @@ func (in *ChiaTimelordList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ChiaTimelordSpec) DeepCopyInto(out *ChiaTimelordSpec) { *out = *in - in.AdditionalMetadata.DeepCopyInto(&out.AdditionalMetadata) + in.CommonSpec.DeepCopyInto(&out.CommonSpec) in.ChiaConfig.DeepCopyInto(&out.ChiaConfig) - in.ChiaExporterConfig.DeepCopyInto(&out.ChiaExporterConfig) - if in.Storage != nil { - in, out := &in.Storage, &out.Storage - *out = new(StorageConfig) - (*in).DeepCopyInto(*out) - } - if in.ImagePullPolicy != nil { - in, out := &in.ImagePullPolicy, &out.ImagePullPolicy - *out = new(corev1.PullPolicy) - **out = **in - } - if in.NodeSelector != nil { - in, out := &in.NodeSelector, &out.NodeSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.PodSecurityContext != nil { - in, out := &in.PodSecurityContext, &out.PodSecurityContext - *out = new(corev1.PodSecurityContext) - (*in).DeepCopyInto(*out) - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChiaTimelordSpec. @@ -825,47 +665,8 @@ func (in *ChiaWallet) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ChiaWalletConfigSpec) DeepCopyInto(out *ChiaWalletConfigSpec) { *out = *in + in.CommonChiaConfigSpec.DeepCopyInto(&out.CommonChiaConfigSpec) out.SecretKeySpec = in.SecretKeySpec - if in.Testnet != nil { - in, out := &in.Testnet, &out.Testnet - *out = new(bool) - **out = **in - } - if in.LogLevel != nil { - in, out := &in.LogLevel, &out.LogLevel - *out = new(string) - **out = **in - } - if in.Timezone != nil { - in, out := &in.Timezone, &out.Timezone - *out = new(string) - **out = **in - } - if in.LivenessProbe != nil { - in, out := &in.LivenessProbe, &out.LivenessProbe - *out = new(corev1.Probe) - (*in).DeepCopyInto(*out) - } - if in.ReadinessProbe != nil { - in, out := &in.ReadinessProbe, &out.ReadinessProbe - *out = new(corev1.Probe) - (*in).DeepCopyInto(*out) - } - if in.StartupProbe != nil { - in, out := &in.StartupProbe, &out.StartupProbe - *out = new(corev1.Probe) - (*in).DeepCopyInto(*out) - } - if in.Resources != nil { - in, out := &in.Resources, &out.Resources - *out = new(corev1.ResourceRequirements) - (*in).DeepCopyInto(*out) - } - if in.SecurityContext != nil { - in, out := &in.SecurityContext, &out.SecurityContext - *out = new(corev1.SecurityContext) - (*in).DeepCopyInto(*out) - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChiaWalletConfigSpec. @@ -913,31 +714,8 @@ func (in *ChiaWalletList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ChiaWalletSpec) DeepCopyInto(out *ChiaWalletSpec) { *out = *in - in.AdditionalMetadata.DeepCopyInto(&out.AdditionalMetadata) + in.CommonSpec.DeepCopyInto(&out.CommonSpec) in.ChiaConfig.DeepCopyInto(&out.ChiaConfig) - in.ChiaExporterConfig.DeepCopyInto(&out.ChiaExporterConfig) - if in.Storage != nil { - in, out := &in.Storage, &out.Storage - *out = new(StorageConfig) - (*in).DeepCopyInto(*out) - } - if in.ImagePullPolicy != nil { - in, out := &in.ImagePullPolicy, &out.ImagePullPolicy - *out = new(corev1.PullPolicy) - **out = **in - } - if in.NodeSelector != nil { - in, out := &in.NodeSelector, &out.NodeSelector - *out = make(map[string]string, len(*in)) - for key, val := range *in { - (*out)[key] = val - } - } - if in.PodSecurityContext != nil { - in, out := &in.PodSecurityContext, &out.PodSecurityContext - *out = new(corev1.PodSecurityContext) - (*in).DeepCopyInto(*out) - } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ChiaWalletSpec. @@ -1020,6 +798,40 @@ func (in *CommonChiaConfigSpec) DeepCopy() *CommonChiaConfigSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *CommonSpec) DeepCopyInto(out *CommonSpec) { + *out = *in + in.AdditionalMetadata.DeepCopyInto(&out.AdditionalMetadata) + in.ChiaExporterConfig.DeepCopyInto(&out.ChiaExporterConfig) + if in.Storage != nil { + in, out := &in.Storage, &out.Storage + *out = new(StorageConfig) + (*in).DeepCopyInto(*out) + } + if in.NodeSelector != nil { + in, out := &in.NodeSelector, &out.NodeSelector + *out = make(map[string]string, len(*in)) + for key, val := range *in { + (*out)[key] = val + } + } + if in.PodSecurityContext != nil { + in, out := &in.PodSecurityContext, &out.PodSecurityContext + *out = new(corev1.PodSecurityContext) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new CommonSpec. +func (in *CommonSpec) DeepCopy() *CommonSpec { + if in == nil { + return nil + } + out := new(CommonSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *HostPathVolumeConfig) DeepCopyInto(out *HostPathVolumeConfig) { *out = *in diff --git a/config/crd/bases/k8s.chia.net_chiafarmers.yaml b/config/crd/bases/k8s.chia.net_chiafarmers.yaml index c09b7a3..4a5bdc7 100644 --- a/config/crd/bases/k8s.chia.net_chiafarmers.yaml +++ b/config/crd/bases/k8s.chia.net_chiafarmers.yaml @@ -958,8 +958,8 @@ spec: type: object serviceType: default: ClusterIP - description: ServiceType is the type of the service for the farmer - instance + description: ServiceType is the type of the service that governs this + ChiaNode StatefulSet. type: string storage: description: StorageConfig defines the Chia container's CHIA_ROOT diff --git a/config/crd/bases/k8s.chia.net_chiaharvesters.yaml b/config/crd/bases/k8s.chia.net_chiaharvesters.yaml index 1f1e1aa..e661700 100644 --- a/config/crd/bases/k8s.chia.net_chiaharvesters.yaml +++ b/config/crd/bases/k8s.chia.net_chiaharvesters.yaml @@ -942,8 +942,8 @@ spec: type: object serviceType: default: ClusterIP - description: ServiceType is the type of the service for the harvester - instance + description: ServiceType is the type of the service that governs this + ChiaNode StatefulSet. type: string storage: description: StorageConfig defines the Chia container's CHIA_ROOT diff --git a/config/crd/bases/k8s.chia.net_chiatimelords.yaml b/config/crd/bases/k8s.chia.net_chiatimelords.yaml index 12a54b7..012f952 100644 --- a/config/crd/bases/k8s.chia.net_chiatimelords.yaml +++ b/config/crd/bases/k8s.chia.net_chiatimelords.yaml @@ -942,8 +942,8 @@ spec: type: object serviceType: default: ClusterIP - description: ServiceType is the type of the service for the timelord - instance + description: ServiceType is the type of the service that governs this + ChiaNode StatefulSet. type: string storage: description: StorageConfig defines the Chia container's CHIA_ROOT diff --git a/config/crd/bases/k8s.chia.net_chiawallets.yaml b/config/crd/bases/k8s.chia.net_chiawallets.yaml index 70093bd..7af159e 100644 --- a/config/crd/bases/k8s.chia.net_chiawallets.yaml +++ b/config/crd/bases/k8s.chia.net_chiawallets.yaml @@ -958,8 +958,8 @@ spec: type: object serviceType: default: ClusterIP - description: ServiceType is the type of the service for the harvester - instance + description: ServiceType is the type of the service that governs this + ChiaNode StatefulSet. type: string storage: description: StorageConfig defines the Chia container's CHIA_ROOT diff --git a/internal/controller/chiaharvester/assemblers.go b/internal/controller/chiaharvester/assemblers.go index 67da500..30abb65 100644 --- a/internal/controller/chiaharvester/assemblers.go +++ b/internal/controller/chiaharvester/assemblers.go @@ -1,3 +1,7 @@ +/* +Copyright 2023 Chia Network Inc. +*/ + package chiaharvester import ( @@ -104,11 +108,6 @@ func (r *ChiaHarvesterReconciler) assembleDeployment(ctx context.Context, harves chiaResources = *harvester.Spec.ChiaConfig.Resources } - var imagePullPolicy corev1.PullPolicy - if harvester.Spec.ImagePullPolicy != nil { - imagePullPolicy = *harvester.Spec.ImagePullPolicy - } - var chiaExporterImage = harvester.Spec.ChiaExporterConfig.Image if chiaExporterImage == "" { chiaExporterImage = consts.DefaultChiaExporterImage @@ -138,7 +137,7 @@ func (r *ChiaHarvesterReconciler) assembleDeployment(ctx context.Context, harves Name: "chia", SecurityContext: chiaSecContext, Image: harvester.Spec.ChiaConfig.Image, - ImagePullPolicy: imagePullPolicy, + ImagePullPolicy: harvester.Spec.ImagePullPolicy, Env: r.getChiaEnv(ctx, harvester), Ports: []corev1.ContainerPort{ { @@ -171,7 +170,7 @@ func (r *ChiaHarvesterReconciler) assembleDeployment(ctx context.Context, harves }, } - exporterContainer := kube.GetChiaExporterContainer(ctx, chiaExporterImage, chiaSecContext, imagePullPolicy, chiaResources) + exporterContainer := kube.GetChiaExporterContainer(ctx, chiaExporterImage, chiaSecContext, harvester.Spec.ImagePullPolicy, chiaResources) deploy.Spec.Template.Spec.Containers = append(deploy.Spec.Template.Spec.Containers, exporterContainer) if harvester.Spec.PodSecurityContext != nil { diff --git a/internal/controller/chiatimelord/assemblers.go b/internal/controller/chiatimelord/assemblers.go index fac1273..5d444b6 100644 --- a/internal/controller/chiatimelord/assemblers.go +++ b/internal/controller/chiatimelord/assemblers.go @@ -1,3 +1,7 @@ +/* +Copyright 2023 Chia Network Inc. +*/ + package chiatimelord import ( @@ -104,11 +108,6 @@ func (r *ChiaTimelordReconciler) assembleDeployment(ctx context.Context, tl k8sc chiaResources = *tl.Spec.ChiaConfig.Resources } - var imagePullPolicy corev1.PullPolicy - if tl.Spec.ImagePullPolicy != nil { - imagePullPolicy = *tl.Spec.ImagePullPolicy - } - var chiaExporterImage = tl.Spec.ChiaExporterConfig.Image if chiaExporterImage == "" { chiaExporterImage = consts.DefaultChiaExporterImage @@ -138,7 +137,7 @@ func (r *ChiaTimelordReconciler) assembleDeployment(ctx context.Context, tl k8sc Name: "chia", SecurityContext: chiaSecContext, Image: tl.Spec.ChiaConfig.Image, - ImagePullPolicy: imagePullPolicy, + ImagePullPolicy: tl.Spec.ImagePullPolicy, Env: r.getChiaEnv(ctx, tl), Ports: []corev1.ContainerPort{ { @@ -180,7 +179,7 @@ func (r *ChiaTimelordReconciler) assembleDeployment(ctx context.Context, tl k8sc }, } - exporterContainer := kube.GetChiaExporterContainer(ctx, chiaExporterImage, chiaSecContext, imagePullPolicy, chiaResources) + exporterContainer := kube.GetChiaExporterContainer(ctx, chiaExporterImage, chiaSecContext, tl.Spec.ImagePullPolicy, chiaResources) deploy.Spec.Template.Spec.Containers = append(deploy.Spec.Template.Spec.Containers, exporterContainer) if tl.Spec.PodSecurityContext != nil { diff --git a/internal/controller/chiawallet/assemblers.go b/internal/controller/chiawallet/assemblers.go index b1ce14d..f2c2cb8 100644 --- a/internal/controller/chiawallet/assemblers.go +++ b/internal/controller/chiawallet/assemblers.go @@ -1,3 +1,7 @@ +/* +Copyright 2023 Chia Network Inc. +*/ + package chiawallet import ( @@ -104,11 +108,6 @@ func (r *ChiaWalletReconciler) assembleDeployment(ctx context.Context, wallet k8 chiaResources = *wallet.Spec.ChiaConfig.Resources } - var imagePullPolicy corev1.PullPolicy - if wallet.Spec.ImagePullPolicy != nil { - imagePullPolicy = *wallet.Spec.ImagePullPolicy - } - var chiaExporterImage = wallet.Spec.ChiaExporterConfig.Image if chiaExporterImage == "" { chiaExporterImage = consts.DefaultChiaExporterImage @@ -138,7 +137,7 @@ func (r *ChiaWalletReconciler) assembleDeployment(ctx context.Context, wallet k8 Name: "chia", SecurityContext: chiaSecContext, Image: wallet.Spec.ChiaConfig.Image, - ImagePullPolicy: imagePullPolicy, + ImagePullPolicy: wallet.Spec.ImagePullPolicy, Env: r.getChiaEnv(ctx, wallet), Ports: []corev1.ContainerPort{ { @@ -184,7 +183,7 @@ func (r *ChiaWalletReconciler) assembleDeployment(ctx context.Context, wallet k8 }, } - exporterContainer := kube.GetChiaExporterContainer(ctx, chiaExporterImage, chiaSecContext, imagePullPolicy, chiaResources) + exporterContainer := kube.GetChiaExporterContainer(ctx, chiaExporterImage, chiaSecContext, wallet.Spec.ImagePullPolicy, chiaResources) deploy.Spec.Template.Spec.Containers = append(deploy.Spec.Template.Spec.Containers, exporterContainer) if wallet.Spec.PodSecurityContext != nil { diff --git a/internal/controller/suite_test.go b/internal/controller/suite_test.go index 1374533..868fe20 100644 --- a/internal/controller/suite_test.go +++ b/internal/controller/suite_test.go @@ -212,9 +212,11 @@ var _ = Describe("ChiaFarmer controller", func() { Key: secretKeyKey, }, }, - ChiaExporterConfig: apiv1.ChiaExporterConfigSpec{ - ServiceLabels: map[string]string{ - "key": "value", + CommonSpec: apiv1.CommonSpec{ + ChiaExporterConfig: apiv1.ChiaExporterConfigSpec{ + ServiceLabels: map[string]string{ + "key": "value", + }, }, }, }, @@ -265,26 +267,30 @@ var _ = Describe("ChiaHarvester controller", func() { }, Spec: apiv1.ChiaHarvesterSpec{ ChiaConfig: apiv1.ChiaHarvesterConfigSpec{ - CASecretName: caSecretName, - Testnet: &testnet, - Timezone: &timezone, - LogLevel: &logLevel, + CommonChiaConfigSpec: apiv1.CommonChiaConfigSpec{ + CASecretName: caSecretName, + Testnet: &testnet, + Timezone: &timezone, + LogLevel: &logLevel, + }, }, - Storage: &apiv1.StorageConfig{ - Plots: &apiv1.PlotsConfig{ - HostPathVolume: []*apiv1.HostPathVolumeConfig{ - { - Path: "/home/test/plot1", - }, - { - Path: "/home/test/plot2", - }, + CommonSpec: apiv1.CommonSpec{ + ChiaExporterConfig: apiv1.ChiaExporterConfigSpec{ + ServiceLabels: map[string]string{ + "key": "value", }, }, - }, - ChiaExporterConfig: apiv1.ChiaExporterConfigSpec{ - ServiceLabels: map[string]string{ - "key": "value", + Storage: &apiv1.StorageConfig{ + Plots: &apiv1.PlotsConfig{ + HostPathVolume: []*apiv1.HostPathVolumeConfig{ + { + Path: "/home/test/plot1", + }, + { + Path: "/home/test/plot2", + }, + }, + }, }, }, }, @@ -344,18 +350,19 @@ var _ = Describe("ChiaNode controller", func() { LogLevel: &logLevel, }, }, - Storage: &apiv1.StorageConfig{ - ChiaRoot: &apiv1.ChiaRootConfig{ - PersistentVolumeClaim: &apiv1.PersistentVolumeClaimConfig{ - StorageClass: storageClass, - ResourceRequest: resourceRequest, + CommonSpec: apiv1.CommonSpec{ + ChiaExporterConfig: apiv1.ChiaExporterConfigSpec{ + ServiceLabels: map[string]string{ + "key": "value", }, }, - }, - ChiaExporterConfig: apiv1.ChiaExporterConfigSpec{ - Enabled: true, - ServiceLabels: map[string]string{ - "key": "value", + Storage: &apiv1.StorageConfig{ + ChiaRoot: &apiv1.ChiaRootConfig{ + PersistentVolumeClaim: &apiv1.PersistentVolumeClaimConfig{ + StorageClass: storageClass, + ResourceRequest: resourceRequest, + }, + }, }, }, }, @@ -411,19 +418,23 @@ var _ = Describe("ChiaWallet controller", func() { }, Spec: apiv1.ChiaWalletSpec{ ChiaConfig: apiv1.ChiaWalletConfigSpec{ - CASecretName: caSecretName, - Testnet: &testnet, - Timezone: &timezone, - LogLevel: &logLevel, + CommonChiaConfigSpec: apiv1.CommonChiaConfigSpec{ + CASecretName: caSecretName, + Testnet: &testnet, + Timezone: &timezone, + LogLevel: &logLevel, + }, FullNodePeer: fullNodePeer, SecretKeySpec: apiv1.ChiaKeysSpec{ Name: secretKeyName, Key: secretKeyKey, }, }, - ChiaExporterConfig: apiv1.ChiaExporterConfigSpec{ - ServiceLabels: map[string]string{ - "key": "value", + CommonSpec: apiv1.CommonSpec{ + ChiaExporterConfig: apiv1.ChiaExporterConfigSpec{ + ServiceLabels: map[string]string{ + "key": "value", + }, }, }, },