Skip to content

Commit

Permalink
Add PITR replication strategy API (#1325)
Browse files Browse the repository at this point in the history
Signed-off-by: souravbiswassanto <saurov@appscode.com>
  • Loading branch information
souravbiswassanto authored Nov 8, 2024
1 parent 1777f43 commit c7aff23
Show file tree
Hide file tree
Showing 20 changed files with 197 additions and 2 deletions.
6 changes: 6 additions & 0 deletions apis/kubedb/v1/openapi_generated.go

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

4 changes: 4 additions & 0 deletions apis/kubedb/v1/postgres_helpers.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"k8s.io/apimachinery/pkg/api/resource"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/labels"
"k8s.io/utils/ptr"
kmapi "kmodules.xyz/client-go/api/v1"
"kmodules.xyz/client-go/apiextensions"
meta_util "kmodules.xyz/client-go/meta"
Expand Down Expand Up @@ -266,6 +267,9 @@ func (p *Postgres) SetDefaults(postgresVersion *catalog.PostgresVersion) {
p.Spec.Monitor.Prometheus.Exporter.SecurityContext.RunAsGroup = postgresVersion.Spec.SecurityContext.RunAsUser
}
}
if p.Spec.Init != nil && p.Spec.Init.Archiver != nil && p.Spec.Init.Archiver.ReplicationStrategy == nil {
p.Spec.Init.Archiver.ReplicationStrategy = ptr.To(ReplicationStrategyNone)
}
}

func getMajorPgVersion(postgresVersion *catalog.PostgresVersion) (uint64, error) {
Expand Down
18 changes: 17 additions & 1 deletion apis/kubedb/v1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,6 +133,21 @@ const (
StatsServiceAlias ServiceAlias = "stats"
)

// +kubebuilder:validation:Enum=fscopy;clone;sync;none
type PITRReplicationStrategy string

const (
// ReplicationStrategySync means data will be synced from primary to secondary
ReplicationStrategySync PITRReplicationStrategy = "sync"
// ReplicationStrategyFSCopy means data will be copied from filesystem
ReplicationStrategyFSCopy PITRReplicationStrategy = "fscopy"
// ReplicationStrategyClone means volumeSnapshot will be used to create pvc's
ReplicationStrategyClone PITRReplicationStrategy = "clone"
// ReplicationStrategyNone means no replication will be used
// data will be fully restored in every replicas instead of replication
ReplicationStrategyNone PITRReplicationStrategy = "none"
)

// +kubebuilder:validation:Enum=DNS;IP;IPv4;IPv6
type AddressType string

Expand Down Expand Up @@ -220,5 +235,6 @@ type ArchiverRecovery struct {
ManifestRepository *kmapi.ObjectReference `json:"manifestRepository,omitempty"`

// FullDBRepository means db restore + manifest restore
FullDBRepository *kmapi.ObjectReference `json:"fullDBRepository,omitempty"`
FullDBRepository *kmapi.ObjectReference `json:"fullDBRepository,omitempty"`
ReplicationStrategy *PITRReplicationStrategy `json:"replicationStrategy,omitempty"`
}
5 changes: 5 additions & 0 deletions apis/kubedb/v1/zz_generated.deepcopy.go

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

6 changes: 6 additions & 0 deletions apis/kubedb/v1alpha2/openapi_generated.go

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

18 changes: 17 additions & 1 deletion apis/kubedb/v1alpha2/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,21 @@ const (
SecondaryServiceAlias ServiceAlias = "secondary"
)

// +kubebuilder:validation:Enum=fscopy;clone;sync;none
type PITRReplicationStrategy string

const (
// ReplicationStrategySync means data will be synced from primary to secondary
ReplicationStrategySync PITRReplicationStrategy = "sync"
// ReplicationStrategyFSCopy means data will be copied from filesystem
ReplicationStrategyFSCopy PITRReplicationStrategy = "fscopy"
// ReplicationStrategyClone means volumeSnapshot will be used to create pvc's
ReplicationStrategyClone PITRReplicationStrategy = "clone"
// ReplicationStrategyNone means no replication will be used
// data will be restored instead of replication
ReplicationStrategyNone PITRReplicationStrategy = "none"
)

// +kubebuilder:validation:Enum=DNS;IP;IPv4;IPv6
type AddressType string

Expand Down Expand Up @@ -237,5 +252,6 @@ type ArchiverRecovery struct {
ManifestRepository *kmapi.ObjectReference `json:"manifestRepository,omitempty"`

// FullDBRepository means db restore + manifest restore
FullDBRepository *kmapi.ObjectReference `json:"fullDBRepository,omitempty"`
FullDBRepository *kmapi.ObjectReference `json:"fullDBRepository,omitempty"`
ReplicationStrategy *PITRReplicationStrategy `json:"replicationStrategy,omitempty"`
}
8 changes: 8 additions & 0 deletions apis/kubedb/v1alpha2/zz_generated.conversion.go

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

5 changes: 5 additions & 0 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.

7 changes: 7 additions & 0 deletions crds/kubedb.com_druids.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -147,6 +147,13 @@ spec:
recoveryTimestamp:
format: date-time
type: string
replicationStrategy:
enum:
- fscopy
- clone
- sync
- none
type: string
required:
- recoveryTimestamp
type: object
Expand Down
14 changes: 14 additions & 0 deletions crds/kubedb.com_elasticsearches.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,13 @@ spec:
recoveryTimestamp:
format: date-time
type: string
replicationStrategy:
enum:
- fscopy
- clone
- sync
- none
type: string
required:
- recoveryTimestamp
type: object
Expand Down Expand Up @@ -39771,6 +39778,13 @@ spec:
recoveryTimestamp:
format: date-time
type: string
replicationStrategy:
enum:
- fscopy
- clone
- sync
- none
type: string
required:
- recoveryTimestamp
type: object
Expand Down
7 changes: 7 additions & 0 deletions crds/kubedb.com_etcds.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,13 @@ spec:
recoveryTimestamp:
format: date-time
type: string
replicationStrategy:
enum:
- fscopy
- clone
- sync
- none
type: string
required:
- recoveryTimestamp
type: object
Expand Down
14 changes: 14 additions & 0 deletions crds/kubedb.com_mariadbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -224,6 +224,13 @@ spec:
recoveryTimestamp:
format: date-time
type: string
replicationStrategy:
enum:
- fscopy
- clone
- sync
- none
type: string
required:
- recoveryTimestamp
type: object
Expand Down Expand Up @@ -5090,6 +5097,13 @@ spec:
recoveryTimestamp:
format: date-time
type: string
replicationStrategy:
enum:
- fscopy
- clone
- sync
- none
type: string
required:
- recoveryTimestamp
type: object
Expand Down
14 changes: 14 additions & 0 deletions crds/kubedb.com_mongodbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6486,6 +6486,13 @@ spec:
recoveryTimestamp:
format: date-time
type: string
replicationStrategy:
enum:
- fscopy
- clone
- sync
- none
type: string
required:
- recoveryTimestamp
type: object
Expand Down Expand Up @@ -26217,6 +26224,13 @@ spec:
recoveryTimestamp:
format: date-time
type: string
replicationStrategy:
enum:
- fscopy
- clone
- sync
- none
type: string
required:
- recoveryTimestamp
type: object
Expand Down
7 changes: 7 additions & 0 deletions crds/kubedb.com_mssqlservers.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -250,6 +250,13 @@ spec:
recoveryTimestamp:
format: date-time
type: string
replicationStrategy:
enum:
- fscopy
- clone
- sync
- none
type: string
required:
- recoveryTimestamp
type: object
Expand Down
14 changes: 14 additions & 0 deletions crds/kubedb.com_mysqls.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -294,6 +294,13 @@ spec:
recoveryTimestamp:
format: date-time
type: string
replicationStrategy:
enum:
- fscopy
- clone
- sync
- none
type: string
required:
- recoveryTimestamp
type: object
Expand Down Expand Up @@ -8373,6 +8380,13 @@ spec:
recoveryTimestamp:
format: date-time
type: string
replicationStrategy:
enum:
- fscopy
- clone
- sync
- none
type: string
required:
- recoveryTimestamp
type: object
Expand Down
14 changes: 14 additions & 0 deletions crds/kubedb.com_perconaxtradbs.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -208,6 +208,13 @@ spec:
recoveryTimestamp:
format: date-time
type: string
replicationStrategy:
enum:
- fscopy
- clone
- sync
- none
type: string
required:
- recoveryTimestamp
type: object
Expand Down Expand Up @@ -5083,6 +5090,13 @@ spec:
recoveryTimestamp:
format: date-time
type: string
replicationStrategy:
enum:
- fscopy
- clone
- sync
- none
type: string
required:
- recoveryTimestamp
type: object
Expand Down
14 changes: 14 additions & 0 deletions crds/kubedb.com_postgreses.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,13 @@ spec:
recoveryTimestamp:
format: date-time
type: string
replicationStrategy:
enum:
- fscopy
- clone
- sync
- none
type: string
required:
- recoveryTimestamp
type: object
Expand Down Expand Up @@ -5301,6 +5308,13 @@ spec:
recoveryTimestamp:
format: date-time
type: string
replicationStrategy:
enum:
- fscopy
- clone
- sync
- none
type: string
required:
- recoveryTimestamp
type: object
Expand Down
Loading

0 comments on commit c7aff23

Please sign in to comment.