Skip to content

Commit

Permalink
refactor: greptimedbcluster replicas default value (#111)
Browse files Browse the repository at this point in the history
  • Loading branch information
daviderli614 authored Jul 24, 2023
1 parent cc9b26a commit 8fa5868
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 35 deletions.
3 changes: 3 additions & 0 deletions apis/v1alpha1/defaulting.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,7 @@ func (in *GreptimeDBCluster) SetDefaults() error {
if in.Spec.Frontend != nil {
defaultGreptimeDBClusterSpec.Frontend = &FrontendSpec{
ComponentSpec: ComponentSpec{
Replicas: 1,
Template: &PodTemplateSpec{},
},
Service: ServiceSpec{
Expand All @@ -109,6 +110,7 @@ func (in *GreptimeDBCluster) SetDefaults() error {
if in.Spec.Meta != nil {
defaultGreptimeDBClusterSpec.Meta = &MetaSpec{
ComponentSpec: ComponentSpec{
Replicas: 1,
Template: &PodTemplateSpec{},
},
ServicePort: int32(defaultMetaServicePort),
Expand All @@ -118,6 +120,7 @@ func (in *GreptimeDBCluster) SetDefaults() error {
if in.Spec.Datanode != nil {
defaultGreptimeDBClusterSpec.Datanode = &DatanodeSpec{
ComponentSpec: ComponentSpec{
Replicas: 3,
Template: &PodTemplateSpec{},
},
Storage: StorageSpec{
Expand Down
9 changes: 3 additions & 6 deletions apis/v1alpha1/defaulting_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,6 @@ func TestSetDefaults(t *testing.T) {
},
Frontend: &FrontendSpec{
ComponentSpec: ComponentSpec{
Replicas: 3,
Template: &PodTemplateSpec{
MainContainer: &MainContainerSpec{
Image: "greptime/frontend:latest",
Expand All @@ -220,7 +219,6 @@ func TestSetDefaults(t *testing.T) {
},
Meta: &MetaSpec{
ComponentSpec: ComponentSpec{
Replicas: 3,
Template: &PodTemplateSpec{
MainContainer: &MainContainerSpec{
Image: "greptime/meta:latest",
Expand All @@ -237,7 +235,6 @@ func TestSetDefaults(t *testing.T) {
},
Datanode: &DatanodeSpec{
ComponentSpec: ComponentSpec{
Replicas: 1,
Template: &PodTemplateSpec{
MainContainer: &MainContainerSpec{
Image: "greptime/greptimedb:latest",
Expand Down Expand Up @@ -275,7 +272,7 @@ func TestSetDefaults(t *testing.T) {
},
Frontend: &FrontendSpec{
ComponentSpec: ComponentSpec{
Replicas: 3,
Replicas: 1,
Template: &PodTemplateSpec{
MainContainer: &MainContainerSpec{
Image: "greptime/frontend:latest",
Expand Down Expand Up @@ -310,7 +307,7 @@ func TestSetDefaults(t *testing.T) {
},
Meta: &MetaSpec{
ComponentSpec: ComponentSpec{
Replicas: 3,
Replicas: 1,
Template: &PodTemplateSpec{
MainContainer: &MainContainerSpec{
Image: "greptime/meta:latest",
Expand Down Expand Up @@ -346,7 +343,7 @@ func TestSetDefaults(t *testing.T) {
},
Datanode: &DatanodeSpec{
ComponentSpec: ComponentSpec{
Replicas: 1,
Replicas: 3,
Template: &PodTemplateSpec{
MainContainer: &MainContainerSpec{
Image: "greptime/greptimedb:latest",
Expand Down
4 changes: 2 additions & 2 deletions apis/v1alpha1/greptimedbcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -274,8 +274,8 @@ type PodTemplateSpec struct {
// ComponentSpec is the common specification for all components(frontend/meta/datanode).
type ComponentSpec struct {
// The number of replicas of the components.
// +required
// +kubebuilder:validation:Minimum=1
// +kubebuilder:validation:Minimum=0
// +optional
Replicas int32 `json:"replicas"`

// The content of the configuration file of the component in TOML format.
Expand Down
12 changes: 3 additions & 9 deletions config/crd/bases/greptime.io_greptimedbclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2691,7 +2691,7 @@ spec:
type: string
replicas:
format: int32
minimum: 1
minimum: 0
type: integer
storage:
properties:
Expand Down Expand Up @@ -5348,8 +5348,6 @@ spec:
type: object
type: array
type: object
required:
- replicas
type: object
enableInfluxDBProtocol:
type: boolean
Expand All @@ -5359,7 +5357,7 @@ spec:
type: string
replicas:
format: int32
minimum: 1
minimum: 0
type: integer
service:
properties:
Expand Down Expand Up @@ -8018,8 +8016,6 @@ spec:
secretName:
type: string
type: object
required:
- replicas
type: object
grpcServicePort:
format: int32
Expand All @@ -8044,7 +8040,7 @@ spec:
type: array
replicas:
format: int32
minimum: 1
minimum: 0
type: integer
servicePort:
format: int32
Expand Down Expand Up @@ -10686,8 +10682,6 @@ spec:
type: object
type: array
type: object
required:
- replicas
type: object
mysqlServicePort:
format: int32
Expand Down
12 changes: 3 additions & 9 deletions manifests/greptimedb-operator-crd.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2690,7 +2690,7 @@ spec:
type: string
replicas:
format: int32
minimum: 1
minimum: 0
type: integer
storage:
properties:
Expand Down Expand Up @@ -5347,8 +5347,6 @@ spec:
type: object
type: array
type: object
required:
- replicas
type: object
enableInfluxDBProtocol:
type: boolean
Expand All @@ -5358,7 +5356,7 @@ spec:
type: string
replicas:
format: int32
minimum: 1
minimum: 0
type: integer
service:
properties:
Expand Down Expand Up @@ -8017,8 +8015,6 @@ spec:
secretName:
type: string
type: object
required:
- replicas
type: object
grpcServicePort:
format: int32
Expand All @@ -8043,7 +8039,7 @@ spec:
type: array
replicas:
format: int32
minimum: 1
minimum: 0
type: integer
servicePort:
format: int32
Expand Down Expand Up @@ -10685,8 +10681,6 @@ spec:
type: object
type: array
type: object
required:
- replicas
type: object
mysqlServicePort:
format: int32
Expand Down
12 changes: 3 additions & 9 deletions manifests/greptimedb-operator-deployment.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2697,7 +2697,7 @@ spec:
type: string
replicas:
format: int32
minimum: 1
minimum: 0
type: integer
storage:
properties:
Expand Down Expand Up @@ -5354,8 +5354,6 @@ spec:
type: object
type: array
type: object
required:
- replicas
type: object
enableInfluxDBProtocol:
type: boolean
Expand All @@ -5365,7 +5363,7 @@ spec:
type: string
replicas:
format: int32
minimum: 1
minimum: 0
type: integer
service:
properties:
Expand Down Expand Up @@ -8024,8 +8022,6 @@ spec:
secretName:
type: string
type: object
required:
- replicas
type: object
grpcServicePort:
format: int32
Expand All @@ -8050,7 +8046,7 @@ spec:
type: array
replicas:
format: int32
minimum: 1
minimum: 0
type: integer
servicePort:
format: int32
Expand Down Expand Up @@ -10692,8 +10688,6 @@ spec:
type: object
type: array
type: object
required:
- replicas
type: object
mysqlServicePort:
format: int32
Expand Down

0 comments on commit 8fa5868

Please sign in to comment.