Skip to content

Commit

Permalink
Add Reconfigure api
Browse files Browse the repository at this point in the history
Signed-off-by: ashraful <[email protected]>
  • Loading branch information
AshrafulHaqueToni committed May 28, 2024
1 parent 7327750 commit 65fe58d
Show file tree
Hide file tree
Showing 11 changed files with 216 additions and 36 deletions.
12 changes: 6 additions & 6 deletions apis/kubedb/v1alpha2/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 0 additions & 3 deletions apis/kubedb/v1alpha2/singlestore_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,9 +324,6 @@ func (s *Singlestore) SetDefaults() {
}

if s.Spec.Topology == nil {
if s.Spec.Replicas == nil {
s.Spec.Replicas = pointer.Int32P(1)
}
if s.Spec.PodTemplate == nil {
s.Spec.PodTemplate = &ofst.PodTemplateSpec{}
}
Expand Down
8 changes: 5 additions & 3 deletions apis/kubedb/v1alpha2/singlestore_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,6 @@ type SinglestoreSpec struct {
// +optional
Version string `json:"version"`

// +optional
Replicas *int32 `json:"replicas,omitempty"`

// Singlestore topology for node specification
// +optional
Topology *SinglestoreTopology `json:"topology,omitempty"`
Expand Down Expand Up @@ -137,6 +134,11 @@ type SinglestoreNode struct {
// +optional
Suffix string `json:"suffix,omitempty"`

// ConfigSecret is an optional field to provide custom configuration file for database (i.e config.properties).
// If specified, this file will be used as configuration file otherwise default configuration file will be used.
// +optional
ConfigSecret *core.LocalObjectReference `json:"configSecret,omitempty"`

// Storage to specify how storage shall be used.
// +optional
Storage *core.PersistentVolumeClaimSpec `json:"storage,omitempty"`
Expand Down
13 changes: 0 additions & 13 deletions apis/kubedb/v1alpha2/singlestore_webhook.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,15 +64,7 @@ func (s *Singlestore) ValidateCreate() (admission.Warnings, error) {
func (s *Singlestore) ValidateUpdate(old runtime.Object) (admission.Warnings, error) {
singlestorelog.Info("validate update", "name", s.Name)

oldConnect := old.(*Singlestore)
allErr := s.ValidateCreateOrUpdate()

if s.Spec.Topology == nil && *oldConnect.Spec.Replicas == 1 && *s.Spec.Replicas > 1 {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("replicas"),
s.Name,
"Cannot scale up from 1 to more than 1 in standalone mode"))
}

if len(allErr) == 0 {
return nil, nil
}
Expand Down Expand Up @@ -111,11 +103,6 @@ func (s *Singlestore) ValidateCreateOrUpdate() field.ErrorList {
}

if s.Spec.Topology == nil {
if *s.Spec.Replicas != 1 {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("replicas"),
s.Name,
"number of replicas for standalone must be one "))
}
err := sdbValidateVolumes(s.Spec.PodTemplate)
if err != nil {
allErr = append(allErr, field.Invalid(field.NewPath("spec").Child("podTemplate").Child("spec").Child("volumes"),
Expand Down
10 changes: 5 additions & 5 deletions apis/kubedb/v1alpha2/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

75 changes: 74 additions & 1 deletion apis/ops/v1alpha1/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

18 changes: 16 additions & 2 deletions apis/ops/v1alpha1/singlestore_ops_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -61,15 +61,17 @@ type SinglestoreOpsRequestSpec struct {
VolumeExpansion *SinglestoreVolumeExpansionSpec `json:"volumeExpansion,omitempty"`
// Specifies information necessary for restarting database
Restart *RestartSpec `json:"restart,omitempty"`
// Specifies information necessary for custom configuration of Singlestore
Configuration *SinglestoreCustomConfigurationSpec `json:"configuration,omitempty"`
// Timeout for each step of the ops request in second. If a step doesn't finish within the specified timeout, the ops request will result in failure.
Timeout *metav1.Duration `json:"timeout,omitempty"`
// ApplyOption is to control the execution of OpsRequest depending on the database state.
// +kubebuilder:default="IfReady"
Apply ApplyOption `json:"apply,omitempty"`
}

// +kubebuilder:validation:Enum=VerticalScaling;VolumeExpansion;Restart
// ENUM(VerticalScaling, VolumeExpansion, Restart)
// +kubebuilder:validation:Enum=VerticalScaling;VolumeExpansion;Restart;Configuration
// ENUM(VerticalScaling, VolumeExpansion, Restart, Configuration)
type SinglestoreOpsRequestType string

// SinglestoreVerticalScalingSpec contains the vertical scaling information of a Singlestore cluster
Expand All @@ -95,6 +97,18 @@ type SinglestoreVolumeExpansionSpec struct {
Leaf *resource.Quantity `json:"leaf,omitempty"`
}

// SinglestoreCustomConfigurationSpec is the spec for Singlestore reconfiguration
type SinglestoreCustomConfigurationSpec struct {
Aggregator *SinglestoreCustomConfiguration `json:"aggregator,omitempty"`
Leaf *SinglestoreCustomConfiguration `json:"leaf,omitempty"`
}

type SinglestoreCustomConfiguration struct {
ConfigSecret *core.LocalObjectReference `json:"configSecret,omitempty"`
ApplyConfig map[string]string `json:"applyConfig,omitempty"`
RemoveCustomConfig bool `json:"removeCustomConfig,omitempty"`
}

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

// SinglestoreOpsRequestList is a list of SinglestoreOpsRequests
Expand Down
5 changes: 5 additions & 0 deletions apis/ops/v1alpha1/singlestore_ops_types_enum.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

59 changes: 59 additions & 0 deletions apis/ops/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

15 changes: 12 additions & 3 deletions crds/kubedb.com_singlestores.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4138,9 +4138,6 @@ spec:
type: array
type: object
type: object
replicas:
format: int32
type: integer
serviceTemplates:
items:
properties:
Expand Down Expand Up @@ -4413,6 +4410,12 @@ spec:
properties:
aggregator:
properties:
configSecret:
properties:
name:
type: string
type: object
x-kubernetes-map-type: atomic
podPlacementPolicy:
default:
name: default
Expand Down Expand Up @@ -7406,6 +7409,12 @@ spec:
type: object
leaf:
properties:
configSecret:
properties:
name:
type: string
type: object
x-kubernetes-map-type: atomic
podPlacementPolicy:
default:
name: default
Expand Down
Loading

0 comments on commit 65fe58d

Please sign in to comment.