diff --git a/apis/kubedb/v1alpha2/mysql_helpers.go b/apis/kubedb/v1alpha2/mysql_helpers.go index d95264e15b..e3af891a3c 100644 --- a/apis/kubedb/v1alpha2/mysql_helpers.go +++ b/apis/kubedb/v1alpha2/mysql_helpers.go @@ -241,10 +241,10 @@ func (m *MySQL) IsInnoDBCluster() bool { *m.Spec.Topology.Mode == MySQLModeInnoDBCluster } -func (m *MySQL) IsReadReplica() bool { +func (m *MySQL) IsRemoteReplica() bool { return m.Spec.Topology != nil && m.Spec.Topology.Mode != nil && - *m.Spec.Topology.Mode == MySQLModeReadReplica + *m.Spec.Topology.Mode == MySQLModeRemoteReplica } func (m *MySQL) IsSemiSync() bool { diff --git a/apis/kubedb/v1alpha2/mysql_types.go b/apis/kubedb/v1alpha2/mysql_types.go index 4b910fb991..a58d41ffb5 100644 --- a/apis/kubedb/v1alpha2/mysql_types.go +++ b/apis/kubedb/v1alpha2/mysql_types.go @@ -31,13 +31,13 @@ const ( ResourcePluralMySQL = "mysqls" ) -// +kubebuilder:validation:Enum=GroupReplication;InnoDBCluster;ReadReplica;SemiSync +// +kubebuilder:validation:Enum=GroupReplication;InnoDBCluster;RemoteReplica;SemiSync type MySQLMode string const ( MySQLModeGroupReplication MySQLMode = "GroupReplication" MySQLModeInnoDBCluster MySQLMode = "InnoDBCluster" - MySQLModeReadReplica MySQLMode = "ReadReplica" + MySQLModeRemoteReplica MySQLMode = "RemoteReplica" MySQLModeSemiSync MySQLMode = "SemiSync" ) @@ -187,10 +187,10 @@ type MySQLTopology struct { // +optional InnoDBCluster *MySQLInnoDBClusterSpec `json:"innoDBCluster,omitempty"` - // ReadReplica implies that the instance will be a MySQL Read Only Replica + // RemoteReplica implies that the instance will be a MySQL Read Only Replica // and it will take reference of appbinding of the source // +optional - ReadReplica *MySQLReadReplicaSpec `json:"readReplica,omitempty"` + RemoteReplica *RemoteReplicaSpec `json:"remoteReplica,omitempty"` // +optional SemiSync *SemiSyncSpec `json:"semiSync,omitempty"` } @@ -246,11 +246,6 @@ type MySQLRouterSpec struct { PodTemplate *ofst.PodTemplateSpec `json:"podTemplate,omitempty"` } -type MySQLReadReplicaSpec struct { - // SourceRef specifies the source object - SourceRef core.ObjectReference `json:"sourceRef" protobuf:"bytes,1,opt,name=sourceRef"` -} - type MySQLStatus struct { // Specifies the current phase of the database // +optional diff --git a/apis/kubedb/v1alpha2/openapi_generated.go b/apis/kubedb/v1alpha2/openapi_generated.go index bad78232a2..588ee0c531 100644 --- a/apis/kubedb/v1alpha2/openapi_generated.go +++ b/apis/kubedb/v1alpha2/openapi_generated.go @@ -483,7 +483,6 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MySQLGroupSpec": schema_apimachinery_apis_kubedb_v1alpha2_MySQLGroupSpec(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MySQLInnoDBClusterSpec": schema_apimachinery_apis_kubedb_v1alpha2_MySQLInnoDBClusterSpec(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MySQLList": schema_apimachinery_apis_kubedb_v1alpha2_MySQLList(ref), - "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MySQLReadReplicaSpec": schema_apimachinery_apis_kubedb_v1alpha2_MySQLReadReplicaSpec(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MySQLRouterSpec": schema_apimachinery_apis_kubedb_v1alpha2_MySQLRouterSpec(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MySQLSpec": schema_apimachinery_apis_kubedb_v1alpha2_MySQLSpec(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MySQLStatus": schema_apimachinery_apis_kubedb_v1alpha2_MySQLStatus(ref), @@ -519,6 +518,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.RedisSentinelStatus": schema_apimachinery_apis_kubedb_v1alpha2_RedisSentinelStatus(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.RedisSpec": schema_apimachinery_apis_kubedb_v1alpha2_RedisSpec(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.RedisStatus": schema_apimachinery_apis_kubedb_v1alpha2_RedisStatus(ref), + "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.RemoteReplicaSpec": schema_apimachinery_apis_kubedb_v1alpha2_RemoteReplicaSpec(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.ScriptSourceSpec": schema_apimachinery_apis_kubedb_v1alpha2_ScriptSourceSpec(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SecretReference": schema_apimachinery_apis_kubedb_v1alpha2_SecretReference(ref), "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SemiSyncSpec": schema_apimachinery_apis_kubedb_v1alpha2_SemiSyncSpec(ref), @@ -24597,28 +24597,6 @@ func schema_apimachinery_apis_kubedb_v1alpha2_MySQLList(ref common.ReferenceCall } } -func schema_apimachinery_apis_kubedb_v1alpha2_MySQLReadReplicaSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { - return common.OpenAPIDefinition{ - Schema: spec.Schema{ - SchemaProps: spec.SchemaProps{ - Type: []string{"object"}, - Properties: map[string]spec.Schema{ - "sourceRef": { - SchemaProps: spec.SchemaProps{ - Description: "SourceRef specifies the source object", - Default: map[string]interface{}{}, - Ref: ref("k8s.io/api/core/v1.ObjectReference"), - }, - }, - }, - Required: []string{"sourceRef"}, - }, - }, - Dependencies: []string{ - "k8s.io/api/core/v1.ObjectReference"}, - } -} - func schema_apimachinery_apis_kubedb_v1alpha2_MySQLRouterSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ @@ -24879,10 +24857,10 @@ func schema_apimachinery_apis_kubedb_v1alpha2_MySQLTopology(ref common.Reference Ref: ref("kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MySQLInnoDBClusterSpec"), }, }, - "readReplica": { + "remoteReplica": { SchemaProps: spec.SchemaProps{ - Description: "ReadReplica implies that the instance will be a MySQL Read Only Replica and it will take reference of appbinding of the source", - Ref: ref("kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MySQLReadReplicaSpec"), + Description: "RemoteReplica implies that the instance will be a MySQL Read Only Replica and it will take reference of appbinding of the source", + Ref: ref("kubedb.dev/apimachinery/apis/kubedb/v1alpha2.RemoteReplicaSpec"), }, }, "semiSync": { @@ -24894,7 +24872,7 @@ func schema_apimachinery_apis_kubedb_v1alpha2_MySQLTopology(ref common.Reference }, }, Dependencies: []string{ - "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MySQLGroupSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MySQLInnoDBClusterSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MySQLReadReplicaSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SemiSyncSpec"}, + "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MySQLGroupSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.MySQLInnoDBClusterSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.RemoteReplicaSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SemiSyncSpec"}, } } @@ -25789,6 +25767,18 @@ func schema_apimachinery_apis_kubedb_v1alpha2_PostgresSpec(ref common.ReferenceC Format: "", }, }, + "mode": { + SchemaProps: spec.SchemaProps{ + Type: []string{"string"}, + Format: "", + }, + }, + "remoteReplica": { + SchemaProps: spec.SchemaProps{ + Description: "RemoteReplica implies that the instance will be a MySQL Read Only Replica, and it will take reference of appbinding of the source", + Ref: ref("kubedb.dev/apimachinery/apis/kubedb/v1alpha2.RemoteReplicaSpec"), + }, + }, "leaderElection": { SchemaProps: spec.SchemaProps{ Description: "Leader election configuration", @@ -25919,7 +25909,7 @@ func schema_apimachinery_apis_kubedb_v1alpha2_PostgresSpec(ref common.ReferenceC }, }, Dependencies: []string{ - "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.PersistentVolumeClaimSpec", "kmodules.xyz/client-go/api/v1.HealthCheckSpec", "kmodules.xyz/client-go/api/v1.TLSConfig", "kmodules.xyz/monitoring-agent-api/api/v1.AgentSpec", "kmodules.xyz/offshoot-api/api/v1.PodTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.AllowedConsumers", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.AutoOpsSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.CoordinatorSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.InitSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.NamedServiceTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.PostgreLeaderElectionConfig", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SecretReference"}, + "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.PersistentVolumeClaimSpec", "kmodules.xyz/client-go/api/v1.HealthCheckSpec", "kmodules.xyz/client-go/api/v1.TLSConfig", "kmodules.xyz/monitoring-agent-api/api/v1.AgentSpec", "kmodules.xyz/offshoot-api/api/v1.PodTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.AllowedConsumers", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.AutoOpsSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.CoordinatorSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.InitSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.NamedServiceTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.PostgreLeaderElectionConfig", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.RemoteReplicaSpec", "kubedb.dev/apimachinery/apis/kubedb/v1alpha2.SecretReference"}, } } @@ -26926,6 +26916,28 @@ func schema_apimachinery_apis_kubedb_v1alpha2_RedisStatus(ref common.ReferenceCa } } +func schema_apimachinery_apis_kubedb_v1alpha2_RemoteReplicaSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "sourceRef": { + SchemaProps: spec.SchemaProps{ + Description: "SourceRef specifies the source object", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ObjectReference"), + }, + }, + }, + Required: []string{"sourceRef"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.ObjectReference"}, + } +} + func schema_apimachinery_apis_kubedb_v1alpha2_ScriptSourceSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/apis/kubedb/v1alpha2/postgres_helpers.go b/apis/kubedb/v1alpha2/postgres_helpers.go index a771cd5276..6a91befe76 100644 --- a/apis/kubedb/v1alpha2/postgres_helpers.go +++ b/apis/kubedb/v1alpha2/postgres_helpers.go @@ -407,3 +407,7 @@ func (m *Postgres) SetHealthCheckerDefaults() { m.Spec.HealthChecker.FailureThreshold = pointer.Int32P(1) } } + +func (m *Postgres) IsRemoteReplica() bool { + return m.Spec.RemoteReplica != nil +} diff --git a/apis/kubedb/v1alpha2/postgres_types.go b/apis/kubedb/v1alpha2/postgres_types.go index c3fa13a2fd..5ccbfa386f 100644 --- a/apis/kubedb/v1alpha2/postgres_types.go +++ b/apis/kubedb/v1alpha2/postgres_types.go @@ -49,6 +49,13 @@ type Postgres struct { Spec PostgresSpec `json:"spec,omitempty"` Status PostgresStatus `json:"status,omitempty"` } +type PostgreSQLMode string + +const ( + PostgreSQLModeStandAlone PostgreSQLMode = "Standalone" + PostgreSQLModeRemoteReplica PostgreSQLMode = "RemoteReplica" + PostgreSQLModeCluster PostgreSQLMode = "Cluster" +) type PostgresSpec struct { // AutoOps contains configuration of automatic ops-request-recommendation generation @@ -67,6 +74,13 @@ type PostgresSpec struct { // Streaming mode StreamingMode *PostgresStreamingMode `json:"streamingMode,omitempty"` + // + optional + Mode *PostgreSQLMode `json:"mode,omitempty"` + // RemoteReplica implies that the instance will be a MySQL Read Only Replica, + // and it will take reference of appbinding of the source + // +optional + RemoteReplica *RemoteReplicaSpec `json:"remoteReplica,omitempty"` + // Leader election configuration // +optional LeaderElection *PostgreLeaderElectionConfig `json:"leaderElection,omitempty"` diff --git a/apis/kubedb/v1alpha2/types.go b/apis/kubedb/v1alpha2/types.go index 3c8b299409..2267983118 100644 --- a/apis/kubedb/v1alpha2/types.go +++ b/apis/kubedb/v1alpha2/types.go @@ -58,6 +58,11 @@ type GitRepo struct { AuthSecret *core.LocalObjectReference `json:"authSecret,omitempty"` } +type RemoteReplicaSpec struct { + // SourceRef specifies the source object + SourceRef core.ObjectReference `json:"sourceRef" protobuf:"bytes,1,opt,name=sourceRef"` +} + // +kubebuilder:validation:Enum=Provisioning;DataRestoring;Ready;Critical;NotReady;Halted;Unknown type DatabasePhase string diff --git a/apis/kubedb/v1alpha2/zz_generated.deepcopy.go b/apis/kubedb/v1alpha2/zz_generated.deepcopy.go index 61e80c2325..2b3dee64ab 100644 --- a/apis/kubedb/v1alpha2/zz_generated.deepcopy.go +++ b/apis/kubedb/v1alpha2/zz_generated.deepcopy.go @@ -1864,23 +1864,6 @@ func (in *MySQLList) DeepCopyObject() runtime.Object { return nil } -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *MySQLReadReplicaSpec) DeepCopyInto(out *MySQLReadReplicaSpec) { - *out = *in - out.SourceRef = in.SourceRef - return -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new MySQLReadReplicaSpec. -func (in *MySQLReadReplicaSpec) DeepCopy() *MySQLReadReplicaSpec { - if in == nil { - return nil - } - out := new(MySQLReadReplicaSpec) - in.DeepCopyInto(out) - return out -} - // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *MySQLRouterSpec) DeepCopyInto(out *MySQLRouterSpec) { *out = *in @@ -2030,9 +2013,9 @@ func (in *MySQLTopology) DeepCopyInto(out *MySQLTopology) { *out = new(MySQLInnoDBClusterSpec) (*in).DeepCopyInto(*out) } - if in.ReadReplica != nil { - in, out := &in.ReadReplica, &out.ReadReplica - *out = new(MySQLReadReplicaSpec) + if in.RemoteReplica != nil { + in, out := &in.RemoteReplica, &out.RemoteReplica + *out = new(RemoteReplicaSpec) **out = **in } if in.SemiSync != nil { @@ -2526,6 +2509,16 @@ func (in *PostgresSpec) DeepCopyInto(out *PostgresSpec) { *out = new(PostgresStreamingMode) **out = **in } + if in.Mode != nil { + in, out := &in.Mode, &out.Mode + *out = new(PostgreSQLMode) + **out = **in + } + if in.RemoteReplica != nil { + in, out := &in.RemoteReplica, &out.RemoteReplica + *out = new(RemoteReplicaSpec) + **out = **in + } if in.LeaderElection != nil { in, out := &in.LeaderElection, &out.LeaderElection *out = new(PostgreLeaderElectionConfig) @@ -3180,6 +3173,23 @@ func (in *RedisStatus) DeepCopy() *RedisStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *RemoteReplicaSpec) DeepCopyInto(out *RemoteReplicaSpec) { + *out = *in + out.SourceRef = in.SourceRef + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new RemoteReplicaSpec. +func (in *RemoteReplicaSpec) DeepCopy() *RemoteReplicaSpec { + if in == nil { + return nil + } + out := new(RemoteReplicaSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *ScriptSourceSpec) DeepCopyInto(out *ScriptSourceSpec) { *out = *in diff --git a/crds/kubedb.com_mysqls.yaml b/crds/kubedb.com_mysqls.yaml index 3963750ecb..3f7d9b573b 100644 --- a/crds/kubedb.com_mysqls.yaml +++ b/crds/kubedb.com_mysqls.yaml @@ -6322,10 +6322,10 @@ spec: enum: - GroupReplication - InnoDBCluster - - ReadReplica + - RemoteReplica - SemiSync type: string - readReplica: + remoteReplica: properties: sourceRef: properties: diff --git a/crds/kubedb.com_postgreses.yaml b/crds/kubedb.com_postgreses.yaml index c84379b061..c9809ff8b6 100644 --- a/crds/kubedb.com_postgreses.yaml +++ b/crds/kubedb.com_postgreses.yaml @@ -1157,6 +1157,8 @@ spec: default: 60s type: string type: object + mode: + type: string monitor: properties: agent: @@ -3662,6 +3664,29 @@ spec: type: array type: object type: object + remoteReplica: + properties: + sourceRef: + properties: + apiVersion: + type: string + fieldPath: + type: string + kind: + type: string + name: + type: string + namespace: + type: string + resourceVersion: + type: string + uid: + type: string + type: object + x-kubernetes-map-type: atomic + required: + - sourceRef + type: object replicas: format: int32 type: integer diff --git a/openapi/swagger.json b/openapi/swagger.json index 3a2e7ef558..f4c5217dd0 100644 --- a/openapi/swagger.json +++ b/openapi/swagger.json @@ -31736,19 +31736,6 @@ } ] }, - "dev.kubedb.apimachinery.apis.kubedb.v1alpha2.MySQLReadReplicaSpec": { - "type": "object", - "required": [ - "sourceRef" - ], - "properties": { - "sourceRef": { - "description": "SourceRef specifies the source object", - "default": {}, - "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" - } - } - }, "dev.kubedb.apimachinery.apis.kubedb.v1alpha2.MySQLRouterSpec": { "type": "object", "properties": { @@ -31905,9 +31892,9 @@ "description": "If set to - \"GroupReplication\", GroupSpec is required and MySQL servers will start a replication group", "type": "string" }, - "readReplica": { - "description": "ReadReplica implies that the instance will be a MySQL Read Only Replica and it will take reference of appbinding of the source", - "$ref": "#/definitions/dev.kubedb.apimachinery.apis.kubedb.v1alpha2.MySQLReadReplicaSpec" + "remoteReplica": { + "description": "RemoteReplica implies that the instance will be a MySQL Read Only Replica and it will take reference of appbinding of the source", + "$ref": "#/definitions/dev.kubedb.apimachinery.apis.kubedb.v1alpha2.RemoteReplicaSpec" }, "semiSync": { "$ref": "#/definitions/dev.kubedb.apimachinery.apis.kubedb.v1alpha2.SemiSyncSpec" @@ -32508,6 +32495,9 @@ "description": "Leader election configuration", "$ref": "#/definitions/dev.kubedb.apimachinery.apis.kubedb.v1alpha2.PostgreLeaderElectionConfig" }, + "mode": { + "type": "string" + }, "monitor": { "description": "Monitor is used monitor database instance", "$ref": "#/definitions/xyz.kmodules.monitoring-agent-api.api.v1.AgentSpec" @@ -32517,6 +32507,10 @@ "default": {}, "$ref": "#/definitions/xyz.kmodules.offshoot-api.api.v1.PodTemplateSpec" }, + "remoteReplica": { + "description": "RemoteReplica implies that the instance will be a MySQL Read Only Replica, and it will take reference of appbinding of the source", + "$ref": "#/definitions/dev.kubedb.apimachinery.apis.kubedb.v1alpha2.RemoteReplicaSpec" + }, "replicas": { "description": "Number of instances to deploy for a Postgres database.", "type": "integer", @@ -32994,6 +32988,19 @@ } } }, + "dev.kubedb.apimachinery.apis.kubedb.v1alpha2.RemoteReplicaSpec": { + "type": "object", + "required": [ + "sourceRef" + ], + "properties": { + "sourceRef": { + "description": "SourceRef specifies the source object", + "default": {}, + "$ref": "#/definitions/io.k8s.api.core.v1.ObjectReference" + } + } + }, "dev.kubedb.apimachinery.apis.kubedb.v1alpha2.ScriptSourceSpec": { "type": "object", "properties": {