diff --git a/apis/kubedb/v1/openapi_generated.go b/apis/kubedb/v1/openapi_generated.go index f93c77f2c0..b8a4621dce 100644 --- a/apis/kubedb/v1/openapi_generated.go +++ b/apis/kubedb/v1/openapi_generated.go @@ -601,6 +601,7 @@ func GetOpenAPIDefinitions(ref common.ReferenceCallback) map[string]common.OpenA "kubedb.dev/apimachinery/apis/kubedb/v1.ProxySQLList": schema_apimachinery_apis_kubedb_v1_ProxySQLList(ref), "kubedb.dev/apimachinery/apis/kubedb/v1.ProxySQLSpec": schema_apimachinery_apis_kubedb_v1_ProxySQLSpec(ref), "kubedb.dev/apimachinery/apis/kubedb/v1.ProxySQLStatus": schema_apimachinery_apis_kubedb_v1_ProxySQLStatus(ref), + "kubedb.dev/apimachinery/apis/kubedb/v1.ReadReplicaSpec": schema_apimachinery_apis_kubedb_v1_ReadReplicaSpec(ref), "kubedb.dev/apimachinery/apis/kubedb/v1.RecoveryTarget": schema_apimachinery_apis_kubedb_v1_RecoveryTarget(ref), "kubedb.dev/apimachinery/apis/kubedb/v1.Redis": schema_apimachinery_apis_kubedb_v1_Redis(ref), "kubedb.dev/apimachinery/apis/kubedb/v1.RedisAclSpec": schema_apimachinery_apis_kubedb_v1_RedisAclSpec(ref), @@ -31311,12 +31312,25 @@ func schema_apimachinery_apis_kubedb_v1_PostgresSpec(ref common.ReferenceCallbac Ref: ref("kubedb.dev/apimachinery/apis/kubedb/v1.PostgresReplication"), }, }, + "readReaplicas": { + SchemaProps: spec.SchemaProps{ + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("kubedb.dev/apimachinery/apis/kubedb/v1.ReadReplicaSpec"), + }, + }, + }, + }, + }, }, Required: []string{"version"}, }, }, 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/v2.PodTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1.AllowedConsumers", "kubedb.dev/apimachinery/apis/kubedb/v1.ArbiterSpec", "kubedb.dev/apimachinery/apis/kubedb/v1.Archiver", "kubedb.dev/apimachinery/apis/kubedb/v1.AutoOpsSpec", "kubedb.dev/apimachinery/apis/kubedb/v1.InitSpec", "kubedb.dev/apimachinery/apis/kubedb/v1.NamedServiceTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1.PostgreLeaderElectionConfig", "kubedb.dev/apimachinery/apis/kubedb/v1.PostgresConfiguration", "kubedb.dev/apimachinery/apis/kubedb/v1.PostgresReplication", "kubedb.dev/apimachinery/apis/kubedb/v1.RemoteReplicaSpec", "kubedb.dev/apimachinery/apis/kubedb/v1.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/v2.PodTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1.AllowedConsumers", "kubedb.dev/apimachinery/apis/kubedb/v1.ArbiterSpec", "kubedb.dev/apimachinery/apis/kubedb/v1.Archiver", "kubedb.dev/apimachinery/apis/kubedb/v1.AutoOpsSpec", "kubedb.dev/apimachinery/apis/kubedb/v1.InitSpec", "kubedb.dev/apimachinery/apis/kubedb/v1.NamedServiceTemplateSpec", "kubedb.dev/apimachinery/apis/kubedb/v1.PostgreLeaderElectionConfig", "kubedb.dev/apimachinery/apis/kubedb/v1.PostgresConfiguration", "kubedb.dev/apimachinery/apis/kubedb/v1.PostgresReplication", "kubedb.dev/apimachinery/apis/kubedb/v1.ReadReplicaSpec", "kubedb.dev/apimachinery/apis/kubedb/v1.RemoteReplicaSpec", "kubedb.dev/apimachinery/apis/kubedb/v1.SecretReference"}, } } @@ -31773,6 +31787,97 @@ func schema_apimachinery_apis_kubedb_v1_ProxySQLStatus(ref common.ReferenceCallb } } +func schema_apimachinery_apis_kubedb_v1_ReadReplicaSpec(ref common.ReferenceCallback) common.OpenAPIDefinition { + return common.OpenAPIDefinition{ + Schema: spec.Schema{ + SchemaProps: spec.SchemaProps{ + Type: []string{"object"}, + Properties: map[string]spec.Schema{ + "name": { + SchemaProps: spec.SchemaProps{ + Description: "Name specifies the name of the read replica", + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + "replicas": { + SchemaProps: spec.SchemaProps{ + Description: "Number of instances to deploy for a Postgres database.", + Type: []string{"integer"}, + Format: "int32", + }, + }, + "resources": { + SchemaProps: spec.SchemaProps{ + Description: "Compute Resources required by the sidecar container.", + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.ResourceRequirements"), + }, + }, + "nodeSelector": { + VendorExtensible: spec.VendorExtensible{ + Extensions: spec.Extensions{ + "x-kubernetes-map-type": "atomic", + }, + }, + SchemaProps: spec.SchemaProps{ + Description: "NodeSelector is a selector which must be true for the pod to fit on a node. Selector which must match a node's labels for the pod to be scheduled on that node. More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/", + Type: []string{"object"}, + AdditionalProperties: &spec.SchemaOrBool{ + Allows: true, + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: "", + Type: []string{"string"}, + Format: "", + }, + }, + }, + }, + }, + "tolerations": { + SchemaProps: spec.SchemaProps{ + Description: "If specified, the pod's tolerations.", + Type: []string{"array"}, + Items: &spec.SchemaOrArray{ + Schema: &spec.Schema{ + SchemaProps: spec.SchemaProps{ + Default: map[string]interface{}{}, + Ref: ref("k8s.io/api/core/v1.Toleration"), + }, + }, + }, + }, + }, + "storageType": { + SchemaProps: spec.SchemaProps{ + Description: "StorageType can be durable (default) or ephemeral", + Type: []string{"string"}, + Format: "", + }, + }, + "storage": { + SchemaProps: spec.SchemaProps{ + Description: "Storage to specify how storage shall be used.", + Ref: ref("k8s.io/api/core/v1.PersistentVolumeClaimSpec"), + }, + }, + "podPlacementPolicy": { + SchemaProps: spec.SchemaProps{ + Description: "PodPlacementPolicy is the reference of the podPlacementPolicy", + Ref: ref("k8s.io/api/core/v1.LocalObjectReference"), + }, + }, + }, + Required: []string{"name"}, + }, + }, + Dependencies: []string{ + "k8s.io/api/core/v1.LocalObjectReference", "k8s.io/api/core/v1.PersistentVolumeClaimSpec", "k8s.io/api/core/v1.ResourceRequirements", "k8s.io/api/core/v1.Toleration"}, + } +} + func schema_apimachinery_apis_kubedb_v1_RecoveryTarget(ref common.ReferenceCallback) common.OpenAPIDefinition { return common.OpenAPIDefinition{ Schema: spec.Schema{ diff --git a/apis/kubedb/v1/postgres_types.go b/apis/kubedb/v1/postgres_types.go index 5d7b7516cc..3c7b9cabe8 100644 --- a/apis/kubedb/v1/postgres_types.go +++ b/apis/kubedb/v1/postgres_types.go @@ -169,6 +169,9 @@ type PostgresSpec struct { // +optional Replication *PostgresReplication `json:"replication,omitempty"` + + // +optional + ReadReaplicas []ReadReplicaSpec `json:"readReaplicas,omitempty"` } type PostgresConfiguration struct { @@ -219,6 +222,33 @@ type ArbiterSpec struct { Tolerations []core.Toleration `json:"tolerations,omitempty"` } +type ReadReplicaSpec struct { + // Name specifies the name of the read replica + Name string `json:"name"` + // Number of instances to deploy for a Postgres database. + Replicas *int32 `json:"replicas,omitempty"` + // Compute Resources required by the sidecar container. + // +optional + Resources core.ResourceRequirements `json:"resources,omitempty"` + // NodeSelector is a selector which must be true for the pod to fit on a node. + // Selector which must match a node's labels for the pod to be scheduled on that node. + // More info: https://kubernetes.io/docs/concepts/configuration/assign-pod-node/ + // +optional + // +mapType=atomic + NodeSelector map[string]string `json:"nodeSelector,omitempty"` + // If specified, the pod's tolerations. + // +optional + Tolerations []core.Toleration `json:"tolerations,omitempty"` + // StorageType can be durable (default) or ephemeral + StorageType StorageType `json:"storageType,omitempty"` + // Storage to specify how storage shall be used. + Storage *core.PersistentVolumeClaimSpec `json:"storage,omitempty"` + // PodPlacementPolicy is the reference of the podPlacementPolicy + // +kubebuilder:default={name:"default"} + // +optional + PodPlacementPolicy *core.LocalObjectReference `json:"podPlacementPolicy,omitempty"` +} + // PostgreLeaderElectionConfig contains essential attributes of leader election. type PostgreLeaderElectionConfig struct { // LeaseDuration is the duration in second that non-leader candidates will diff --git a/apis/kubedb/v1/zz_generated.deepcopy.go b/apis/kubedb/v1/zz_generated.deepcopy.go index e1c5a39a2f..9a3f38e771 100644 --- a/apis/kubedb/v1/zz_generated.deepcopy.go +++ b/apis/kubedb/v1/zz_generated.deepcopy.go @@ -2835,6 +2835,13 @@ func (in *PostgresSpec) DeepCopyInto(out *PostgresSpec) { *out = new(PostgresReplication) (*in).DeepCopyInto(*out) } + if in.ReadReaplicas != nil { + in, out := &in.ReadReaplicas, &out.ReadReaplicas + *out = make([]ReadReplicaSpec, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } return } @@ -3148,6 +3155,52 @@ func (in *ProxySQLStatus) DeepCopy() *ProxySQLStatus { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ReadReplicaSpec) DeepCopyInto(out *ReadReplicaSpec) { + *out = *in + if in.Replicas != nil { + in, out := &in.Replicas, &out.Replicas + *out = new(int32) + **out = **in + } + in.Resources.DeepCopyInto(&out.Resources) + 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.Tolerations != nil { + in, out := &in.Tolerations, &out.Tolerations + *out = make([]corev1.Toleration, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } + if in.Storage != nil { + in, out := &in.Storage, &out.Storage + *out = new(corev1.PersistentVolumeClaimSpec) + (*in).DeepCopyInto(*out) + } + if in.PodPlacementPolicy != nil { + in, out := &in.PodPlacementPolicy, &out.PodPlacementPolicy + *out = new(corev1.LocalObjectReference) + **out = **in + } + return +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ReadReplicaSpec. +func (in *ReadReplicaSpec) DeepCopy() *ReadReplicaSpec { + if in == nil { + return nil + } + out := new(ReadReplicaSpec) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *RecoveryTarget) DeepCopyInto(out *RecoveryTarget) { *out = *in diff --git a/apis/kubedb/v1alpha2/zz_generated.conversion.go b/apis/kubedb/v1alpha2/zz_generated.conversion.go index 6f7b185691..45ae133ebc 100644 --- a/apis/kubedb/v1alpha2/zz_generated.conversion.go +++ b/apis/kubedb/v1alpha2/zz_generated.conversion.go @@ -3855,6 +3855,7 @@ func autoConvert_v1_PostgresSpec_To_v1alpha2_PostgresSpec(in *v1.PostgresSpec, o out.Archiver = (*Archiver)(unsafe.Pointer(in.Archiver)) out.Arbiter = (*ArbiterSpec)(unsafe.Pointer(in.Arbiter)) out.Replication = (*PostgresReplication)(unsafe.Pointer(in.Replication)) + // WARNING: in.ReadReaplicas requires manual conversion: does not exist in peer-type return nil } diff --git a/crds/gitops.kubedb.com_postgreses.yaml b/crds/gitops.kubedb.com_postgreses.yaml index ae9f9233fa..f76771ff5e 100644 --- a/crds/gitops.kubedb.com_postgreses.yaml +++ b/crds/gitops.kubedb.com_postgreses.yaml @@ -4851,6 +4851,174 @@ spec: type: array type: object type: object + readReaplicas: + items: + properties: + name: + type: string + nodeSelector: + additionalProperties: + type: string + type: object + x-kubernetes-map-type: atomic + podPlacementPolicy: + default: + name: default + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + replicas: + format: int32 + type: integer + resources: + properties: + claims: + items: + properties: + name: + type: string + request: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + storage: + properties: + accessModes: + items: + type: string + type: array + x-kubernetes-list-type: atomic + dataSource: + properties: + apiGroup: + type: string + kind: + type: string + name: + type: string + required: + - kind + - name + type: object + x-kubernetes-map-type: atomic + dataSourceRef: + properties: + apiGroup: + type: string + kind: + type: string + name: + type: string + namespace: + type: string + required: + - kind + - name + type: object + resources: + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + selector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + storageClassName: + type: string + volumeAttributesClassName: + type: string + volumeMode: + type: string + volumeName: + type: string + type: object + storageType: + enum: + - Durable + - Ephemeral + type: string + tolerations: + items: + properties: + effect: + type: string + key: + type: string + operator: + type: string + tolerationSeconds: + format: int64 + type: integer + value: + type: string + type: object + type: array + required: + - name + type: object + type: array remoteReplica: properties: sourceRef: diff --git a/crds/kubedb.com_postgreses.yaml b/crds/kubedb.com_postgreses.yaml index 4a70f36e30..f16d41805a 100644 --- a/crds/kubedb.com_postgreses.yaml +++ b/crds/kubedb.com_postgreses.yaml @@ -4873,6 +4873,174 @@ spec: type: array type: object type: object + readReaplicas: + items: + properties: + name: + type: string + nodeSelector: + additionalProperties: + type: string + type: object + x-kubernetes-map-type: atomic + podPlacementPolicy: + default: + name: default + properties: + name: + default: "" + type: string + type: object + x-kubernetes-map-type: atomic + replicas: + format: int32 + type: integer + resources: + properties: + claims: + items: + properties: + name: + type: string + request: + type: string + required: + - name + type: object + type: array + x-kubernetes-list-map-keys: + - name + x-kubernetes-list-type: map + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + storage: + properties: + accessModes: + items: + type: string + type: array + x-kubernetes-list-type: atomic + dataSource: + properties: + apiGroup: + type: string + kind: + type: string + name: + type: string + required: + - kind + - name + type: object + x-kubernetes-map-type: atomic + dataSourceRef: + properties: + apiGroup: + type: string + kind: + type: string + name: + type: string + namespace: + type: string + required: + - kind + - name + type: object + resources: + properties: + limits: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + requests: + additionalProperties: + anyOf: + - type: integer + - type: string + pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ + x-kubernetes-int-or-string: true + type: object + type: object + selector: + properties: + matchExpressions: + items: + properties: + key: + type: string + operator: + type: string + values: + items: + type: string + type: array + x-kubernetes-list-type: atomic + required: + - key + - operator + type: object + type: array + x-kubernetes-list-type: atomic + matchLabels: + additionalProperties: + type: string + type: object + type: object + x-kubernetes-map-type: atomic + storageClassName: + type: string + volumeAttributesClassName: + type: string + volumeMode: + type: string + volumeName: + type: string + type: object + storageType: + enum: + - Durable + - Ephemeral + type: string + tolerations: + items: + properties: + effect: + type: string + key: + type: string + operator: + type: string + tolerationSeconds: + format: int64 + type: integer + value: + type: string + type: object + type: array + required: + - name + type: object + type: array remoteReplica: properties: sourceRef: