v1alpha1

package
v0.5.3-beta.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 12, 2023 License: AGPL-3.0 Imports: 10 Imported by: 8

Documentation

Overview

+k8s:deepcopy-gen=package,register +k8s:openapi-gen=true +groupName=dataprotection.kubeblocks.io

Package v1alpha1 contains API Schema definitions for the dataprotection v1alpha1 API group +kubebuilder:object:generate=true +groupName=dataprotection.kubeblocks.io

Index

Constants

This section is empty.

Variables

View Source
var (
	// GroupVersion is group version used to register these objects
	GroupVersion = schema.GroupVersion{Group: "dataprotection.kubeblocks.io", Version: "v1alpha1"}

	// SchemeBuilder is used to add go types to the GroupVersionKind scheme
	SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

	// AddToScheme adds the types in this group-version to the given scheme.
	AddToScheme = SchemeBuilder.AddToScheme
)

Functions

func ToDuration

func ToDuration(ttl *string) time.Duration

ToDuration converts the ttl string to time.Duration.

Types

type Backup

type Backup struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   BackupSpec   `json:"spec,omitempty"`
	Status BackupStatus `json:"status,omitempty"`
}

Backup is the Schema for the backups API (defined by User).

type BackupList

type BackupList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []Backup `json:"items"`
}

BackupList contains a list of Backup.

type BackupLogStatus

type BackupLogStatus struct {
	// startTime records the start time of data logging.
	// +optional
	StartTime *metav1.Time `json:"startTime,omitempty"`

	// stopTime records the stop time of data logging.
	// +optional
	StopTime *metav1.Time `json:"stopTime,omitempty"`
}

func GetRecoverableTimeRange

func GetRecoverableTimeRange(backups []Backup) []BackupLogStatus

GetRecoverableTimeRange returns the recoverable time range array.

type BackupPhase

type BackupPhase string

BackupPhase The current phase. Valid values are New, InProgress, Completed, Failed. +enum +kubebuilder:validation:Enum={New,InProgress,Completed,Failed}

const (
	BackupNew        BackupPhase = "New"
	BackupInProgress BackupPhase = "InProgress"
	BackupCompleted  BackupPhase = "Completed"
	BackupFailed     BackupPhase = "Failed"
)

type BackupPolicy

type BackupPolicy struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   BackupPolicySpec   `json:"spec,omitempty"`
	Status BackupPolicyStatus `json:"status,omitempty"`
}

BackupPolicy is the Schema for the backuppolicies API (defined by User)

type BackupPolicyHook

type BackupPolicyHook struct {
	// pre backup to perform commands
	// +optional
	PreCommands []string `json:"preCommands,omitempty"`

	// post backup to perform commands
	// +optional
	PostCommands []string `json:"postCommands,omitempty"`

	// exec command with image
	// +optional
	Image string `json:"image,omitempty"`

	// which container can exec command
	// +optional
	ContainerName string `json:"containerName,omitempty"`
}

BackupPolicyHook defines for the database execute commands before and after backup.

type BackupPolicyList

type BackupPolicyList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []BackupPolicy `json:"items"`
}

BackupPolicyList contains a list of BackupPolicy

type BackupPolicyPhase

type BackupPolicyPhase string

BackupPolicyPhase defines phases for BackupPolicy CR. +enum +kubebuilder:validation:Enum={Available,Failed}

const (
	PolicyAvailable BackupPolicyPhase = "Available"
	PolicyFailed    BackupPolicyPhase = "Failed"
)

type BackupPolicySecret

type BackupPolicySecret struct {
	// the secret name
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	Name string `json:"name"`

	// usernameKey the map key of the user in the connection credential secret
	// +kubebuilder:validation:Required
	// +kubebuilder:default=username
	UsernameKey string `json:"usernameKey,omitempty"`

	// passwordKey the map key of the password in the connection credential secret
	// +kubebuilder:validation:Required
	// +kubebuilder:default=password
	PasswordKey string `json:"passwordKey,omitempty"`
}

BackupPolicySecret defines for the target database secret that backup tool can connect.

type BackupPolicySpec

type BackupPolicySpec struct {
	// retention describe how long the Backup should be retained. if not set, will be retained forever.
	// +optional
	Retention *RetentionSpec `json:"retention,omitempty"`

	// schedule policy for backup.
	// +optional
	Schedule Schedule `json:"schedule,omitempty"`

	// the policy for snapshot backup.
	// +optional
	Snapshot *SnapshotPolicy `json:"snapshot,omitempty"`

	// the policy for datafile backup.
	// +optional
	Datafile *CommonBackupPolicy `json:"datafile,omitempty"`

	// the policy for logfile backup.
	// +optional
	Logfile *CommonBackupPolicy `json:"logfile,omitempty"`
}

BackupPolicySpec defines the desired state of BackupPolicy

func (*BackupPolicySpec) GetCommonPolicy

func (r *BackupPolicySpec) GetCommonPolicy(backupType BackupType) *CommonBackupPolicy

func (*BackupPolicySpec) GetCommonSchedulePolicy

func (r *BackupPolicySpec) GetCommonSchedulePolicy(backupType BackupType) *SchedulePolicy

type BackupPolicyStatus

type BackupPolicyStatus struct {

	// observedGeneration is the most recent generation observed for this
	// BackupPolicy. It corresponds to the Cluster's generation, which is
	// updated on mutation by the API Server.
	// +optional
	ObservedGeneration int64 `json:"observedGeneration,omitempty"`

	// backup policy phase valid value: Available, Failed.
	// +optional
	Phase BackupPolicyPhase `json:"phase,omitempty"`

	// the reason if backup policy check failed.
	// +optional
	FailureReason string `json:"failureReason,omitempty"`

	// information when was the last time the job was successfully scheduled.
	// +optional
	LastScheduleTime *metav1.Time `json:"lastScheduleTime,omitempty"`

	// information when was the last time the job successfully completed.
	// +optional
	LastSuccessfulTime *metav1.Time `json:"lastSuccessfulTime,omitempty"`
}

BackupPolicyStatus defines the observed state of BackupPolicy

type BackupSnapshotStatus

type BackupSnapshotStatus struct {
	// volumeSnapshotName records the volumeSnapshot name.
	// +optional
	VolumeSnapshotName string `json:"volumeSnapshotName,omitempty"`

	// volumeSnapshotContentName specifies the name of a pre-existing VolumeSnapshotContent
	// object representing an existing volume snapshot.
	// This field should be set if the snapshot already exists and only needs a representation in Kubernetes.
	// This field is immutable.
	// +optional
	VolumeSnapshotContentName string `json:"volumeSnapshotContentName,omitempty"`
}

type BackupSpec

type BackupSpec struct {
	// Which backupPolicy is applied to perform this backup
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	BackupPolicyName string `json:"backupPolicyName"`

	// Backup Type. datafile or logfile or snapshot. If not set, datafile is the default type.
	// +kubebuilder:default=datafile
	BackupType BackupType `json:"backupType"`

	// if backupType is incremental, parentBackupName is required.
	// +optional
	ParentBackupName string `json:"parentBackupName,omitempty"`
}

BackupSpec defines the desired state of Backup.

func (*BackupSpec) Validate

func (r *BackupSpec) Validate(backupPolicy *BackupPolicy) error

Validate validates the BackupSpec and returns an error if invalid.

type BackupStatus

type BackupStatus struct {
	// +optional
	Phase BackupPhase `json:"phase,omitempty"`

	// Records parentBackupName if backupType is incremental.
	// +optional
	ParentBackupName string `json:"parentBackupName,omitempty"`

	// The date and time when the Backup is eligible for garbage collection.
	// 'null' means the Backup is NOT be cleaned except delete manual.
	// +optional
	Expiration *metav1.Time `json:"expiration,omitempty"`

	// Date/time when the backup started being processed.
	// +optional
	StartTimestamp *metav1.Time `json:"startTimestamp,omitempty"`

	// Date/time when the backup finished being processed.
	// +optional
	CompletionTimestamp *metav1.Time `json:"completionTimestamp,omitempty"`

	// The duration time of backup execution.
	// When converted to a string, the form is "1h2m0.5s".
	// +optional
	Duration *metav1.Duration `json:"duration,omitempty"`

	// Backup total size.
	// A string with capacity units in the form of "1Gi", "1Mi", "1Ki".
	// +optional
	TotalSize string `json:"totalSize,omitempty"`

	// The reason for a backup failure.
	// +optional
	FailureReason string `json:"failureReason,omitempty"`

	// remoteVolume saves the backup data.
	// +optional
	PersistentVolumeClaimName string `json:"persistentVolumeClaimName,omitempty"`

	// backupToolName references the backup tool name.
	// +optional
	BackupToolName string `json:"backupToolName,omitempty"`

	// manifests determines the backup metadata info.
	// +optional
	Manifests *ManifestsStatus `json:"manifests,omitempty"`
}

BackupStatus defines the observed state of Backup.

type BackupStatusUpdate

type BackupStatusUpdate struct {
	// specify the json path of backup object for patch.
	// example: manifests.backupLog -- means patch the backup json path of status.manifests.backupLog.
	// +optional
	Path string `json:"path,omitempty"`

	// which container name that kubectl can execute.
	// +optional
	ContainerName string `json:"containerName,omitempty"`

	// the shell Script commands to collect backup status metadata.
	// The script must exist in the container of ContainerName and the output format must be set to JSON.
	// Note that outputting to stderr may cause the result format to not be in JSON.
	// +optional
	Script string `json:"script,omitempty"`

	// when to update the backup status, pre: before backup, post: after backup
	// +optional
	UpdateStage BackupStatusUpdateStage `json:"updateStage,omitempty"`
}

type BackupStatusUpdateStage

type BackupStatusUpdateStage string

BackupStatusUpdateStage defines the stage of backup status update. +enum +kubebuilder:validation:Enum={pre,post}

const (
	PRE  BackupStatusUpdateStage = "pre"
	POST BackupStatusUpdateStage = "post"
)

type BackupTool

type BackupTool struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   BackupToolSpec   `json:"spec,omitempty"`
	Status BackupToolStatus `json:"status,omitempty"`
}

BackupTool is the Schema for the backuptools API (defined by provider)

type BackupToolList

type BackupToolList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []BackupTool `json:"items"`
}

BackupToolList contains a list of BackupTool

type BackupToolManifestsStatus

type BackupToolManifestsStatus struct {
	// filePath records the file path of backup.
	// +optional
	FilePath string `json:"filePath,omitempty"`

	// Backup upload total size.
	// A string with capacity units in the form of "1Gi", "1Mi", "1Ki".
	// +optional
	UploadTotalSize string `json:"uploadTotalSize,omitempty"`

	// Checksum of backup file, generated by md5 or sha1 or sha256.
	// +optional
	CheckSum string `json:"checkSum,omitempty"`

	// backup check point, for incremental backup.
	// +optional
	CheckPoint string `json:"CheckPoint,omitempty"`
}

type BackupToolRestoreCommand

type BackupToolRestoreCommand struct {
	// Array of command that apps can perform database restore.
	// like xtrabackup, that can performs restore mysql from files.
	// +optional
	RestoreCommands []string `json:"restoreCommands"`

	// Array of incremental restore commands.
	// +optional
	IncrementalRestoreCommands []string `json:"incrementalRestoreCommands,omitempty"`
}

BackupToolRestoreCommand defines the restore commands of BackupTool

type BackupToolSpec

type BackupToolSpec struct {
	// Backup tool Container image name.
	// +kubebuilder:validation:Required
	Image string `json:"image"`

	// which kind for run a backup tool.
	// +kubebuilder:validation:Enum={job,daemon}
	// +kubebuilder:default=job
	DeployKind string `json:"deployKind,omitempty"`

	// the type of backup tool, file or pitr
	// +kubebuilder:validation:Enum={file,pitr}
	// +kubebuilder:default=file
	Type string `json:"type,omitempty"`

	// Compute Resources required by this container.
	// Cannot be updated.
	// +kubebuilder:pruning:PreserveUnknownFields
	// +optional
	Resources *corev1.ResourceRequirements `json:"resources,omitempty"`

	// List of environment variables to set in the container.
	// +kubebuilder:pruning:PreserveUnknownFields
	// +optional
	Env []corev1.EnvVar `json:"env,omitempty" patchStrategy:"merge" patchMergeKey:"name"`

	// List of sources to populate environment variables in the container.
	// The keys defined within a source must be a C_IDENTIFIER. All invalid keys
	// will be reported as an event when the container is starting. When a key exists in multiple
	// sources, the value associated with the last source will take precedence.
	// Values defined by an Env with a duplicate key will take precedence.
	// Cannot be updated.
	// +kubebuilder:pruning:PreserveUnknownFields
	// +optional
	EnvFrom []corev1.EnvFromSource `json:"envFrom,omitempty"`

	// Array of command that apps can do database backup.
	// from invoke args
	// the order of commands follows the order of array.
	// +kubebuilder:validation:Required
	BackupCommands []string `json:"backupCommands"`

	// Array of command that apps can do database incremental backup.
	// like xtrabackup, that can performs an incremental backup file.
	// +optional
	IncrementalBackupCommands []string `json:"incrementalBackupCommands,omitempty"`

	// backup tool can support physical restore, in this case, restore must be RESTART database.
	// +kubebuilder:validation:Required
	Physical BackupToolRestoreCommand `json:"physical"`

	// backup tool can support logical restore, in this case, restore NOT RESTART database.
	// +optional
	Logical *BackupToolRestoreCommand `json:"logical,omitempty"`
}

BackupToolSpec defines the desired state of BackupTool

type BackupToolStatus

type BackupToolStatus struct {
}

BackupToolStatus defines the observed state of BackupTool

type BackupType

type BackupType string

BackupType the backup type, marked backup set is datafile or logfile or snapshot. +enum +kubebuilder:validation:Enum={datafile,logfile,snapshot}

const (
	BackupTypeDataFile BackupType = "datafile"
	BackupTypeLogFile  BackupType = "logfile"
	BackupTypeSnapshot BackupType = "snapshot"
)

type BaseBackupType

type BaseBackupType string

BaseBackupType the base backup type. +enum +kubebuilder:validation:Enum={full,snapshot}

type BasePolicy

type BasePolicy struct {
	// target database cluster for backup.
	// +kubebuilder:validation:Required
	Target TargetCluster `json:"target"`

	// the number of automatic backups to retain. Value must be non-negative integer.
	// 0 means NO limit on the number of backups.
	// +kubebuilder:default=7
	// +optional
	BackupsHistoryLimit int32 `json:"backupsHistoryLimit,omitempty"`

	// count of backup stop retries on fail.
	// +optional
	OnFailAttempted int32 `json:"onFailAttempted,omitempty"`

	// define how to update metadata for backup status.
	// +optional
	BackupStatusUpdates []BackupStatusUpdate `json:"backupStatusUpdates,omitempty"`
}

type CommonBackupPolicy

type CommonBackupPolicy struct {
	BasePolicy `json:",inline"`

	// refer to PersistentVolumeClaim and the backup data will be stored in the corresponding persistent volume.
	// +kubebuilder:validation:Required
	PersistentVolumeClaim PersistentVolumeClaim `json:"persistentVolumeClaim"`

	// which backup tool to perform database backup, only support one tool.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	BackupToolName string `json:"backupToolName,omitempty"`
}

type CreatePVCPolicy

type CreatePVCPolicy string

CreatePVCPolicy the policy how to create the PersistentVolumeClaim for backup. +enum +kubebuilder:validation:Enum={IfNotPresent,Never}

const (
	CreatePVCPolicyNever        CreatePVCPolicy = "Never"
	CreatePVCPolicyIfNotPresent CreatePVCPolicy = "IfNotPresent"
)

type ManifestsStatus

type ManifestsStatus struct {
	// backupLog records startTime and stopTime of data logging.
	// +optional
	BackupLog *BackupLogStatus `json:"backupLog,omitempty"`

	// target records the target cluster metadata string, which is in JSON format.
	// +optional
	Target string `json:"target,omitempty"`

	// snapshot records the volume snapshot metadata.
	// +optional
	Snapshot *BackupSnapshotStatus `json:"backupSnapshot,omitempty"`

	// backupTool records information about backup files generated by the backup tool.
	// +optional
	BackupTool *BackupToolManifestsStatus `json:"backupTool,omitempty"`

	// userContext stores some loosely structured and extensible information.
	// +optional
	UserContext map[string]string `json:"userContext,omitempty"`
}

type PersistentVolumeClaim

type PersistentVolumeClaim struct {
	// the name of the PersistentVolumeClaim.
	Name string `json:"name"`

	// storageClassName is the name of the StorageClass required by the claim.
	// +optional
	StorageClassName *string `json:"storageClassName,omitempty"`

	// initCapacity represents the init storage size of the PersistentVolumeClaim which should be created if not exist.
	// and the default value is 100Gi if it is empty.
	// +optional
	InitCapacity resource.Quantity `json:"initCapacity,omitempty"`

	// createPolicy defines the policy for creating the PersistentVolumeClaim, enum values:
	// - Never: do nothing if the PersistentVolumeClaim not exists.
	// - IfNotPresent: create the PersistentVolumeClaim if not present and the accessModes only contains 'ReadWriteMany'.
	// +kubebuilder:default=IfNotPresent
	// +optional
	CreatePolicy CreatePVCPolicy `json:"createPolicy"`

	// persistentVolumeConfigMap references the configmap which contains a persistentVolume template.
	// key must be "persistentVolume" and value is the "PersistentVolume" struct.
	// support the following built-in Objects:
	// - $(GENERATE_NAME): generate a specific format "pvcName-pvcNamespace".
	// if the PersistentVolumeClaim not exists and CreatePolicy is "IfNotPresent", the controller
	// will create it by this template. this is a mutually exclusive setting with "storageClassName".
	// +optional
	PersistentVolumeConfigMap *PersistentVolumeConfigMap `json:"persistentVolumeConfigMap,omitempty"`
}

type PersistentVolumeConfigMap

type PersistentVolumeConfigMap struct {
	// the name of the persistentVolume ConfigMap.
	// +kubebuilder:validation:Required
	Name string `json:"name"`

	// the namespace of the persistentVolume ConfigMap.
	// +kubebuilder:validation:Required
	Namespace string `json:"namespace"`
}

type RestoreJob

type RestoreJob struct {
	metav1.TypeMeta   `json:",inline"`
	metav1.ObjectMeta `json:"metadata,omitempty"`

	Spec   RestoreJobSpec   `json:"spec,omitempty"`
	Status RestoreJobStatus `json:"status,omitempty"`
}

RestoreJob is the Schema for the restorejobs API (defined by User)

type RestoreJobList

type RestoreJobList struct {
	metav1.TypeMeta `json:",inline"`
	metav1.ListMeta `json:"metadata,omitempty"`
	Items           []RestoreJob `json:"items"`
}

RestoreJobList contains a list of RestoreJob

type RestoreJobPhase

type RestoreJobPhase string

RestoreJobPhase The current phase. Valid values are New, InProgressPhy, InProgressLogic, Completed, Failed. +enum +kubebuilder:validation:Enum={New,InProgressPhy,InProgressLogic,Completed,Failed}

const (
	RestoreJobNew             RestoreJobPhase = "New"
	RestoreJobInProgressPhy   RestoreJobPhase = "InProgressPhy"
	RestoreJobInProgressLogic RestoreJobPhase = "InProgressLogic"
	RestoreJobCompleted       RestoreJobPhase = "Completed"
	RestoreJobFailed          RestoreJobPhase = "Failed"
)

type RestoreJobSpec

type RestoreJobSpec struct {
	// Specified one backupJob to restore.
	// +kubebuilder:validation:Required
	BackupJobName string `json:"backupJobName"`

	// the target database workload to restore
	// +kubebuilder:validation:Required
	Target TargetCluster `json:"target"`

	// array of restore volumes .
	// +kubebuilder:validation:MinItems=1
	// +kubebuilder:pruning:PreserveUnknownFields
	TargetVolumes []corev1.Volume `json:"targetVolumes" patchStrategy:"merge,retainKeys" patchMergeKey:"name"`

	// array of restore volume mounts .
	// +kubebuilder:validation:MinItems=1
	// +kubebuilder:pruning:PreserveUnknownFields
	TargetVolumeMounts []corev1.VolumeMount `json:"targetVolumeMounts" patchStrategy:"merge" patchMergeKey:"mountPath"`

	// count of backup stop retries on fail.
	// +optional
	OnFailAttempted int32 `json:"onFailAttempted,omitempty"`
}

RestoreJobSpec defines the desired state of RestoreJob

type RestoreJobStatus

type RestoreJobStatus struct {

	// +optional
	Phase RestoreJobPhase `json:"phase,omitempty"`

	// The date and time when the Backup is eligible for garbage collection.
	// 'null' means the Backup is NOT be cleaned except delete manual.
	// +optional
	Expiration *metav1.Time `json:"expiration,omitempty"`

	// Date/time when the backup started being processed.
	// +optional
	StartTimestamp *metav1.Time `json:"startTimestamp,omitempty"`

	// Date/time when the backup finished being processed.
	// +optional
	CompletionTimestamp *metav1.Time `json:"completionTimestamp,omitempty"`

	// Job failed reason.
	// +optional
	FailureReason string `json:"failureReason,omitempty"`
}

RestoreJobStatus defines the observed state of RestoreJob

type RetentionSpec

type RetentionSpec struct {
	// ttl is a time string ending with the 'd'|'D'|'h'|'H' character to describe how long
	// the Backup should be retained. if not set, will be retained forever.
	// +kubebuilder:validation:Pattern:=`^\d+[d|D|h|H]$`
	// +optional
	TTL *string `json:"ttl,omitempty"`
}

type Schedule

type Schedule struct {
	// schedule policy for snapshot backup.
	// +optional
	Snapshot *SchedulePolicy `json:"snapshot,omitempty"`

	// schedule policy for datafile backup.
	// +optional
	Datafile *SchedulePolicy `json:"datafile,omitempty"`

	// schedule policy for logfile backup.
	// +optional
	Logfile *SchedulePolicy `json:"logfile,omitempty"`
}

type SchedulePolicy

type SchedulePolicy struct {
	// the cron expression for schedule, the timezone is in UTC. see https://en.wikipedia.org/wiki/Cron.
	// +kubebuilder:validation:Required
	CronExpression string `json:"cronExpression"`

	// enable or disable the schedule.
	// +kubebuilder:validation:Required
	Enable bool `json:"enable"`
}

type SnapshotPolicy

type SnapshotPolicy struct {
	BasePolicy `json:",inline"`

	// execute hook commands for backup.
	// +optional
	Hooks *BackupPolicyHook `json:"hooks,omitempty"`
}

type TargetCluster

type TargetCluster struct {
	// labelsSelector is used to find matching pods.
	// Pods that match this label selector are counted to determine the number of pods
	// in their corresponding topology domain.
	// +kubebuilder:validation:Required
	// +kubebuilder:pruning:PreserveUnknownFields
	LabelsSelector *metav1.LabelSelector `json:"labelsSelector"`

	// secret is used to connect to the target database cluster.
	// If not set, secret will be inherited from backup policy template.
	// if still not set, the controller will check if any system account for dataprotection has been created.
	// +optional
	Secret *BackupPolicySecret `json:"secret,omitempty"`
}

TargetCluster TODO (dsj): target cluster need redefined from Cluster API

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL