v1alpha1

package
v0.8.0-alpha.0 Latest Latest
Warning

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

Go to latest
Published: Nov 6, 2023 License: AGPL-3.0 Imports: 33 Imported by: 22

Documentation

Overview

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

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

Package v1alpha1 contains API Schema definitions for the apps v1alpha1 API group

Index

Constants

View Source
const (
	// condition types
	ConditionTypeCancelled         = "Cancelled"
	ConditionTypeProgressing       = "Progressing"
	ConditionTypeValidated         = "Validated"
	ConditionTypeSucceed           = "Succeed"
	ConditionTypeFailed            = "Failed"
	ConditionTypeRestarting        = "Restarting"
	ConditionTypeVerticalScaling   = "VerticalScaling"
	ConditionTypeHorizontalScaling = "HorizontalScaling"
	ConditionTypeVolumeExpanding   = "VolumeExpanding"
	ConditionTypeReconfigure       = "Reconfigure"
	ConditionTypeSwitchover        = "Switchover"
	ConditionTypeStop              = "Stopping"
	ConditionTypeStart             = "Starting"
	ConditionTypeVersionUpgrading  = "VersionUpgrading"
	ConditionTypeExpose            = "Exposing"
	ConditionTypeDataScript        = "ExecuteDataScript"
	ConditionTypeBackup            = "Backup"

	ReasonReconfigurePersisting    = "ReconfigurePersisting"
	ReasonReconfigurePersisted     = "ReconfigurePersisted"
	ReasonReconfigureFailed        = "ReconfigureFailed"
	ReasonReconfigureRestartFailed = "ReconfigureRestartFailed"
	ReasonReconfigureRestart       = "ReconfigureRestarted"
	ReasonReconfigureNoChanged     = "ReconfigureNoChanged"
	ReasonReconfigureSucceed       = "ReconfigureSucceed"
	ReasonReconfigureRunning       = "ReconfigureRunning"
	ReasonClusterPhaseMismatch     = "ClusterPhaseMismatch"
	ReasonOpsTypeNotSupported      = "OpsTypeNotSupported"
	ReasonValidateFailed           = "ValidateFailed"
	ReasonClusterNotFound          = "ClusterNotFound"
	ReasonOpsRequestFailed         = "OpsRequestFailed"
	ReasonOpsCanceling             = "Canceling"
	ReasonOpsCancelFailed          = "CancelFailed"
	ReasonOpsCancelSucceed         = "CancelSucceed"
)
View Source
const (
	APIVersion            = "apps.kubeblocks.io/v1alpha1"
	ClusterVersionKind    = "ClusterVersion"
	ClusterDefinitionKind = "ClusterDefinition"
	ClusterKind           = "Cluster"
	OpsRequestKind        = "OpsRequestKind"
)
View Source
const (
	// define the cluster condition type
	ConditionTypeHaltRecovery        = "HaltRecovery"        // ConditionTypeHaltRecovery describe Halt recovery processing stage
	ConditionTypeProvisioningStarted = "ProvisioningStarted" // ConditionTypeProvisioningStarted the operator starts resource provisioning to create or change the cluster
	ConditionTypeApplyResources      = "ApplyResources"      // ConditionTypeApplyResources the operator start to apply resources to create or change the cluster
	ConditionTypeReplicasReady       = "ReplicasReady"       // ConditionTypeReplicasReady all pods of components are ready
	ConditionTypeReady               = "Ready"               // ConditionTypeReady all components are running
	ConditionTypeSwitchoverPrefix    = "Switchover-"         // ConditionTypeSwitchoverPrefix component status condition of switchover
)
View Source
const (
	KBAccountInvalid        KBAccountType = 0
	KBAccountAdmin                        = 1
	KBAccountDataprotection               = 1 << 1
	KBAccountProbe                        = 1 << 2
	KBAccountMonitor                      = 1 << 3
	KBAccountReplicator                   = 1 << 4
	KBAccountMAX                          = KBAccountReplicator // KBAccountMAX indicates the max value of KBAccountType, used for validation.
)

System accounts represented in bit.

View Source
const DefaultRoleProbeTimeoutAfterPodsReady int32 = 60

DefaultRoleProbeTimeoutAfterPodsReady the default role probe timeout for application when all pods of component are ready. default values are 60 seconds.

Variables

View Source
var (
	// GroupVersion is group version used to register these objects
	GroupVersion = schema.GroupVersion{Group: "apps.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
)
View Source
var (
	ErrWorkloadTypeIsUnknown   = errors.New("workloadType is unknown")
	ErrWorkloadTypeIsStateless = errors.New("workloadType should not be stateless")
	ErrNotMatchingCompDef      = errors.New("not matching componentDefRef")
)
View Source
var DefaultLeader = ConsensusMember{
	Name:       "leader",
	AccessMode: ReadWrite,
}
View Source
var (

	// OpsRequestBehaviourMapper records the opsRequest behaviour according to the OpsType.
	OpsRequestBehaviourMapper = map[OpsType]OpsRequestBehaviour{}
)

log is for logging in this package.

View Source
var SchemeGroupVersion = GroupVersion

SchemeGroupVersion is group version used to register these objects.

View Source
var WorkloadTypes = []string{"Stateless", "Stateful", "Consensus", "Replication"}

Functions

func ComponentPodsAreReady added in v0.6.0

func ComponentPodsAreReady(podsAreReady *bool) bool

ComponentPodsAreReady checks if the pods of component are ready.

func NewBackupCondition added in v0.7.0

func NewBackupCondition(ops *OpsRequest) *metav1.Condition

NewBackupCondition creates a condition that the OpsRequest backup the cluster.

func NewCancelFailedCondition added in v0.6.0

func NewCancelFailedCondition(ops *OpsRequest, err error) *metav1.Condition

NewCancelFailedCondition creates a condition for canceling failed.

func NewCancelSucceedCondition added in v0.6.0

func NewCancelSucceedCondition(opsName string) *metav1.Condition

NewCancelSucceedCondition creates a condition for canceling successfully.

func NewCancelingCondition added in v0.6.0

func NewCancelingCondition(ops *OpsRequest) *metav1.Condition

NewCancelingCondition the controller is canceling the OpsRequest

func NewDataScriptCondition added in v0.6.0

func NewDataScriptCondition(ops *OpsRequest) *metav1.Condition

func NewExposingCondition

func NewExposingCondition(ops *OpsRequest) *metav1.Condition

func NewFailedCondition

func NewFailedCondition(ops *OpsRequest, err error) *metav1.Condition

NewFailedCondition creates a condition that the OpsRequest processing failed

func NewHorizontalScalingCondition

func NewHorizontalScalingCondition(ops *OpsRequest) *metav1.Condition

NewHorizontalScalingCondition creates a condition that the OpsRequest starts to horizontal scale cluster

func NewProgressingCondition

func NewProgressingCondition(ops *OpsRequest) *metav1.Condition

NewProgressingCondition the controller is progressing the OpsRequest

func NewReconfigureCondition

func NewReconfigureCondition(ops *OpsRequest) *metav1.Condition

NewReconfigureCondition creates a condition that the OpsRequest updating component configuration

func NewReconfigureFailedCondition

func NewReconfigureFailedCondition(ops *OpsRequest, err error) *metav1.Condition

NewReconfigureFailedCondition creates a condition for the failed reconfigure.

func NewReconfigureRunningCondition

func NewReconfigureRunningCondition(ops *OpsRequest, conditionType string, configSpecName string, info ...string) *metav1.Condition

NewReconfigureRunningCondition creates a condition that the OpsRequest reconfigure workflow

func NewRestartingCondition

func NewRestartingCondition(ops *OpsRequest) *metav1.Condition

NewRestartingCondition creates a condition that the operation starts to restart components

func NewStartCondition

func NewStartCondition(ops *OpsRequest) *metav1.Condition

NewStartCondition creates a condition that the OpsRequest starts the cluster.

func NewStopCondition

func NewStopCondition(ops *OpsRequest) *metav1.Condition

NewStopCondition creates a condition that the OpsRequest starts to stop the cluster.

func NewSucceedCondition

func NewSucceedCondition(ops *OpsRequest) *metav1.Condition

NewSucceedCondition creates a condition that the controller has successfully processed the OpsRequest

func NewSwitchoveringCondition added in v0.6.0

func NewSwitchoveringCondition(generation int64, message string) *metav1.Condition

NewSwitchoveringCondition creates a condition that the operation starts to switchover components

func NewUpgradingCondition

func NewUpgradingCondition(ops *OpsRequest) *metav1.Condition

NewUpgradingCondition creates a condition that the OpsRequest starts to upgrade the cluster version

func NewValidateFailedCondition

func NewValidateFailedCondition(reason, message string) *metav1.Condition

NewValidateFailedCondition creates a condition for operation validation failure.

func NewValidatePassedCondition

func NewValidatePassedCondition(opsRequestName string) *metav1.Condition

NewValidatePassedCondition creates a condition for operation validation to pass.

func NewVerticalScalingCondition

func NewVerticalScalingCondition(ops *OpsRequest) *metav1.Condition

NewVerticalScalingCondition creates a condition that the OpsRequest starts to vertical scale cluster

func NewVolumeExpandingCondition

func NewVolumeExpandingCondition(ops *OpsRequest) *metav1.Condition

NewVolumeExpandingCondition creates a condition that the OpsRequest starts to expand volume

func RegisterWebhookManager

func RegisterWebhookManager(mgr manager.Manager)

func Resource added in v0.6.0

func Resource(resource string) schema.GroupResource

Resource takes an unqualified resource and returns a Group qualified GroupResource

Types

type AccessMode

type AccessMode string

AccessMode defines SVC access mode enums. +enum +kubebuilder:validation:Enum={None,Readonly,ReadWrite}

const (
	ReadWrite AccessMode = "ReadWrite"
	Readonly  AccessMode = "Readonly"
	None      AccessMode = "None"
)

type AccountName

type AccountName string

AccountName defines system account names. +enum +kubebuilder:validation:Enum={kbadmin,kbdataprotection,kbprobe,kbmonitoring,kbreplicator}

const (
	AdminAccount          AccountName = "kbadmin"
	DataprotectionAccount AccountName = "kbdataprotection"
	ProbeAccount          AccountName = "kbprobe"
	MonitorAccount        AccountName = "kbmonitoring"
	ReplicatorAccount     AccountName = "kbreplicator"
)

func (AccountName) GetAccountID

func (r AccountName) GetAccountID() KBAccountType

type Affinity

type Affinity struct {
	// podAntiAffinity describes the anti-affinity level of pods within a component.
	// Preferred means try spread pods by `TopologyKeys`.
	// Required means must spread pods by `TopologyKeys`.
	// +kubebuilder:default=Preferred
	// +optional
	PodAntiAffinity PodAntiAffinity `json:"podAntiAffinity,omitempty"`

	// topologyKey is the key of node labels.
	// Nodes that have a label with this key and identical values are considered to be in the same topology.
	// It's used as the topology domain for pod anti-affinity and pod spread constraint.
	// Some well-known label keys, such as "kubernetes.io/hostname" and "topology.kubernetes.io/zone"
	// are often used as TopologyKey, as well as any other custom label key.
	// +listType=set
	// +optional
	TopologyKeys []string `json:"topologyKeys,omitempty"`

	// nodeLabels describes that pods must be scheduled to the nodes with the specified node labels.
	// +optional
	NodeLabels map[string]string `json:"nodeLabels,omitempty"`

	// tenancy describes how pods are distributed across node.
	// SharedNode means multiple pods may share the same node.
	// DedicatedNode means each pod runs on their own dedicated node.
	// +kubebuilder:default=SharedNode
	// +optional
	Tenancy TenancyType `json:"tenancy,omitempty"`
}

type AvailabilityPolicyType added in v0.6.0

type AvailabilityPolicyType string

AvailabilityPolicyType for cluster affinity policy. +enum +kubebuilder:validation:Enum={zone,node,none}

const (
	AvailabilityPolicyZone AvailabilityPolicyType = "zone"
	AvailabilityPolicyNode AvailabilityPolicyType = "node"
	AvailabilityPolicyNone AvailabilityPolicyType = "none"
)

type BackupMethod added in v0.7.0

type BackupMethod struct {
	dpv1alpha1.BackupMethod `json:",inline"`

	// envMapping defines the variables of cluster mapped to env values' keys.
	// +optional
	EnvMapping []EnvMappingVar `json:"envMapping,omitempty"`
}

type BackupPolicy

type BackupPolicy struct {
	// componentDefRef references componentDef defined in ClusterDefinition spec. Need to
	// comply with IANA Service Naming rule.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=22
	// +kubebuilder:validation:Pattern:=`^[a-z]([a-z0-9\-]*[a-z0-9])?$`
	ComponentDefRef string `json:"componentDefRef"`

	// retentionPeriod determines a duration up to which the backup should be kept.
	// controller will remove all backups that are older than the RetentionPeriod.
	// For example, RetentionPeriod of `30d` will keep only the backups of last 30 days.
	// Sample duration format:
	// - years: 	2y
	// - months: 	6mo
	// - days: 		30d
	// - hours: 	12h
	// - minutes: 	30m
	// You can also combine the above durations. For example: 30d12h30m
	// +optional
	// +kubebuilder:default="7d"
	RetentionPeriod dpv1alpha1.RetentionPeriod `json:"retentionPeriod,omitempty"`

	// target instance for backup.
	// +optional
	Target TargetInstance `json:"target"`

	// schedule policy for backup.
	// +optional
	Schedules []SchedulePolicy `json:"schedules,omitempty"`

	// backupMethods defines the backup methods.
	// +kubebuilder:validation:Required
	BackupMethods []BackupMethod `json:"backupMethods"`
}

type BackupPolicyTemplate

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

	Spec   BackupPolicyTemplateSpec   `json:"spec,omitempty"`
	Status BackupPolicyTemplateStatus `json:"status,omitempty"`
}

BackupPolicyTemplate is the Schema for the BackupPolicyTemplates API (defined by provider)

type BackupPolicyTemplateList

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

BackupPolicyTemplateList contains a list of BackupPolicyTemplate

type BackupPolicyTemplateSpec

type BackupPolicyTemplateSpec struct {
	// clusterDefinitionRef references ClusterDefinition name, this is an immutable attribute.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="clusterDefinitionRef is immutable"
	ClusterDefRef string `json:"clusterDefinitionRef"`

	// backupPolicies is a list of backup policy template for the specified componentDefinition.
	// +patchMergeKey=componentDefRef
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=componentDefRef
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MinItems=1
	BackupPolicies []BackupPolicy `json:"backupPolicies"`

	// Identifier is a unique identifier for this BackupPolicyTemplate.
	// this identifier will be the suffix of the automatically generated backupPolicy name.
	// and must be added when multiple BackupPolicyTemplates exist,
	// otherwise the generated backupPolicy override will occur.
	// +optional
	// +kubebuilder:validation:MaxLength=20
	Identifier string `json:"identifier,omitempty"`
}

BackupPolicyTemplateSpec defines the desired state of BackupPolicyTemplate

type BackupPolicyTemplateStatus

type BackupPolicyTemplateStatus struct {
}

BackupPolicyTemplateStatus defines the observed state of BackupPolicyTemplate

type BackupRefSpec

type BackupRefSpec struct {
	// specify a reference backup to restore
	// +optional
	Ref RefNamespaceName `json:"ref,omitempty"`
}

type BackupSpec added in v0.7.0

type BackupSpec struct {
	// backupName is the name of the backup.
	// +optional
	BackupName string `json:"backupName,omitempty"`

	// Which backupPolicy is applied to perform this backup
	// +optional
	BackupPolicyName string `json:"backupPolicyName,omitempty"`

	// Backup method name that is defined in backupPolicy.
	// +optional
	BackupMethod string `json:"backupMethod,omitempty"`

	// deletionPolicy determines whether the backup contents stored in backup repository
	// should be deleted when the backup custom resource is deleted.
	// Supported values are "Retain" and "Delete".
	// "Retain" means that the backup content and its physical snapshot on backup repository are kept.
	// "Delete" means that the backup content and its physical snapshot on backup repository are deleted.
	// +kubebuilder:validation:Enum=Delete;Retain
	// +kubebuilder:validation:Required
	// +kubebuilder:default=Delete
	// +optional
	DeletionPolicy string `json:"deletionPolicy,omitempty"`

	// retentionPeriod determines a duration up to which the backup should be kept.
	// Controller will remove all backups that are older than the RetentionPeriod.
	// For example, RetentionPeriod of `30d` will keep only the backups of last 30 days.
	// Sample duration format:
	// - years: 	2y
	// - months: 	6mo
	// - days: 		30d
	// - hours: 	12h
	// - minutes: 	30m
	// You can also combine the above durations. For example: 30d12h30m.
	// If not set, the backup will be kept forever.
	// +optional
	RetentionPeriod string `json:"retentionPeriod,omitempty"`

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

type BackupStatusUpdateStage

type BackupStatusUpdateStage string

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

type BaseBackupType

type BaseBackupType string

BaseBackupType the base backup type, keep synchronized with the BaseBackupType of the data protection API. +enum +kubebuilder:validation:Enum={full,snapshot}

type CPUConstraint

type CPUConstraint struct {
	// The maximum count of vcpu cores, [Min, Max] defines a range for valid vcpu cores, and the value in this range
	// must be multiple times of Step. It's useful to define a large number of valid values without defining them one by
	// one. Please see the documentation for Step for some examples.
	// If Slots is specified, Max, Min, and Step are ignored
	// +optional
	Max *resource.Quantity `json:"max,omitempty"`

	// The minimum count of vcpu cores, [Min, Max] defines a range for valid vcpu cores, and the value in this range
	// must be multiple times of Step. It's useful to define a large number of valid values without defining them one by
	// one. Please see the documentation for Step for some examples.
	// If Slots is specified, Max, Min, and Step are ignored
	// +optional
	Min *resource.Quantity `json:"min,omitempty"`

	// The minimum granularity of vcpu cores, [Min, Max] defines a range for valid vcpu cores and the value in this range must be
	// multiple times of Step.
	// For example:
	// 1. Min is 2, Max is 8, Step is 2, and the valid vcpu core is {2, 4, 6, 8}.
	// 2. Min is 0.5, Max is 2, Step is 0.5, and the valid vcpu core is {0.5, 1, 1.5, 2}.
	// +optional
	Step *resource.Quantity `json:"step,omitempty"`

	// The valid vcpu cores, it's useful if you want to define valid vcpu cores explicitly.
	// If Slots is specified, Max, Min, and Step are ignored
	// +optional
	Slots []resource.Quantity `json:"slots,omitempty"`
}

type CfgFileFormat

type CfgFileFormat string

CfgFileFormat defines formatter of configuration files. +enum +kubebuilder:validation:Enum={xml,ini,yaml,json,hcl,dotenv,toml,properties,redis,props-plus}

const (
	Ini            CfgFileFormat = "ini"
	YAML           CfgFileFormat = "yaml"
	JSON           CfgFileFormat = "json"
	XML            CfgFileFormat = "xml"
	HCL            CfgFileFormat = "hcl"
	Dotenv         CfgFileFormat = "dotenv"
	TOML           CfgFileFormat = "toml"
	Properties     CfgFileFormat = "properties"
	RedisCfg       CfgFileFormat = "redis"
	PropertiesPlus CfgFileFormat = "props-plus"
)

type CfgReloadType

type CfgReloadType string

CfgReloadType defines reload method. +enum

const (
	UnixSignalType CfgReloadType = "signal"
	SQLType        CfgReloadType = "sql"
	ShellType      CfgReloadType = "exec"
	HTTPType       CfgReloadType = "http"
	TPLScriptType  CfgReloadType = "tpl"
)

type ClassDefRef

type ClassDefRef struct {
	// Name refers to the name of the ComponentClassDefinition.
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	// +optional
	Name string `json:"name,omitempty"`

	// Class refers to the name of the class that is defined in the ComponentClassDefinition.
	// +kubebuilder:validation:Required
	Class string `json:"class"`
}

type Cluster

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

	Spec   ClusterSpec   `json:"spec,omitempty"`
	Status ClusterStatus `json:"status,omitempty"`
}

Cluster is the Schema for the clusters API.

func (*Cluster) GetVolumeClaimNames

func (r *Cluster) GetVolumeClaimNames(compName string, claimNames ...string) []string

GetVolumeClaimNames gets all PVC names of component compName.

r.Spec.GetComponentByName(compName).VolumeClaimTemplates[*].Name will be used if no claimNames provided

nil return if: 1. component compName not found or 2. len(VolumeClaimTemplates)==0 or 3. any claimNames not found

func (Cluster) IsDeleting added in v0.6.0

func (r Cluster) IsDeleting() bool

func (Cluster) IsStatusUpdating added in v0.6.0

func (r Cluster) IsStatusUpdating() bool

func (Cluster) IsUpdating added in v0.6.0

func (r Cluster) IsUpdating() bool

func (*Cluster) SetupWebhookWithManager

func (r *Cluster) SetupWebhookWithManager(mgr ctrl.Manager) error

func (*Cluster) ValidateCreate

func (r *Cluster) ValidateCreate() (admission.Warnings, error)

ValidateCreate implements webhook.Validator so a webhook will be registered for the type

func (*Cluster) ValidateDelete

func (r *Cluster) ValidateDelete() (admission.Warnings, error)

ValidateDelete implements webhook.Validator so a webhook will be registered for the type

func (*Cluster) ValidateUpdate

func (r *Cluster) ValidateUpdate(old runtime.Object) (admission.Warnings, error)

ValidateUpdate implements webhook.Validator so a webhook will be registered for the type

type ClusterBackup added in v0.6.0

type ClusterBackup struct {
	// enabled defines whether to enable automated backup.
	// +kubebuilder:default=false
	// +optional
	Enabled *bool `json:"enabled,omitempty"`

	// retentionPeriod determines a duration up to which the backup should be kept.
	// controller will remove all backups that are older than the RetentionPeriod.
	// For example, RetentionPeriod of `30d` will keep only the backups of last 30 days.
	// Sample duration format:
	// - years: 	2y
	// - months: 	6mo
	// - days: 		30d
	// - hours: 	12h
	// - minutes: 	30m
	// You can also combine the above durations. For example: 30d12h30m
	// +kubebuilder:default="7d"
	// +optional
	RetentionPeriod dpv1alpha1.RetentionPeriod `json:"retentionPeriod,omitempty"`

	// backup method name to use, that is defined in backupPolicy.
	// +optional
	Method string `json:"method"`

	// the cron expression for schedule, the timezone is in UTC. see https://en.wikipedia.org/wiki/Cron.
	// +optional
	CronExpression string `json:"cronExpression,omitempty"`

	// startingDeadlineMinutes defines the deadline in minutes for starting the backup job
	// if it misses scheduled time for any reason.
	// +kubebuilder:validation:Minimum=0
	// +kubebuilder:validation:Maximum=1440
	// +optional
	StartingDeadlineMinutes *int64 `json:"startingDeadlineMinutes,omitempty"`

	// repoName is the name of the backupRepo, if not set, will use the default backupRepo.
	// +optional
	RepoName string `json:"repoName,omitempty"`

	// pitrEnabled defines whether to enable point-in-time recovery.
	// +kubebuilder:default=false
	// +optional
	PITREnabled *bool `json:"pitrEnabled,omitempty"`
}

type ClusterComponentDefinition

type ClusterComponentDefinition struct {
	// A component definition name, this name could be used as default name of `Cluster.spec.componentSpecs.name`,
	// and so this name is need to conform with same validation rules as `Cluster.spec.componentSpecs.name`, that
	// is currently comply with IANA Service Naming rule. This name will apply to "apps.kubeblocks.io/component-name"
	// object label value.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=22
	// +kubebuilder:validation:Pattern:=`^[a-z]([a-z0-9\-]*[a-z0-9])?$`
	Name string `json:"name"`

	// The description of component definition.
	// +optional
	Description string `json:"description,omitempty"`

	// workloadType defines type of the workload.
	// Stateless is a stateless workload type used to describe stateless applications.
	// Stateful is a stateful workload type used to describe common stateful applications.
	// Consensus is a stateful workload type used to describe applications based on consensus protocols, common consensus protocols such as raft and paxos.
	// Replication is a stateful workload type used to describe applications based on the primary-secondary data replication protocol.
	// +kubebuilder:validation:Required
	WorkloadType WorkloadType `json:"workloadType"`

	// characterType defines well-known database component name, such as mongos(mongodb), proxy(redis), mariadb(mysql)
	// KubeBlocks will generate proper monitor configs for well-known characterType when builtIn is true.
	//
	// CharacterType will also be used in role probe to decide which probe engine to use.
	// current available candidates are: mysql, postgres, mongodb, redis, etcd, kafka.
	// +optional
	CharacterType string `json:"characterType,omitempty"`

	// The configSpec field provided by provider, and
	// finally this configTemplateRefs will be rendered into the user's own configuration file according to the user's cluster.
	// +optional
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	ConfigSpecs []ComponentConfigSpec `json:"configSpecs,omitempty"`

	// The scriptSpec field provided by provider, and
	// finally this configTemplateRefs will be rendered into the user's own configuration file according to the user's cluster.
	// +optional
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	// +optional
	ScriptSpecs []ComponentTemplateSpec `json:"scriptSpecs,omitempty"`

	// probes setting for healthy checks.
	// +optional
	Probes *ClusterDefinitionProbes `json:"probes,omitempty"`

	// monitor is monitoring config which provided by provider.
	// +optional
	Monitor *MonitorConfig `json:"monitor,omitempty"`

	// logConfigs is detail log file config which provided by provider.
	// +optional
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	LogConfigs []LogConfig `json:"logConfigs,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name"`

	// podSpec define pod spec template of the cluster component.
	// +kubebuilder:pruning:PreserveUnknownFields
	// +optional
	PodSpec *corev1.PodSpec `json:"podSpec,omitempty"`

	// service defines the behavior of a service spec.
	// provide read-write service when WorkloadType is Consensus.
	// +optional
	Service *ServiceSpec `json:"service,omitempty"`

	// statelessSpec defines stateless related spec if workloadType is Stateless.
	// +optional
	//+kubebuilder:deprecatedversion:warning="This field is deprecated from KB 0.7.0, use RSMSpec instead."
	StatelessSpec *StatelessSetSpec `json:"statelessSpec,omitempty"`

	// statefulSpec defines stateful related spec if workloadType is Stateful.
	// +optional
	//+kubebuilder:deprecatedversion:warning="This field is deprecated from KB 0.7.0, use RSMSpec instead."
	StatefulSpec *StatefulSetSpec `json:"statefulSpec,omitempty"`

	// consensusSpec defines consensus related spec if workloadType is Consensus, required if workloadType is Consensus.
	// +optional
	//+kubebuilder:deprecatedversion:warning="This field is deprecated from KB 0.7.0, use RSMSpec instead."
	ConsensusSpec *ConsensusSetSpec `json:"consensusSpec,omitempty"`

	// replicationSpec defines replication related spec if workloadType is Replication.
	// +optional
	//+kubebuilder:deprecatedversion:warning="This field is deprecated from KB 0.7.0, use RSMSpec instead."
	ReplicationSpec *ReplicationSetSpec `json:"replicationSpec,omitempty"`

	// RSMSpec defines workload related spec of this component.
	// start from KB 0.7.0, RSM(ReplicatedStateMachineSpec) will be the underlying CR which powers all kinds of workload in KB.
	// RSM is an enhanced stateful workload extension dedicated for heavy-state workloads like databases.
	// +optional
	RSMSpec *RSMSpec `json:"rsmSpec,omitempty"`

	// horizontalScalePolicy controls the behavior of horizontal scale.
	// +optional
	HorizontalScalePolicy *HorizontalScalePolicy `json:"horizontalScalePolicy,omitempty"`

	// Statement to create system account.
	// +optional
	SystemAccounts *SystemAccountSpec `json:"systemAccounts,omitempty"`

	// volumeTypes is used to describe the purpose of the volumes
	// mapping the name of the VolumeMounts in the PodSpec.Container field,
	// such as data volume, log volume, etc.
	// When backing up the volume, the volume can be correctly backed up
	// according to the volumeType.
	//
	// For example:
	//  `name: data, type: data` means that the volume named `data` is used to store `data`.
	//  `name: binlog, type: log` means that the volume named `binlog` is used to store `log`.
	//
	// NOTE:
	//   When volumeTypes is not defined, the backup function will not be supported,
	// even if a persistent volume has been specified.
	// +listType=map
	// +listMapKey=name
	// +optional
	VolumeTypes []VolumeTypeSpec `json:"volumeTypes,omitempty"`

	// customLabelSpecs is used for custom label tags which you want to add to the component resources.
	// +listType=map
	// +listMapKey=key
	// +optional
	CustomLabelSpecs []CustomLabelSpec `json:"customLabelSpecs,omitempty"`

	// switchoverSpec defines command to do switchover.
	// in particular, when workloadType=Replication, the command defined in switchoverSpec will only be executed under the condition of cluster.componentSpecs[x].SwitchPolicy.type=Noop.
	// +optional
	SwitchoverSpec *SwitchoverSpec `json:"switchoverSpec,omitempty"`

	// +optional
	VolumeProtectionSpec *VolumeProtectionSpec `json:"volumeProtectionSpec,omitempty"`

	// componentDefRef is used to inject values from other components into the current component.
	// values will be saved and updated in a configmap and mounted to the current component.
	// +patchMergeKey=componentDefName
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=componentDefName
	// +optional
	ComponentDefRef []ComponentDefRef `json:"componentDefRef,omitempty" patchStrategy:"merge" patchMergeKey:"componentDefName"`

	// serviceRefDeclarations is used to declare the service reference of the current component.
	// +optional
	ServiceRefDeclarations []ServiceRefDeclaration `json:"serviceRefDeclarations,omitempty"`
}

ClusterComponentDefinition provides a workload component specification template, with attributes that strongly work with stateful workloads and day-2 operations behaviors. +kubebuilder:validation:XValidation:rule="has(self.workloadType) && self.workloadType == 'Consensus' ? (has(self.consensusSpec) || has(self.rsmSpec)) : !has(self.consensusSpec)",message="componentDefs.consensusSpec(deprecated) or componentDefs.rsmSpec(recommended) is required when componentDefs.workloadType is Consensus, and forbidden otherwise"

func GetComponentDefByCluster added in v0.7.0

func GetComponentDefByCluster(ctx context.Context, cli client.Client, cluster Cluster,
	compDefName string) (*ClusterComponentDefinition, error)

GetComponentDefByCluster gets component from ClusterDefinition with compDefName

func (*ClusterComponentDefinition) GetCommonStatefulSpec added in v0.6.0

func (r *ClusterComponentDefinition) GetCommonStatefulSpec() (*StatefulSetSpec, error)

func (*ClusterComponentDefinition) GetMaxUnavailable added in v0.6.0

func (r *ClusterComponentDefinition) GetMaxUnavailable() *intstr.IntOrString

GetMaxUnavailable get workload's maxUnavailable settings, this value is not suitable for PDB.spec.maxUnavailable usage, as a PDB with maxUnavailable=49% and if workload's replicaCount=3 and allowed disruption pod count is 2, check following setup:

#cmd: kubectl get sts,po,pdb -l app.kubernetes.io/instance=consul NAME READY AGE statefulset.apps/consul 3/3 3h23m

NAME READY STATUS RESTARTS AGE pod/consul-0 1/1 Running 0 3h pod/consul-2 1/1 Running 0 16s pod/consul-1 1/1 Running 0 16s

NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS AGE poddisruptionbudget.policy/consul N/A 49% 2 3h23m

VS. using minAvailable=51% will result allowed disruption pod count is 1

NAME READY AGE statefulset.apps/consul 3/3 3h26m

NAME READY STATUS RESTARTS AGE pod/consul-0 1/1 Running 0 3h3m pod/consul-2 1/1 Running 0 3m35s pod/consul-1 1/1 Running 0 3m35s

NAME MIN AVAILABLE MAX UNAVAILABLE ALLOWED DISRUPTIONS AGE poddisruptionbudget.policy/consul 51% N/A 1 3h26m

func (*ClusterComponentDefinition) GetMinAvailable added in v0.6.0

func (r *ClusterComponentDefinition) GetMinAvailable() *intstr.IntOrString

GetMinAvailable get workload's minAvailable settings, return 51% for workloadType=Consensus, value 1 pod for workloadType=[Stateless|Stateful|Replication].

func (*ClusterComponentDefinition) GetStatefulSetWorkload added in v0.6.0

func (r *ClusterComponentDefinition) GetStatefulSetWorkload() StatefulSetWorkload

func (*ClusterComponentDefinition) IsStatelessWorkload added in v0.6.0

func (r *ClusterComponentDefinition) IsStatelessWorkload() bool

type ClusterComponentPhase

type ClusterComponentPhase string

ClusterComponentPhase defines the Cluster CR .status.components.phase +enum +kubebuilder:validation:Enum={Creating,Running,Updating,Stopping,Stopped,Deleting,Failed,Abnormal}

const (
	CreatingClusterCompPhase ClusterComponentPhase = "Creating"
	RunningClusterCompPhase  ClusterComponentPhase = "Running"
	UpdatingClusterCompPhase ClusterComponentPhase = "Updating"
	StoppingClusterCompPhase ClusterComponentPhase = "Stopping"
	StoppedClusterCompPhase  ClusterComponentPhase = "Stopped"
	DeletingClusterCompPhase ClusterComponentPhase = "Deleting"
	FailedClusterCompPhase   ClusterComponentPhase = "Failed"
	AbnormalClusterCompPhase ClusterComponentPhase = "Abnormal"
)

func GetComponentTerminalPhases

func GetComponentTerminalPhases() []ClusterComponentPhase

GetComponentTerminalPhases return Cluster's component terminal phases.

func GetComponentUpRunningPhase added in v0.6.0

func GetComponentUpRunningPhase() []ClusterComponentPhase

GetComponentUpRunningPhase returns component running or partially running phases.

type ClusterComponentService

type ClusterComponentService struct {
	// Service name
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=15
	Name string `json:"name"`

	// serviceType determines how the Service is exposed. Valid
	// options are ClusterIP, NodePort, and LoadBalancer.
	// "ClusterIP" allocates a cluster-internal IP address for load-balancing
	// to endpoints. Endpoints are determined by the selector or if that is not
	// specified, they are determined by manual construction of an Endpoints object or
	// EndpointSlice objects. If clusterIP is "None", no virtual IP is
	// allocated and the endpoints are published as a set of endpoints rather
	// than a virtual IP.
	// "NodePort" builds on ClusterIP and allocates a port on every node which
	// routes to the same endpoints as the clusterIP.
	// "LoadBalancer" builds on NodePort and creates an external load-balancer
	// (if supported in the current cloud) which routes to the same endpoints
	// as the clusterIP.
	// More info: https://kubernetes.io/docs/concepts/services-networking/service/#publishing-services-service-types.
	// +kubebuilder:default=ClusterIP
	// +kubebuilder:validation:Enum={ClusterIP,NodePort,LoadBalancer}
	// +kubebuilder:pruning:PreserveUnknownFields
	// +optional
	ServiceType corev1.ServiceType `json:"serviceType,omitempty"`

	// If ServiceType is LoadBalancer, cloud provider related parameters can be put here
	// More info: https://kubernetes.io/docs/concepts/services-networking/service/#loadbalancer.
	// +optional
	Annotations map[string]string `json:"annotations,omitempty"`
}

type ClusterComponentSpec

type ClusterComponentSpec struct {
	// name defines cluster's component name, this name is also part of Service DNS name, so this name will
	// comply with IANA Service Naming rule.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=22
	// +kubebuilder:validation:Pattern:=`^[a-z]([a-z0-9\-]*[a-z0-9])?$`
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="name is immutable"
	Name string `json:"name"`

	// componentDefRef references componentDef defined in ClusterDefinition spec. Need to
	// comply with IANA Service Naming rule.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=22
	// +kubebuilder:validation:Pattern:=`^[a-z]([a-z0-9\-]*[a-z0-9])?$`
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="componentDefRef is immutable"
	ComponentDefRef string `json:"componentDefRef"`

	// classDefRef references the class defined in ComponentClassDefinition.
	// +optional
	ClassDefRef *ClassDefRef `json:"classDefRef,omitempty"`

	// serviceRefs define service references for the current component. Based on the referenced services, they can be categorized into two types:
	// Service provided by external sources: These services are provided by external sources and are not managed by KubeBlocks. They can be Kubernetes-based or non-Kubernetes services. For external services, you need to provide an additional ServiceDescriptor object to establish the service binding.
	// Service provided by other KubeBlocks clusters: These services are provided by other KubeBlocks clusters. You can bind to these services by specifying the name of the hosting cluster.
	// Each type of service reference requires specific configurations and bindings to establish the connection and interaction with the respective services.
	// It should be noted that the ServiceRef has cluster-level semantic consistency, meaning that within the same Cluster, service references with the same ServiceRef.Name are considered to be the same service. It is only allowed to bind to the same Cluster or ServiceDescriptor.
	// +optional
	ServiceRefs []ServiceRef `json:"serviceRefs,omitempty"`

	// monitor is a switch to enable monitoring and is set as false by default.
	// KubeBlocks provides an extension mechanism to support component level monitoring,
	// which will scrape metrics auto or manually from servers in component and export
	// metrics to Time Series Database.
	// +kubebuilder:default=false
	// +optional
	Monitor bool `json:"monitor,omitempty"`

	// enabledLogs indicates which log file takes effect in the database cluster.
	// element is the log type which is defined in cluster definition logConfig.name,
	// and will set relative variables about this log type in database kernel.
	// +listType=set
	// +optional
	EnabledLogs []string `json:"enabledLogs,omitempty"`

	// Component replicas. The default value is used in ClusterDefinition spec if not specified.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Minimum=0
	// +kubebuilder:default=1
	Replicas int32 `json:"replicas"`

	// affinity describes affinities specified by users.
	// +optional
	Affinity *Affinity `json:"affinity,omitempty"`

	// Component tolerations will override ClusterSpec.Tolerations if specified.
	// +kubebuilder:pruning:PreserveUnknownFields
	// +optional
	Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

	// Resources requests and limits of workload.
	// +kubebuilder:pruning:PreserveUnknownFields
	// +optional
	Resources corev1.ResourceRequirements `json:"resources,omitempty"`

	// volumeClaimTemplates information for statefulset.spec.volumeClaimTemplates.
	// +optional
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	VolumeClaimTemplates []ClusterComponentVolumeClaimTemplate `json:"volumeClaimTemplates,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name"`

	// Services expose endpoints that can be accessed by clients.
	// +optional
	Services []ClusterComponentService `json:"services,omitempty"`

	// switchPolicy defines the strategy for switchover and failover when workloadType is Replication.
	// +optional
	SwitchPolicy *ClusterSwitchPolicy `json:"switchPolicy,omitempty"`

	// Enables or disables TLS certs.
	// +optional
	TLS bool `json:"tls,omitempty"`

	// issuer defines provider context for TLS certs.
	// required when TLS enabled
	// +optional
	Issuer *Issuer `json:"issuer,omitempty"`

	// serviceAccountName is the name of the ServiceAccount that running component depends on.
	// +optional
	ServiceAccountName string `json:"serviceAccountName,omitempty"`

	// noCreatePDB defines the PodDisruptionBudget creation behavior and is set to true if creation of PodDisruptionBudget
	// for this component is not needed. It defaults to false.
	// +kubebuilder:default=false
	// +optional
	NoCreatePDB bool `json:"noCreatePDB,omitempty"`

	// userResourceRefs defines the user-defined volumes.
	// +optional
	UserResourceRefs *UserResourceRefs `json:"userResourceRefs,omitempty"`
}

ClusterComponentSpec defines the cluster component spec.

func (*ClusterComponentSpec) GetMinAvailable added in v0.6.0

func (r *ClusterComponentSpec) GetMinAvailable(prefer *intstr.IntOrString) *intstr.IntOrString

GetMinAvailable wraps the 'prefer' value return. As for component replicaCount <= 1, it will return 0, and as for replicaCount=2 it will return 1.

func (*ClusterComponentSpec) ToVolumeClaimTemplates

func (r *ClusterComponentSpec) ToVolumeClaimTemplates() []corev1.PersistentVolumeClaimTemplate

ToVolumeClaimTemplates convert r.VolumeClaimTemplates to []corev1.PersistentVolumeClaimTemplate.

type ClusterComponentStatus

type ClusterComponentStatus struct {
	// phase describes the phase of the component and the detail information of the phases are as following:
	// Creating: `Creating` is a special `Updating` with previous phase `empty`(means "") or `Creating`.
	// Running: component replicas > 0 and all pod specs are latest with a Running state.
	// Updating: component replicas > 0 and has no failed pods. the component is being updated.
	// Abnormal: component replicas > 0 but having some failed pods. the component basically works but in a fragile state.
	// Failed: component replicas > 0 but having some failed pods. the component doesn't work anymore.
	// Stopping: component replicas = 0 and has terminating pods.
	// Stopped: component replicas = 0 and all pods have been deleted.
	// Deleting: the component is being deleted.
	Phase ClusterComponentPhase `json:"phase,omitempty"`

	// message records the component details message in current phase.
	// Keys are podName or deployName or statefulSetName. The format is `ObjectKind/Name`.
	// +optional
	Message ComponentMessageMap `json:"message,omitempty"`

	// podsReady checks if all pods of the component are ready.
	// +optional
	PodsReady *bool `json:"podsReady,omitempty"`

	// podsReadyTime what time point of all component pods are ready,
	// this time is the ready time of the last component pod.
	// +optional
	PodsReadyTime *metav1.Time `json:"podsReadyTime,omitempty"`

	// consensusSetStatus specifies the mapping of role and pod name.
	// +optional
	// +kubebuilder:deprecatedversion:warning="This field is deprecated from KB 0.7.0, use MembersStatus instead."
	ConsensusSetStatus *ConsensusSetStatus `json:"consensusSetStatus,omitempty"`

	// replicationSetStatus specifies the mapping of role and pod name.
	// +optional
	// +kubebuilder:deprecatedversion:warning="This field is deprecated from KB 0.7.0, use MembersStatus instead."
	ReplicationSetStatus *ReplicationSetStatus `json:"replicationSetStatus,omitempty"`

	// members' status.
	// +optional
	MembersStatus []workloads.MemberStatus `json:"membersStatus,omitempty"`
}

ClusterComponentStatus records components status.

func (ClusterComponentStatus) GetMessage

GetMessage gets message map deep copy object.

func (ClusterComponentStatus) GetObjectMessage

func (r ClusterComponentStatus) GetObjectMessage(objectKind, objectName string) string

GetObjectMessage gets the k8s workload message in component status message map

func (*ClusterComponentStatus) SetMessage

func (r *ClusterComponentStatus) SetMessage(messageMap ComponentMessageMap)

SetMessage overrides message map object.

func (*ClusterComponentStatus) SetObjectMessage

func (r *ClusterComponentStatus) SetObjectMessage(objectKind, objectName, message string)

SetObjectMessage sets K8s workload message to component status message map.

type ClusterComponentVersion

type ClusterComponentVersion struct {
	// componentDefRef reference one of the cluster component definition names in ClusterDefinition API (spec.componentDefs.name).
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	ComponentDefRef string `json:"componentDefRef"`

	// configSpecs defines a configuration extension mechanism to handle configuration differences between versions,
	// the configTemplateRefs field, together with configTemplateRefs in the ClusterDefinition,
	// determines the final configuration file.
	// +optional
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	ConfigSpecs []ComponentConfigSpec `json:"configSpecs,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name"`

	// systemAccountSpec define image for the component to connect database or engines.
	// It overrides `image` and `env` attributes defined in ClusterDefinition.spec.componentDefs.systemAccountSpec.cmdExecutorConfig.
	// To clean default envs settings, set `SystemAccountSpec.CmdExecutorConfig.Env` to empty list.
	// +optional
	SystemAccountSpec *SystemAccountShortSpec `json:"systemAccountSpec,omitempty"`

	// versionContext defines containers images' context for component versions,
	// this value replaces ClusterDefinition.spec.componentDefs.podSpec.[initContainers | containers]
	VersionsCtx VersionsContext `json:"versionsContext"`

	// switchoverSpec defines images for the component to do switchover.
	// It overrides `image` and `env` attributes defined in ClusterDefinition.spec.componentDefs.SwitchoverSpec.CommandExecutorEnvItem.
	// +optional
	SwitchoverSpec *SwitchoverShortSpec `json:"switchoverSpec,omitempty"`
}

ClusterComponentVersion is an application version component spec.

type ClusterComponentVolumeClaimTemplate

type ClusterComponentVolumeClaimTemplate struct {
	// Reference `ClusterDefinition.spec.componentDefs.containers.volumeMounts.name`.
	// +kubebuilder:validation:Required
	Name string `json:"name"`
	// spec defines the desired characteristics of a volume requested by a pod author.
	// +optional
	Spec PersistentVolumeClaimSpec `json:"spec,omitempty"`
}

type ClusterDefinition

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

	Spec   ClusterDefinitionSpec   `json:"spec,omitempty"`
	Status ClusterDefinitionStatus `json:"status,omitempty"`
}

ClusterDefinition is the Schema for the clusterdefinitions API

func (*ClusterDefinition) Default

func (r *ClusterDefinition) Default()

Default implements webhook.Defaulter so a webhook will be registered for the type

func (*ClusterDefinition) GetComponentDefByName

func (r *ClusterDefinition) GetComponentDefByName(compDefName string) *ClusterComponentDefinition

GetComponentDefByName gets component definition from ClusterDefinition with compDefName

func (*ClusterDefinition) SetupWebhookWithManager

func (r *ClusterDefinition) SetupWebhookWithManager(mgr ctrl.Manager) error

func (*ClusterDefinition) ValidateCreate

func (r *ClusterDefinition) ValidateCreate() (admission.Warnings, error)

ValidateCreate implements webhook.Validator so a webhook will be registered for the type

func (*ClusterDefinition) ValidateDelete

func (r *ClusterDefinition) ValidateDelete() (admission.Warnings, error)

ValidateDelete implements webhook.Validator so a webhook will be registered for the type

func (*ClusterDefinition) ValidateEnabledLogConfigs

func (r *ClusterDefinition) ValidateEnabledLogConfigs(compDefName string, enabledLogs []string) []string

ValidateEnabledLogConfigs validates enabledLogs against component compDefName, and returns the invalid logNames undefined in ClusterDefinition.

func (*ClusterDefinition) ValidateUpdate

func (r *ClusterDefinition) ValidateUpdate(old runtime.Object) (admission.Warnings, error)

ValidateUpdate implements webhook.Validator so a webhook will be registered for the type

type ClusterDefinitionList

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

ClusterDefinitionList contains a list of ClusterDefinition

type ClusterDefinitionProbe

type ClusterDefinitionProbe struct {
	// How often (in seconds) to perform the probe.
	// +kubebuilder:default=1
	// +kubebuilder:validation:Minimum=1
	PeriodSeconds int32 `json:"periodSeconds,omitempty"`

	// Number of seconds after which the probe times out. Defaults to 1 second.
	// +kubebuilder:default=1
	// +kubebuilder:validation:Minimum=1
	TimeoutSeconds int32 `json:"timeoutSeconds,omitempty"`

	// Minimum consecutive failures for the probe to be considered failed after having succeeded.
	// +kubebuilder:default=3
	// +kubebuilder:validation:Minimum=2
	FailureThreshold int32 `json:"failureThreshold,omitempty"`

	// commands used to execute for probe.
	// +optional
	Commands *ClusterDefinitionProbeCMDs `json:"commands,omitempty"`
}

type ClusterDefinitionProbeCMDs

type ClusterDefinitionProbeCMDs struct {
	// Write check executed on probe sidecar, used to check workload's allow write access.
	// +optional
	Writes []string `json:"writes,omitempty"`

	// Read check executed on probe sidecar, used to check workload's readonly access.
	// +optional
	Queries []string `json:"queries,omitempty"`
}

type ClusterDefinitionProbes

type ClusterDefinitionProbes struct {
	// Probe for DB running check.
	// +optional
	RunningProbe *ClusterDefinitionProbe `json:"runningProbe,omitempty"`

	// Probe for DB status check.
	// +optional
	StatusProbe *ClusterDefinitionProbe `json:"statusProbe,omitempty"`

	// Probe for DB role changed check.
	// +optional
	//+kubebuilder:deprecatedversion:warning="This field is deprecated from KB 0.7.0, use RSMSpec instead."
	RoleProbe *ClusterDefinitionProbe `json:"roleProbe,omitempty"`

	// roleProbeTimeoutAfterPodsReady(in seconds), when all pods of the component are ready,
	// it will detect whether the application is available in the pod.
	// if pods exceed the InitializationTimeoutSeconds time without a role label,
	// this component will enter the Failed/Abnormal phase.
	// Note that this configuration will only take effect if the component supports RoleProbe
	// and will not affect the life cycle of the pod. default values are 60 seconds.
	// +optional
	// +kubebuilder:validation:Minimum=30
	RoleProbeTimeoutAfterPodsReady int32 `json:"roleProbeTimeoutAfterPodsReady,omitempty"`
}

type ClusterDefinitionSpec

type ClusterDefinitionSpec struct {

	// Cluster definition type defines well known application cluster type, e.g. mysql/redis/mongodb
	// +kubebuilder:validation:MaxLength=24
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$`
	// +optional
	Type string `json:"type,omitempty"`

	// componentDefs provides cluster components definitions.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MinItems=1
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	ComponentDefs []ClusterComponentDefinition `json:"componentDefs" patchStrategy:"merge,retainKeys" patchMergeKey:"name"`

	// Connection credential template used for creating a connection credential
	// secret for cluster.apps.kubeblocks.io object.
	//
	// Built-in objects are:
	// - `$(RANDOM_PASSWD)` - random 8 characters.
	// - `$(UUID)` - generate a random UUID v4 string.
	// - `$(UUID_B64)` - generate a random UUID v4 BASE64 encoded string.
	// - `$(UUID_STR_B64)` - generate a random UUID v4 string then BASE64 encoded.
	// - `$(UUID_HEX)` - generate a random UUID v4 HEX representation.
	// - `$(HEADLESS_SVC_FQDN)` - headless service FQDN placeholder, value pattern - $(CLUSTER_NAME)-$(1ST_COMP_NAME)-headless.$(NAMESPACE).svc,
	//    where 1ST_COMP_NAME is the 1st component that provide `ClusterDefinition.spec.componentDefs[].service` attribute;
	// - `$(SVC_FQDN)` - service FQDN  placeholder, value pattern - $(CLUSTER_NAME)-$(1ST_COMP_NAME).$(NAMESPACE).svc,
	//    where 1ST_COMP_NAME is the 1st component that provide `ClusterDefinition.spec.componentDefs[].service` attribute;
	// - `$(SVC_PORT_{PORT-NAME})` - a ServicePort's port value with specified port name, i.e, a servicePort JSON struct:
	//    `{"name": "mysql", "targetPort": "mysqlContainerPort", "port": 3306}`, and "$(SVC_PORT_mysql)" in the
	//    connection credential value is 3306.
	// +optional
	ConnectionCredential map[string]string `json:"connectionCredential,omitempty"`
}

ClusterDefinitionSpec defines the desired state of ClusterDefinition

type ClusterDefinitionStatus

type ClusterDefinitionStatus struct {
	// ClusterDefinition phase, valid values are `empty`, `Available`, 'Unavailable`.
	// Available is ClusterDefinition become available, and can be referenced for co-related objects.
	Phase Phase `json:"phase,omitempty"`

	// Extra message in current phase
	// +optional
	Message string `json:"message,omitempty"`

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

ClusterDefinitionStatus defines the observed state of ClusterDefinition

func (ClusterDefinitionStatus) GetTerminalPhases

func (r ClusterDefinitionStatus) GetTerminalPhases() []Phase

type ClusterList

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

ClusterList contains a list of Cluster.

type ClusterMonitor added in v0.6.0

type ClusterMonitor struct {

	// monitoringInterval specifies interval of monitoring, no monitor if set to 0
	// +kubebuilder:validation:XIntOrString
	// +optional
	MonitoringInterval *intstr.IntOrString `json:"monitoringInterval,omitempty"`
}

type ClusterNetwork added in v0.6.0

type ClusterNetwork struct {

	// hostNetworkAccessible specifies whether host network is accessible. It defaults to false
	// +kubebuilder:default=false
	// +optional
	HostNetworkAccessible bool `json:"hostNetworkAccessible,omitempty"`

	// publiclyAccessible specifies whether it is publicly accessible. It defaults to false
	// +kubebuilder:default=false
	// +optional
	PubliclyAccessible bool `json:"publiclyAccessible,omitempty"`
}

type ClusterPhase

type ClusterPhase string

ClusterPhase defines the Cluster CR .status.phase +enum +kubebuilder:validation:Enum={Creating,Running,Updating,Stopping,Stopped,Deleting,Failed,Abnormal}

const (
	CreatingClusterPhase ClusterPhase = "Creating"
	RunningClusterPhase  ClusterPhase = "Running"
	UpdatingClusterPhase ClusterPhase = "Updating"
	StoppingClusterPhase ClusterPhase = "Stopping"
	StoppedClusterPhase  ClusterPhase = "Stopped"
	DeletingClusterPhase ClusterPhase = "Deleting"
	FailedClusterPhase   ClusterPhase = "Failed"
	AbnormalClusterPhase ClusterPhase = "Abnormal"
)

func GetClusterUpRunningPhases

func GetClusterUpRunningPhases() []ClusterPhase

GetClusterUpRunningPhases returns Cluster running or partially running phases.

func GetReconfiguringRunningPhases added in v0.6.0

func GetReconfiguringRunningPhases() []ClusterPhase

GetReconfiguringRunningPhases return Cluster running or partially running phases.

type ClusterResourceConstraintSelector added in v0.6.0

type ClusterResourceConstraintSelector struct {
	// clusterDefRef is the name of the cluster definition.
	// +kubebuilder:validation:Required
	ClusterDefRef string `json:"clusterDefRef"`

	// selector is used to bind the resource constraint to components.
	// +listType=map
	// +listMapKey=componentDefRef
	// +kubebuilder:validation:Required
	Components []ComponentResourceConstraintSelector `json:"components"`
}

type ClusterResources added in v0.6.0

type ClusterResources struct {

	// cpu resource needed, more info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
	// +optional
	CPU resource.Quantity `json:"cpu,omitempty"`

	// memory resource needed, more info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
	// +optional
	Memory resource.Quantity `json:"memory,omitempty"`
}

type ClusterSpec

type ClusterSpec struct {
	// Cluster referencing ClusterDefinition name. This is an immutable attribute.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="clusterDefinitionRef is immutable"
	ClusterDefRef string `json:"clusterDefinitionRef"`

	// Cluster referencing ClusterVersion name.
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	// +optional
	ClusterVersionRef string `json:"clusterVersionRef,omitempty"`

	// Cluster termination policy. Valid values are DoNotTerminate, Halt, Delete, WipeOut.
	// DoNotTerminate will block delete operation.
	// Halt will delete workload resources such as statefulset, deployment workloads but keep PVCs.
	// Delete is based on Halt and deletes PVCs.
	// WipeOut is based on Delete and wipe out all volume snapshots and snapshot data from backup storage location.
	// +kubebuilder:validation:Required
	TerminationPolicy TerminationPolicyType `json:"terminationPolicy"`

	// List of componentSpecs you want to replace in ClusterDefinition and ClusterVersion. It will replace the field in ClusterDefinition's and ClusterVersion's component if type is matching.
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MinItems=1
	// +kubebuilder:validation:MaxItems=128
	// +kubebuilder:validation:XValidation:rule="self.all(x, size(self.filter(c, c.name == x.name)) == 1)",message="duplicated component"
	// +kubebuilder:validation:XValidation:rule="self.all(x, oldSelf.exists(y, y.name == x.name))",message="component can not be added dynamically"
	// +kubebuilder:validation:XValidation:rule="oldSelf.all(x, self.exists(y, y.name == x.name))",message="component can not be removed dynamically"
	ComponentSpecs []ClusterComponentSpec `json:"componentSpecs,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"name"`

	// tenancy describes how pods are distributed across node.
	// SharedNode means multiple pods may share the same node.
	// DedicatedNode means each pod runs on their own dedicated node.
	// +optional
	Tenancy TenancyType `json:"tenancy,omitempty"`

	// availabilityPolicy describes the availability policy, including zone, node, and none.
	// +optional
	AvailabilityPolicy AvailabilityPolicyType `json:"availabilityPolicy,omitempty"`

	// affinity is a group of affinity scheduling rules.
	// +optional
	Affinity *Affinity `json:"affinity,omitempty"`

	// tolerations are attached to tolerate any taint that matches the triple `key,value,effect` using the matching operator `operator`.
	// +kubebuilder:pruning:PreserveUnknownFields
	// +optional
	Tolerations []corev1.Toleration `json:"tolerations,omitempty"`

	// replicas specifies the replicas of the first componentSpec, if the replicas of the first componentSpec is specified, this value will be ignored.
	// +optional
	Replicas *int32 `json:"replicas,omitempty"`

	// resources specifies the resources of the first componentSpec, if the resources of the first componentSpec is specified, this value will be ignored.
	// +optional
	Resources ClusterResources `json:"resources,omitempty"`

	// storage specifies the storage of the first componentSpec, if the storage of the first componentSpec is specified, this value will be ignored.
	// +optional
	Storage ClusterStorage `json:"storage,omitempty"`

	// monitor specifies the configuration of monitor
	// +optional
	Monitor ClusterMonitor `json:"monitor,omitempty"`

	// network specifies the configuration of network
	// +optional
	Network *ClusterNetwork `json:"network,omitempty"`

	// cluster backup configuration.
	// +optional
	Backup *ClusterBackup `json:"backup,omitempty"`
}

ClusterSpec defines the desired state of Cluster.

func (ClusterSpec) GetComponentByName

func (r ClusterSpec) GetComponentByName(componentName string) *ClusterComponentSpec

GetComponentByName gets component by name.

func (ClusterSpec) GetComponentDefRefName

func (r ClusterSpec) GetComponentDefRefName(componentName string) string

GetComponentDefRefName gets the name of referenced component definition.

func (ClusterSpec) GetDefNameMappingComponents

func (r ClusterSpec) GetDefNameMappingComponents() map[string][]ClusterComponentSpec

GetDefNameMappingComponents returns ComponentDefRef name mapping ClusterComponentSpec.

func (ClusterSpec) ValidateEnabledLogs

func (r ClusterSpec) ValidateEnabledLogs(cd *ClusterDefinition) error

ValidateEnabledLogs validates enabledLogs config in cluster.yaml, and returns metav1.Condition when detecting invalid values.

type ClusterStatus

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

	// phase describes the phase of the Cluster, the detail information of the phases are as following:
	// Creating: all components are in `Creating` phase.
	// Running: all components are in `Running` phase, means the cluster is working well.
	// Updating: all components are in `Creating`, `Running` or `Updating` phase,
	// and at least one component is in `Creating` or `Updating` phase, means the cluster is doing an update.
	// Stopping: at least one component is in `Stopping` phase, means the cluster is in a stop progress.
	// Stopped: all components are in 'Stopped` phase, means the cluster has stopped and didn't provide any function anymore.
	// Failed: all components are in `Failed` phase, means the cluster is unavailable.
	// Abnormal: some components are in `Failed` or `Abnormal` phase, means the cluster in a fragile state. troubleshoot need to be done.
	// Deleting: the cluster is being deleted.
	// +optional
	Phase ClusterPhase `json:"phase,omitempty"`

	// message describes cluster details message in current phase.
	// +optional
	Message string `json:"message,omitempty"`

	// components record the current status information of all components of the cluster.
	// +optional
	Components map[string]ClusterComponentStatus `json:"components,omitempty"`

	// clusterDefGeneration represents the generation number of ClusterDefinition referenced.
	// +optional
	ClusterDefGeneration int64 `json:"clusterDefGeneration,omitempty"`

	// Describe current state of cluster API Resource, like warning.
	// +optional
	Conditions []metav1.Condition `json:"conditions,omitempty"`
}

ClusterStatus defines the observed state of Cluster.

func (*ClusterStatus) SetComponentStatus

func (r *ClusterStatus) SetComponentStatus(name string, status ClusterComponentStatus)

SetComponentStatus does safe operation on ClusterStatus.Components map object update.

type ClusterStorage added in v0.6.0

type ClusterStorage struct {

	// storage size needed, more info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/
	// +optional
	Size resource.Quantity `json:"size,omitempty"`
}

type ClusterSwitchPolicy

type ClusterSwitchPolicy struct {

	// clusterSwitchPolicy defines type of the switchPolicy when workloadType is Replication.
	// MaximumAvailability: [WIP] when the primary is active, do switch if the synchronization delay = 0 in the user-defined lagProbe data delay detection logic, otherwise do not switch. The primary is down, switch immediately. It will be available in future versions.
	// MaximumDataProtection: [WIP] when the primary is active, do switch if synchronization delay = 0 in the user-defined lagProbe data lag detection logic, otherwise do not switch. If the primary is down, if it can be judged that the primary and secondary data are consistent, then do the switch, otherwise do not switch. It will be available in future versions.
	// Noop: KubeBlocks will not perform high-availability switching on components. Users need to implement HA by themselves or integrate open source HA solution.
	// +kubebuilder:validation:Required
	// +kubebuilder:default=Noop
	// +optional
	Type SwitchPolicyType `json:"type"`
}

type ClusterVersion

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

	Spec   ClusterVersionSpec   `json:"spec,omitempty"`
	Status ClusterVersionStatus `json:"status,omitempty"`
}

ClusterVersion is the Schema for the ClusterVersions API

func (*ClusterVersion) GetInconsistentComponentsInfo

func (r *ClusterVersion) GetInconsistentComponentsInfo(clusterDef *ClusterDefinition) ([]string, []string)

GetInconsistentComponentsInfo get clusterVersion invalid component name and no containers component compared with clusterDefinitionDef

func (*ClusterVersion) SetupWebhookWithManager

func (r *ClusterVersion) SetupWebhookWithManager(mgr ctrl.Manager) error

func (*ClusterVersion) ValidateCreate

func (r *ClusterVersion) ValidateCreate() (admission.Warnings, error)

ValidateCreate implements webhook.Validator so a webhook will be registered for the type

func (*ClusterVersion) ValidateDelete

func (r *ClusterVersion) ValidateDelete() (admission.Warnings, error)

ValidateDelete implements webhook.Validator so a webhook will be registered for the type

func (*ClusterVersion) ValidateUpdate

func (r *ClusterVersion) ValidateUpdate(old runtime.Object) (admission.Warnings, error)

ValidateUpdate implements webhook.Validator so a webhook will be registered for the type

type ClusterVersionList

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

ClusterVersionList contains a list of ClusterVersion

type ClusterVersionMapping added in v0.7.0

type ClusterVersionMapping struct {
	// the array of ClusterVersion name which can be mapped to the env value.
	// +kubebuilder:validation:Required
	Names []string `json:"names"`

	// mapping value for the specified ClusterVersion names.
	// +kubebuilder:validation:Required
	MappingValue string `json:"mappingValue"`
}

type ClusterVersionSpec

type ClusterVersionSpec struct {
	// ref ClusterDefinition.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	ClusterDefinitionRef string `json:"clusterDefinitionRef"`

	// List of components' containers versioning context, i.e., container image ID, container commands, args., and environments.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MinItems=1
	// +patchMergeKey=componentDefRef
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=componentDefRef
	ComponentVersions []ClusterComponentVersion `json:"componentVersions" patchStrategy:"merge,retainKeys" patchMergeKey:"componentDefRef"`
}

ClusterVersionSpec defines the desired state of ClusterVersion

func (ClusterVersionSpec) GetDefNameMappingComponents

func (r ClusterVersionSpec) GetDefNameMappingComponents() map[string]*ClusterComponentVersion

GetDefNameMappingComponents returns ComponentDefRef name mapping ClusterComponentVersion.

type ClusterVersionStatus

type ClusterVersionStatus struct {
	// phase - in list of [Available,Unavailable]
	// +optional
	Phase Phase `json:"phase,omitempty"`

	// A human readable message indicating details about why the ClusterVersion is in this phase.
	// +optional
	Message string `json:"message,omitempty"`

	// generation number
	// +optional
	ObservedGeneration int64 `json:"observedGeneration,omitempty"`

	// clusterDefGeneration represents the generation number of ClusterDefinition referenced.
	// +optional
	ClusterDefGeneration int64 `json:"clusterDefGeneration,omitempty"`
}

ClusterVersionStatus defines the observed state of ClusterVersion

func (ClusterVersionStatus) GetTerminalPhases

func (r ClusterVersionStatus) GetTerminalPhases() []Phase

type CmdExecutorConfig

type CmdExecutorConfig struct {
	CommandExecutorEnvItem `json:",inline"`
	CommandExecutorItem    `json:",inline"`
}

CmdExecutorConfig specifies how to perform creation and deletion statements.

type CommandExecutorEnvItem

type CommandExecutorEnvItem struct {
	// image for Connector when executing the command.
	// +kubebuilder:validation:Required
	Image string `json:"image"`
	// envs is a list of environment variables.
	// +kubebuilder:pruning:PreserveUnknownFields
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +optional
	Env []corev1.EnvVar `json:"env,omitempty" patchStrategy:"merge" patchMergeKey:"name"`
}

type CommandExecutorItem

type CommandExecutorItem struct {
	// command to perform statements.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MinItems=1
	Command []string `json:"command"`
	// args is used to perform statements.
	// +optional
	Args []string `json:"args,omitempty"`
}

type ComponentClass

type ComponentClass struct {
	// name is the class name
	// +optional
	Name string `json:"name,omitempty"`

	// args are variable's value
	// +optional
	Args []string `json:"args,omitempty"`

	// the CPU of the class
	// +optional
	CPU resource.Quantity `json:"cpu,omitempty"`

	// the memory of the class
	// +optional
	Memory resource.Quantity `json:"memory,omitempty"`
}

func (*ComponentClass) Cmp added in v0.6.0

func (r *ComponentClass) Cmp(b *ComponentClass) int

func (*ComponentClass) ToResourceRequirements

func (r *ComponentClass) ToResourceRequirements() corev1.ResourceRequirements

type ComponentClassDefinition

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

	Spec   ComponentClassDefinitionSpec   `json:"spec,omitempty"`
	Status ComponentClassDefinitionStatus `json:"status,omitempty"`
}

ComponentClassDefinition is the Schema for the componentclassdefinitions API

type ComponentClassDefinitionList

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

ComponentClassDefinitionList contains a list of ComponentClassDefinition

type ComponentClassDefinitionSpec

type ComponentClassDefinitionSpec struct {
	// group defines a list of class series that conform to the same constraint.
	// +optional
	Groups []ComponentClassGroup `json:"groups,omitempty"`
}

ComponentClassDefinitionSpec defines the desired state of ComponentClassDefinition

type ComponentClassDefinitionStatus

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

	// classes is the list of classes that have been observed for this ComponentClassDefinition
	Classes []ComponentClass `json:"classes,omitempty"`
}

ComponentClassDefinitionStatus defines the observed state of ComponentClassDefinition

type ComponentClassGroup

type ComponentClassGroup struct {
	// template is a class definition template that uses the Go template syntax and allows for variable declaration.
	// When defining a class in Series, specifying the variable's value is sufficient, as the complete class
	// definition will be generated through rendering the template.
	//
	// For example:
	//	template: |
	//	  cpu: "{{ or .cpu 1 }}"
	//	  memory: "{{ or .memory 4 }}Gi"
	//
	// +optional
	Template string `json:"template,omitempty"`

	// vars defines the variables declared in the template and will be used to generating the complete class definition by
	// render the template.
	// +listType=set
	// +optional
	Vars []string `json:"vars,omitempty"`

	// series is a series of class definitions.
	// +optional
	Series []ComponentClassSeries `json:"series,omitempty"`
}

type ComponentClassSeries

type ComponentClassSeries struct {
	// namingTemplate is a template that uses the Go template syntax and allows for referencing variables defined
	// in ComponentClassGroup.Template. This enables dynamic generation of class names.
	// For example:
	// name: "general-{{ .cpu }}c{{ .memory }}g"
	// +optional
	NamingTemplate string `json:"namingTemplate,omitempty"`

	// classes are definitions of classes that come in two forms. In the first form, only ComponentClass.Args
	// need to be defined, and the complete class definition is generated by rendering the ComponentClassGroup.Template
	// and Name. In the second form, the Name, CPU and Memory must be defined.
	// +optional
	Classes []ComponentClass `json:"classes,omitempty"`
}

type ComponentConfigSpec

type ComponentConfigSpec struct {
	ComponentTemplateSpec `json:",inline"`

	// Specify a list of keys.
	// If empty, ConfigConstraint takes effect for all keys in configmap.
	// +listType=set
	// +optional
	Keys []string `json:"keys,omitempty"`

	// lazyRenderedConfigSpec is optional: specify the secondary rendered config spec.
	// +optional
	LegacyRenderedConfigSpec *LegacyRenderedTemplateSpec `json:"legacyRenderedConfigSpec,omitempty"`

	// Specify the name of the referenced the configuration constraints object.
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	// +optional
	ConfigConstraintRef string `json:"constraintRef,omitempty"`

	// asEnvFrom is optional: the list of containers will be injected into EnvFrom.
	// +listType=set
	// +optional
	AsEnvFrom []string `json:"asEnvFrom,omitempty"`
}

type ComponentDefRef added in v0.6.0

type ComponentDefRef struct {
	// componentDefName is the name of the componentDef to select.
	// +kubebuilder:validation:Required
	ComponentDefName string `json:"componentDefName"`
	// failurePolicy is the failure policy of the component.
	// If failed to find the component, the failure policy will be used.
	// +kubebuilder:validation:Enum={Ignore,Fail}
	// +default="Ignore"
	// +optional
	FailurePolicy FailurePolicyType `json:"failurePolicy,omitempty"`
	// componentRefEnv specifies a list of values to be injected as env variables to each component.
	// +kbubebuilder:validation:Required
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	// +optional
	ComponentRefEnvs []ComponentRefEnv `json:"componentRefEnv" patchStrategy:"merge" patchMergeKey:"name"`
}

ComponentDefRef is used to select the component and its fields to be referenced.

type ComponentMessageMap

type ComponentMessageMap map[string]string

func (ComponentMessageMap) SetObjectMessage

func (r ComponentMessageMap) SetObjectMessage(objectKind, objectName, message string)

SetObjectMessage sets k8s workload message to component status message map

type ComponentNameSet

type ComponentNameSet map[string]struct{}

type ComponentOps

type ComponentOps struct {
	// componentName cluster component name.
	// +kubebuilder:validation:Required
	ComponentName string `json:"componentName"`
}

ComponentOps defines the common variables of component scope operations.

type ComponentRefEnv added in v0.6.0

type ComponentRefEnv struct {
	// name is the name of the env to be injected, and it must be a C identifier.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Pattern=`^[A-Za-z_][A-Za-z0-9_]*$`
	Name string `json:"name"`
	// value is the value of the env to be injected.
	// +optional
	Value string `json:"value,omitempty"`
	// valueFrom specifies the source of the env to be injected.
	// +optional
	ValueFrom *ComponentValueFrom `json:"valueFrom,omitempty"`
}

ComponentRefEnv specifies name and value of an env.

type ComponentResourceConstraint

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

	Spec ComponentResourceConstraintSpec `json:"spec,omitempty"`
}

ComponentResourceConstraint is the Schema for the componentresourceconstraints API

func (*ComponentResourceConstraint) FindMatchingRules added in v0.6.0

func (c *ComponentResourceConstraint) FindMatchingRules(
	clusterDefRef string,
	componentDefRef string,
	resources corev1.ResourceList) []ResourceConstraintRule

FindMatchingRules find all constraint rules that resource satisfies.

func (*ComponentResourceConstraint) FindRules added in v0.6.0

func (c *ComponentResourceConstraint) FindRules(clusterDefRef, componentDefRef string) []ResourceConstraintRule

FindRules find all constraint rules that the component should conform to.

func (*ComponentResourceConstraint) MatchClass

func (c *ComponentResourceConstraint) MatchClass(clusterDefRef, componentDefRef string, class *ComponentClass) bool

MatchClass checks if the class meets the constraint rules.

type ComponentResourceConstraintList

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

ComponentResourceConstraintList contains a list of ComponentResourceConstraint

type ComponentResourceConstraintSelector added in v0.6.0

type ComponentResourceConstraintSelector struct {
	// componentDefRef is the name of the component definition in the cluster definition.
	// +kubebuilder:validation:Required
	ComponentDefRef string `json:"componentDefRef"`

	// rules are the constraint rules that will be applied to the component.
	// +kubebuilder:validation:Required
	Rules []string `json:"rules"`
}

type ComponentResourceConstraintSpec

type ComponentResourceConstraintSpec struct {
	// Component resource constraint rules.
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	// +kubebuilder:validation:Required
	Rules []ResourceConstraintRule `json:"rules"`

	// selector is used to bind the resource constraint to cluster definitions.
	// +listType=map
	// +listMapKey=clusterDefRef
	// +optional
	Selector []ClusterResourceConstraintSelector `json:"selector,omitempty"`
}

ComponentResourceConstraintSpec defines the desired state of ComponentResourceConstraint

type ComponentResourceKey

type ComponentResourceKey string

ComponentResourceKey defines the resource key of component, such as pod/pvc. +enum +kubebuilder:validation:Enum={pods}

const PodsCompResourceKey ComponentResourceKey = "pods"

type ComponentTemplateSpec

type ComponentTemplateSpec struct {
	// Specify the name of configuration template.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	Name string `json:"name"`

	// Specify the name of the referenced the configuration template ConfigMap object.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	TemplateRef string `json:"templateRef"`

	// Specify the namespace of the referenced the configuration template ConfigMap object.
	// An empty namespace is equivalent to the "default" namespace.
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$`
	// +kubebuilder:default="default"
	// +optional
	Namespace string `json:"namespace,omitempty"`

	// volumeName is the volume name of PodTemplate, which the configuration file produced through the configuration
	// template will be mounted to the corresponding volume. Must be a DNS_LABEL name.
	// The volume name must be defined in podSpec.containers[*].volumeMounts.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z]([a-z0-9\-]*[a-z0-9])?$`
	VolumeName string `json:"volumeName"`

	// defaultMode is optional: mode bits used to set permissions on created files by default.
	// Must be an octal value between 0000 and 0777 or a decimal value between 0 and 511.
	// YAML accepts both octal and decimal values, JSON requires decimal values for mode bits.
	// Defaults to 0644.
	// Directories within the path are not affected by this setting.
	// This might be in conflict with other options that affect the file
	// mode, like fsGroup, and the result can be other mode bits set.
	// +optional
	DefaultMode *int32 `json:"defaultMode,omitempty" protobuf:"varint,3,opt,name=defaultMode"`
}

type ComponentValueFrom added in v0.6.0

type ComponentValueFrom struct {
	// type is the type of the source to select. There are three types: `FieldRef`, `ServiceRef`, `HeadlessServiceRef`.
	// +kubebuilder:validation:Enum={FieldRef,ServiceRef,HeadlessServiceRef}
	// +kubebuilder:validation:Required
	Type ComponentValueFromType `json:"type"`
	// fieldRef is the jsonpath of the source to select when type is `FieldRef`.
	// there are two objects registered in the jsonpath: `componentDef` and `components`.
	// componentDef is the component definition object specified in `componentRef.componentDefName`.
	// components is the component list objects referring to the component definition object.
	// +optional
	FieldPath string `json:"fieldPath,omitempty"`
	// format is the format of each headless service address.
	// there are three builtin variables can be used as placeholder: $POD_ORDINAL, $POD_FQDN, $POD_NAME
	// $POD_ORDINAL is the ordinal of the pod.
	// $POD_FQDN is the fully qualified domain name of the pod.
	// $POD_NAME is the name of the pod
	// +optional
	// +kubebuilder:default=="$POD_FQDN"
	Format string `json:"format,omitempty"`
	// joinWith is the string to join the values of headless service addresses.
	// +optional
	// +kubebuilder:default=","
	JoinWith string `json:"joinWith,omitempty"`
}

type ComponentValueFromType added in v0.6.0

type ComponentValueFromType string

ComponentValueFromType specifies the type of component value from. +enum +kubebuilder:validation:Enum={FieldRef,ServiceRef,HeadlessServiceRef}

const (
	FromFieldRef           ComponentValueFromType = "FieldRef"
	FromServiceRef         ComponentValueFromType = "ServiceRef"
	FromHeadlessServiceRef ComponentValueFromType = "HeadlessServiceRef"
)

type ConfigConstraint

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

	Spec   ConfigConstraintSpec   `json:"spec,omitempty"`
	Status ConfigConstraintStatus `json:"status,omitempty"`
}

ConfigConstraint is the Schema for the configconstraint API

type ConfigConstraintList

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

ConfigConstraintList contains a list of ConfigConstraints.

type ConfigConstraintPhase

type ConfigConstraintPhase string

ConfigConstraintPhase defines the ConfigConstraint CR .status.phase +enum +kubebuilder:validation:Enum={Available,Unavailable, Deleting}

const (
	CCAvailablePhase   ConfigConstraintPhase = "Available"
	CCUnavailablePhase ConfigConstraintPhase = "Unavailable"
	CCDeletingPhase    ConfigConstraintPhase = "Deleting"
)

type ConfigConstraintSpec

type ConfigConstraintSpec struct {
	// reloadOptions indicates whether the process supports reload.
	// if set, the controller will determine the behavior of the engine instance based on the configuration templates,
	// restart or reload depending on whether any parameters in the StaticParameters have been modified.
	// +optional
	ReloadOptions *ReloadOptions `json:"reloadOptions,omitempty"`

	// toolConfig used to config init container.
	// +optional
	ToolsImageSpec *ToolsImageSpec `json:"toolsImageSpec,omitempty"`

	// downwardAPIOptions is used to watch pod fields.
	// +optional
	DownwardAPIOptions []DownwardAPIOption `json:"downwardAPIOptions,omitempty"`

	// scriptConfigs, list of ScriptConfig, witch these scripts can be used by volume trigger,downward trigger, or tool image
	// +optional
	// +patchMergeKey=scriptConfigMapRef
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=scriptConfigMapRef
	ScriptConfigs []ScriptConfig `json:"scriptConfigs,omitempty"`

	// cfgSchemaTopLevelName is cue type name, which generates openapi schema.
	// +optional
	CfgSchemaTopLevelName string `json:"cfgSchemaTopLevelName,omitempty"`

	// configurationSchema imposes restrictions on database parameter's rule.
	// +optional
	ConfigurationSchema *CustomParametersValidation `json:"configurationSchema,omitempty"`

	// staticParameters, list of StaticParameter, modifications of them trigger a process restart.
	// +listType=set
	// +optional
	StaticParameters []string `json:"staticParameters,omitempty"`

	// dynamicParameters, list of DynamicParameter, modifications of them trigger a config dynamic reload without process restart.
	// +listType=set
	// +optional
	DynamicParameters []string `json:"dynamicParameters,omitempty"`

	// immutableParameters describes parameters that prohibit user from modification.
	// +listType=set
	// +optional
	ImmutableParameters []string `json:"immutableParameters,omitempty"`

	// selector is used to match the label on the pod,
	// for example, a pod of the primary is match on the patroni cluster.
	Selector *metav1.LabelSelector `json:"selector,omitempty"`

	// formatterConfig describes the format of the configuration file, the controller
	// 1. parses configuration file
	// 2. analyzes the modified parameters
	// 3. applies corresponding policies.
	// +kubebuilder:validation:Required
	FormatterConfig *FormatterConfig `json:"formatterConfig"`
}

ConfigConstraintSpec defines the desired state of ConfigConstraint

type ConfigConstraintStatus

type ConfigConstraintStatus struct {
	// phase is status of configuration template, when set to CCAvailablePhase, it can be referenced by ClusterDefinition or ClusterVersion.
	// +optional
	Phase ConfigConstraintPhase `json:"phase,omitempty"`

	// message field describes the reasons of abnormal status.
	// +optional
	Message string `json:"message,omitempty"`

	// observedGeneration is the latest generation observed for this
	// ClusterDefinition. It refers to the ConfigConstraint's generation, which is
	// updated by the API Server.
	// +optional
	ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

ConfigConstraintStatus defines the observed state of ConfigConstraint.

func (ConfigConstraintStatus) IsConfigConstraintTerminalPhases

func (cs ConfigConstraintStatus) IsConfigConstraintTerminalPhases() bool

type ConfigMapRef added in v0.8.0

type ConfigMapRef struct {
	ResourceMeta `json:",inline"`

	// configMap defines the configmap volume source.
	// +kubebuilder:validation:Required
	ConfigMap corev1.ConfigMapVolumeSource `json:"configMap"`
}

type ConfigParams added in v0.7.0

type ConfigParams struct {

	// fileContent indicates the configuration file content.
	// +optional
	Content *string `json:"content"`

	// updated parameters for a single configuration file.
	// +optional
	Parameters map[string]*string `json:"parameters,omitempty"`
}

type ConfigTemplateExtension added in v0.7.0

type ConfigTemplateExtension struct {
	// Specify the name of the referenced the configuration template ConfigMap object.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	TemplateRef string `json:"templateRef"`

	// Specify the namespace of the referenced the configuration template ConfigMap object.
	// An empty namespace is equivalent to the "default" namespace.
	// +kubebuilder:default="default"
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$`
	// +optional
	Namespace string `json:"namespace,omitempty"`

	// policy defines how to merge external imported templates into component templates.
	// +kubebuilder:default="none"
	// +optional
	Policy MergedPolicy `json:"policy,omitempty"`
}

type Configuration

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

	Spec   ConfigurationSpec   `json:"spec,omitempty"`
	Status ConfigurationStatus `json:"status,omitempty"`
}

Configuration is the Schema for the configurations API

type ConfigurationItem added in v0.7.0

type ConfigurationItem struct {
	// name is a config template name.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	Name string `json:"name"`

	// policy defines the upgrade policy.
	// +optional
	Policy *UpgradePolicy `json:"policy,omitempty"`

	// keys is used to set the parameters to be updated.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MinItems=1
	// +patchMergeKey=key
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=key
	Keys []ParameterConfig `json:"keys" patchStrategy:"merge,retainKeys" patchMergeKey:"key"`
}

type ConfigurationItemDetail added in v0.7.0

type ConfigurationItemDetail struct {
	// Specify the name of configuration template.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	Name string `json:"name"`

	// version is the version of configuration template.
	// +optional
	Version string `json:"version,omitempty"`

	// configSpec is used to set the configuration template.
	// +optional
	ConfigSpec *ComponentConfigSpec `json:"configSpec"`

	// Specify the configuration template.
	// +optional
	ImportTemplateRef *ConfigTemplateExtension `json:"importTemplateRef"`

	// configFileParams is used to set the parameters to be updated.
	// +optional
	ConfigFileParams map[string]ConfigParams `json:"configFileParams,omitempty"`
}

type ConfigurationItemDetailStatus added in v0.7.0

type ConfigurationItemDetailStatus struct {
	// name is a config template name.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	Name string `json:"name"`

	// phase is status of configurationItem.
	// +optional
	Phase ConfigurationPhase `json:"phase,omitempty"`

	// lastDoneRevision is the last done revision of configurationItem.
	// +optional
	LastDoneRevision string `json:"lastDoneRevision,omitempty"`

	// updateRevision is the update revision of configurationItem.
	// +optional
	UpdateRevision string `json:"updateRevision,omitempty"`

	// message field describes the reasons of abnormal status.
	// +optional
	Message *string `json:"message,omitempty"`

	// reconcileDetail describes the details of the configuration change execution.
	// +optional
	ReconcileDetail *ReconcileDetail `json:"reconcileDetail,omitempty"`
}

type ConfigurationItemStatus added in v0.7.0

type ConfigurationItemStatus struct {
	// name is a config template name.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	Name string `json:"name"`

	// updatePolicy describes the policy of reconfiguring.
	// +optional
	UpdatePolicy UpgradePolicy `json:"updatePolicy,omitempty"`

	// status describes the current state of the reconfiguring state machine.
	// +optional
	Status string `json:"status,omitempty"`

	// message describes the details about this operation.
	// +optional
	Message string `json:"message,omitempty"`

	// succeedCount describes the number of successful reconfiguring.
	// +kubebuilder:default=0
	// +optional
	SucceedCount int32 `json:"succeedCount"`

	// expectedCount describes the number of expected reconfiguring.
	// +kubebuilder:default=-1
	// +optional
	ExpectedCount int32 `json:"expectedCount"`

	// lastStatus describes the last status for the reconfiguring controller.
	// +optional
	LastAppliedStatus string `json:"lastStatus,omitempty"`

	// LastAppliedConfiguration describes the last configuration.
	// +optional
	LastAppliedConfiguration map[string]string `json:"lastAppliedConfiguration,omitempty"`

	// updatedParameters describes the updated parameters.
	// +optional
	UpdatedParameters UpdatedParameters `json:"updatedParameters"`
}

type ConfigurationList added in v0.7.0

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

ConfigurationList contains a list of Configuration

type ConfigurationPhase added in v0.7.0

type ConfigurationPhase string

ConfigurationPhase defines the Configuration FSM phase +enum +kubebuilder:validation:Enum={Creating,Init,Running,Pending,Merged,MergeFailed,FailedAndPause,Upgrading,Deleting,FailedAndRetry,Finished}

const (
	CCreatingPhase       ConfigurationPhase = "Creating"
	CInitPhase           ConfigurationPhase = "Init"
	CRunningPhase        ConfigurationPhase = "Running"
	CPendingPhase        ConfigurationPhase = "Pending"
	CFailedPhase         ConfigurationPhase = "FailedAndRetry"
	CFailedAndPausePhase ConfigurationPhase = "FailedAndPause"
	CMergedPhase         ConfigurationPhase = "Merged"
	CMergeFailedPhase    ConfigurationPhase = "MergeFailed"
	CDeletingPhase       ConfigurationPhase = "Deleting"
	CUpgradingPhase      ConfigurationPhase = "Upgrading"
	CFinishedPhase       ConfigurationPhase = "Finished"
)

type ConfigurationSpec added in v0.7.0

type ConfigurationSpec struct {

	// clusterRef references Cluster name.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.clusterRef"
	ClusterRef string `json:"clusterRef"`

	// componentName is cluster component name.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.clusterRef"
	ComponentName string `json:"componentName"`

	// customConfigurationItems describes user-defined config template.
	// +optional
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	ConfigItemDetails []ConfigurationItemDetail `json:"configItemDetails,omitempty"`
}

ConfigurationSpec defines the desired state of Configuration

func (*ConfigurationSpec) GetConfigurationItem added in v0.7.0

func (configuration *ConfigurationSpec) GetConfigurationItem(name string) *ConfigurationItemDetail

type ConfigurationStatus

type ConfigurationStatus struct {

	// message field describes the reasons of abnormal status.
	// +optional
	Message string `json:"message,omitempty"`

	// observedGeneration is the latest generation observed for this
	// ClusterDefinition. It refers to the ConfigConstraint's generation, which is
	// updated by the API Server.
	// +optional
	ObservedGeneration int64 `json:"observedGeneration,omitempty"`

	// conditions describes opsRequest detail status.
	// +optional
	// +patchMergeKey=type
	// +patchStrategy=merge
	// +listType=map
	// +listMapKey=type
	Conditions []metav1.Condition `json:"conditions,omitempty"`

	// configurationStatus describes the status of the component reconfiguring.
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	ConfigurationItemStatus []ConfigurationItemDetailStatus `json:"configurationStatus"`
}

ConfigurationStatus defines the observed state of Configuration

func (*ConfigurationStatus) GetItemStatus added in v0.7.0

func (status *ConfigurationStatus) GetItemStatus(name string) *ConfigurationItemDetailStatus

type ConnectionCredentialAuth added in v0.7.0

type ConnectionCredentialAuth struct {
	// service connection based-on username and password credential.
	// +optional
	Username *CredentialVar `json:"username,omitempty"`

	// service connection based-on username and password credential.
	// +optional
	Password *CredentialVar `json:"password,omitempty"`
}

type ConnectionCredentialKey

type ConnectionCredentialKey struct {
	// the key of password in the ConnectionCredential secret.
	// if not set, the default key is "password".
	// +optional
	PasswordKey *string `json:"passwordKey,omitempty"`

	// the key of username in the ConnectionCredential secret.
	// if not set, the default key is "username".
	// +optional
	UsernameKey *string `json:"usernameKey,omitempty"`

	// hostKey specifies the map key of the host in the connection credential secret.
	HostKey *string `json:"hostKey,omitempty"`

	// portKey specifies the map key of the port in the connection credential secret.
	// +kubebuilder:default=port
	PortKey *string `json:"portKey,omitempty"`
}

type ConsensusMember

type ConsensusMember struct {
	// name, role name.
	// +kubebuilder:validation:Required
	// +kubebuilder:default=leader
	Name string `json:"name"`

	// accessMode, what service this member capable.
	// +kubebuilder:validation:Required
	// +kubebuilder:default=ReadWrite
	AccessMode AccessMode `json:"accessMode"`

	// replicas, number of Pods of this role.
	// default 1 for Leader
	// default 0 for Learner
	// default Cluster.spec.componentSpec[*].Replicas - Leader.Replicas - Learner.Replicas for Followers
	// +kubebuilder:default=0
	// +kubebuilder:validation:Minimum=0
	// +optional
	Replicas *int32 `json:"replicas,omitempty"`
}

type ConsensusMemberStatus

type ConsensusMemberStatus struct {
	// Defines the role name.
	// +kubebuilder:validation:Required
	// +kubebuilder:default=leader
	Name string `json:"name"`

	// accessMode defines what service this pod provides.
	// +kubebuilder:validation:Required
	// +kubebuilder:default=ReadWrite
	AccessMode AccessMode `json:"accessMode"`

	// Pod name.
	// +kubebuilder:validation:Required
	// +kubebuilder:default=Unknown
	Pod string `json:"pod"`
}

type ConsensusSetSpec

type ConsensusSetSpec struct {
	StatefulSetSpec `json:",inline"`

	// leader, one single leader.
	// +kubebuilder:validation:Required
	Leader ConsensusMember `json:"leader"`

	// followers, has voting right but not Leader.
	// +optional
	Followers []ConsensusMember `json:"followers,omitempty"`

	// learner, no voting right.
	// +optional
	Learner *ConsensusMember `json:"learner,omitempty"`
}

func NewConsensusSetSpec added in v0.6.0

func NewConsensusSetSpec() *ConsensusSetSpec

func (*ConsensusSetSpec) FinalStsUpdateStrategy added in v0.6.0

func (*ConsensusSetSpec) GetUpdateStrategy added in v0.6.0

func (r *ConsensusSetSpec) GetUpdateStrategy() UpdateStrategy

type ConsensusSetStatus

type ConsensusSetStatus struct {
	// Leader status.
	// +kubebuilder:validation:Required
	Leader ConsensusMemberStatus `json:"leader"`

	// Followers status.
	// +optional
	Followers []ConsensusMemberStatus `json:"followers,omitempty"`

	// Learner status.
	// +optional
	Learner *ConsensusMemberStatus `json:"learner,omitempty"`
}

type CredentialVar added in v0.7.0

type CredentialVar struct {

	// Variable references $(VAR_NAME) are expanded
	// using the previously defined environment variables in the container and
	// any service environment variables. If a variable cannot be resolved,
	// the reference in the input string will be unchanged. Double $$ are reduced
	// to a single $, which allows for escaping the $(VAR_NAME) syntax: i.e.
	// "$$(VAR_NAME)" will produce the string literal "$(VAR_NAME)".
	// Escaped references will never be expanded, regardless of whether the variable
	// exists or not.
	// Defaults to "".
	// +optional
	Value string `json:"value,omitempty" protobuf:"bytes,2,opt,name=value"`
	// Source for the environment variable's value. Cannot be used if value is not empty.
	// +optional
	ValueFrom *corev1.EnvVarSource `json:"valueFrom,omitempty" protobuf:"bytes,3,opt,name=valueFrom"`
}

type CustomLabelSpec

type CustomLabelSpec struct {
	// key name of label
	// +kubebuilder:validation:Required
	Key string `json:"key"`

	// value of label
	// +kubebuilder:validation:Required
	Value string `json:"value"`

	// resources defines the resources to be labeled.
	// +kubebuilder:validation:Required
	Resources []GVKResource `json:"resources,omitempty"`
}

type CustomParametersValidation

type CustomParametersValidation struct {
	// schema provides a way for providers to validate the changed parameters through json.
	// +kubebuilder:validation:Schemaless
	// +kubebuilder:validation:ComponentDefRef=object
	// +kubebuilder:pruning:PreserveUnknownFields
	Schema *apiext.JSONSchemaProps `json:"schema,omitempty"`

	// cue that to let provider verify user configuration through cue language.
	// +optional
	CUE string `json:"cue,omitempty"`
}

type DownwardAPIOption added in v0.6.0

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

	// mountPoint is the mount point of the scripts file.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=128
	MountPoint string `json:"mountPoint"`

	// Items is a list of downward API volume file
	// +kubebuilder:validation:Required
	Items []corev1.DownwardAPIVolumeFile `json:"items"`

	// command used to execute for downwrad api.
	// +optional
	Command []string `json:"command,omitempty"`
}

type EnvMappingVar added in v0.7.0

type EnvMappingVar struct {
	// env key which needs to mapping.
	// +kubebuilder:validation:Required
	Key string `json:"key"`

	// valueFrom defines source of the env value.
	// +kubebuilder:validation:Required
	ValueFrom ValueFrom `json:"valueFrom"`
}

type ExporterConfig

type ExporterConfig struct {
	// scrapePort is exporter port for Time Series Database to scrape metrics.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:XIntOrString
	ScrapePort intstr.IntOrString `json:"scrapePort"`

	// scrapePath is exporter url path for Time Series Database to scrape metrics.
	// +kubebuilder:validation:MaxLength=128
	// +kubebuilder:default="/metrics"
	// +optional
	ScrapePath string `json:"scrapePath,omitempty"`
}

type Expose

type Expose struct {
	ComponentOps `json:",inline"`

	// Setting the list of services to be exposed.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Minitems=0
	Services []ClusterComponentService `json:"services"`
}

type FailurePolicyType added in v0.6.0

type FailurePolicyType string

FailurePolicyType specifies the type of failure policy +enum +kubebuilder:validation:Enum={Ignore,Fail}

const (
	// Ignore means that an error will be ignored but logged.
	FailurePolicyIgnore FailurePolicyType = "Ignore"
	// ReportError means that an error will be reported.
	FailurePolicyFail FailurePolicyType = "Fail"
)

type FormatterConfig

type FormatterConfig struct {
	// The FormatterOptions represents the special options of configuration file.
	// This is optional for now. If not specified.
	// +optional
	FormatterOptions `json:",inline"`

	// The configuration file format. Valid values are ini, xml, yaml, json,
	// hcl, dotenv, properties and toml.
	//
	// ini: a configuration file that consists of a text-based content with a structure and syntax comprising key–value pairs for properties, reference wiki: https://en.wikipedia.org/wiki/INI_file
	// xml: reference wiki: https://en.wikipedia.org/wiki/XML
	// yaml: a configuration file support for complex data types and structures.
	// json: reference wiki: https://en.wikipedia.org/wiki/JSON
	// hcl: : The HashiCorp Configuration Language (HCL) is a configuration language authored by HashiCorp, reference url: https://www.linode.com/docs/guides/introduction-to-hcl/
	// dotenv: this was a plain text file with simple key–value pairs, reference wiki: https://en.wikipedia.org/wiki/Configuration_file#MS-DOS
	// properties: a file extension mainly used in Java, reference wiki: https://en.wikipedia.org/wiki/.properties
	// toml: reference wiki: https://en.wikipedia.org/wiki/TOML
	// props-plus: a file extension mainly used in Java, support CamelCase(e.g: brokerMaxConnectionsPerIp)
	// +kubebuilder:validation:Required
	Format CfgFileFormat `json:"format"`
}

type FormatterOptions

type FormatterOptions struct {
	// iniConfig represents the ini options.
	// +optional
	IniConfig *IniConfig `json:"iniConfig,omitempty"`
}

FormatterOptions represents the special options of configuration file. Only one of its members may be specified.

type GVKResource

type GVKResource struct {
	// gvk is Group/Version/Kind, for example "v1/Pod", "apps/v1/StatefulSet", etc.
	// when the gvk resource filtered by the selector already exists, if there is no corresponding custom label, it will be added, and if label already exists, it will be updated.
	// +kubebuilder:validation:Required
	GVK string `json:"gvk"`

	// selector is a label query over a set of resources.
	// +optional
	Selector map[string]string `json:"selector,omitempty"`
}

type HScaleDataClonePolicyType

type HScaleDataClonePolicyType string

HScaleDataClonePolicyType defines data clone policy when horizontal scaling. +enum +kubebuilder:validation:Enum={None,CloneVolume,Snapshot}

const (
	HScaleDataClonePolicyNone         HScaleDataClonePolicyType = "None"
	HScaleDataClonePolicyCloneVolume  HScaleDataClonePolicyType = "CloneVolume"
	HScaleDataClonePolicyFromSnapshot HScaleDataClonePolicyType = "Snapshot"
)

type HorizontalScalePolicy

type HorizontalScalePolicy struct {
	// type controls what kind of data synchronization do when component scale out.
	// Policy is in enum of {None, CloneVolume}. The default policy is `None`.
	// None: Default policy, create empty volume and no data clone.
	// CloneVolume: Do data clone to newly scaled pods. Prefer to use volume snapshot first,
	//         and will try backup tool if volume snapshot is not enabled, finally
	// 	       report error if both above cannot work.
	// Snapshot: Deprecated, alias for CloneVolume.
	// +kubebuilder:default=None
	// +optional
	Type HScaleDataClonePolicyType `json:"type,omitempty"`

	// BackupPolicyTemplateName reference the backup policy template.
	// +optional
	BackupPolicyTemplateName string `json:"backupPolicyTemplateName,omitempty"`

	// volumeMountsName defines which volumeMount of the container to do backup,
	// only work if Type is not None
	// if not specified, the 1st volumeMount will be chosen
	// +optional
	VolumeMountsName string `json:"volumeMountsName,omitempty"`
}

type HorizontalScaling

type HorizontalScaling struct {
	ComponentOps `json:",inline"`

	// replicas for the workloads.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Minimum=0
	Replicas int32 `json:"replicas"`
}

HorizontalScaling defines the variables of horizontal scaling operation

type IniConfig

type IniConfig struct {
	// sectionName describes ini section.
	// +optional
	SectionName string `json:"sectionName,omitempty"`
}

type Issuer

type Issuer struct {
	// Name of issuer.
	// Options supported:
	// - KubeBlocks - Certificates signed by KubeBlocks Operator.
	// - UserProvided - User provided own CA-signed certificates.
	// +kubebuilder:validation:Enum={KubeBlocks, UserProvided}
	// +kubebuilder:default=KubeBlocks
	// +kubebuilder:validation:Required
	Name IssuerName `json:"name"`

	// secretRef. TLS certs Secret reference
	// required when from is UserProvided
	// +optional
	SecretRef *TLSSecretRef `json:"secretRef,omitempty"`
}

Issuer defines Tls certs issuer

type IssuerName

type IssuerName string

IssuerName defines Tls certs issuer name +enum

const (
	// IssuerKubeBlocks Certificates signed by KubeBlocks Operator.
	IssuerKubeBlocks IssuerName = "KubeBlocks"
	// IssuerUserProvided User provided own CA-signed certificates.
	IssuerUserProvided IssuerName = "UserProvided"
)

type KBAccountType

type KBAccountType uint8

KBAccountType is used for bitwise operation.

type LastComponentConfiguration

type LastComponentConfiguration struct {
	// replicas are the last replicas of the component.
	// +optional
	Replicas *int32 `json:"replicas,omitempty"`

	// the last resources of the component.
	// +kubebuilder:pruning:PreserveUnknownFields
	// +optional
	corev1.ResourceRequirements `json:",inline,omitempty"`

	// classDefRef reference class defined in ComponentClassDefinition.
	// +optional
	ClassDefRef *ClassDefRef `json:"classDefRef,omitempty"`

	// volumeClaimTemplates records the last volumeClaimTemplates of the component.
	// +optional
	VolumeClaimTemplates []OpsRequestVolumeClaimTemplate `json:"volumeClaimTemplates,omitempty"`

	// services records the last services of the component.
	// +optional
	Services []ClusterComponentService `json:"services,omitempty"`

	// targetResources records the affecting target resources information for the component.
	// resource key is in list of [pods].
	// +optional
	TargetResources map[ComponentResourceKey][]string `json:"targetResources,omitempty"`
}

type LastConfiguration

type LastConfiguration struct {
	// clusterVersionRef references ClusterVersion name.
	// +optional
	ClusterVersionRef string `json:"clusterVersionRef,omitempty"`

	// components records last configuration of the component.
	// +optional
	Components map[string]LastComponentConfiguration `json:"components,omitempty"`
}

type LegacyRenderedTemplateSpec added in v0.7.0

type LegacyRenderedTemplateSpec struct {
	ConfigTemplateExtension `json:",inline"`
}

type LetterCase

type LetterCase string

LetterCase defines cases to use in password generation. +enum

const (
	LowerCases LetterCase = "LowerCases"
	UpperCases LetterCase = "UpperCases"
	MixedCases LetterCase = "MixedCases"
)

type LogConfig

type LogConfig struct {
	// name log type name, such as slow for MySQL slow log file.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=128
	Name string `json:"name"`

	// filePathPattern log file path pattern which indicate how to find this file
	// corresponding to variable (log path) in database kernel. please don't set this casually.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=4096
	FilePathPattern string `json:"filePathPattern"`
}

type MemoryConstraint

type MemoryConstraint struct {
	// The size of memory per vcpu core.
	// For example: 1Gi, 200Mi.
	// If SizePerCPU is specified, MinPerCPU and MaxPerCPU are ignore.
	// +optional
	SizePerCPU *resource.Quantity `json:"sizePerCPU,omitempty"`

	// The maximum size of memory per vcpu core, [MinPerCPU, MaxPerCPU] defines a range for valid memory size per vcpu core.
	// It is useful on GCP as the ratio between the CPU and memory may be a range.
	// If SizePerCPU is specified, MinPerCPU and MaxPerCPU are ignored.
	// Reference: https://cloud.google.com/compute/docs/general-purpose-machines#custom_machine_types
	// +optional
	MaxPerCPU *resource.Quantity `json:"maxPerCPU,omitempty"`

	// The minimum size of memory per vcpu core, [MinPerCPU, MaxPerCPU] defines a range for valid memory size per vcpu core.
	// It is useful on GCP as the ratio between the CPU and memory may be a range.
	// If SizePerCPU is specified, MinPerCPU and MaxPerCPU are ignored.
	// Reference: https://cloud.google.com/compute/docs/general-purpose-machines#custom_machine_types
	// +optional
	MinPerCPU *resource.Quantity `json:"minPerCPU,omitempty"`
}

type MergedPolicy added in v0.6.0

type MergedPolicy string

MergedPolicy defines how to merge external imported templates into component templates. +enum +kubebuilder:validation:Enum={patch,replace,none}

const (
	PatchPolicy     MergedPolicy = "patch"
	ReplacePolicy   MergedPolicy = "replace"
	OnlyAddPolicy   MergedPolicy = "add"
	NoneMergePolicy MergedPolicy = "none"
)

type MonitorConfig

type MonitorConfig struct {
	// builtIn is a switch to enable KubeBlocks builtIn monitoring.
	// If BuiltIn is set to true, monitor metrics will be scraped automatically.
	// If BuiltIn is set to false, the provider should set ExporterConfig and Sidecar container own.
	// +kubebuilder:default=false
	// +optional
	BuiltIn bool `json:"builtIn,omitempty"`

	// exporterConfig provided by provider, which specify necessary information to Time Series Database.
	// exporterConfig is valid when builtIn is false.
	// +optional
	Exporter *ExporterConfig `json:"exporterConfig,omitempty"`
}

type OpsPhase

type OpsPhase string

OpsPhase defines opsRequest phase. +enum +kubebuilder:validation:Enum={Pending,Creating,Running,Cancelling,Cancelled,Failed,Succeed}

const (
	OpsPendingPhase    OpsPhase = "Pending"
	OpsCreatingPhase   OpsPhase = "Creating"
	OpsRunningPhase    OpsPhase = "Running"
	OpsCancellingPhase OpsPhase = "Cancelling"
	OpsSucceedPhase    OpsPhase = "Succeed"
	OpsCancelledPhase  OpsPhase = "Cancelled"
	OpsFailedPhase     OpsPhase = "Failed"
)

type OpsRecorder

type OpsRecorder struct {
	// name OpsRequest name
	Name string `json:"name"`
	// clusterPhase the cluster phase when the OpsRequest is running
	Type OpsType `json:"type"`
}

type OpsRequest

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

	Spec   OpsRequestSpec   `json:"spec,omitempty"`
	Status OpsRequestStatus `json:"status,omitempty"`
}

OpsRequest is the Schema for the opsrequests API

func GetRunningOpsByOpsType added in v0.6.0

func GetRunningOpsByOpsType(ctx context.Context, cli client.Client,
	clusterName, namespace, opsType string) ([]OpsRequest, error)

GetRunningOpsByOpsType gets the running opsRequests by type.

func (*OpsRequest) GetComponentNameSet

func (r *OpsRequest) GetComponentNameSet() ComponentNameSet

GetComponentNameSet if the operations are within the scope of component, this function should be implemented

func (*OpsRequest) GetUpgradeComponentNameSet

func (r *OpsRequest) GetUpgradeComponentNameSet() ComponentNameSet

GetUpgradeComponentNameSet gets the component name map with upgrade operation.

func (*OpsRequest) IsComplete added in v0.6.0

func (r *OpsRequest) IsComplete(phases ...OpsPhase) bool

IsComplete checks if opsRequest has been completed.

func (*OpsRequest) SetStatusCondition

func (r *OpsRequest) SetStatusCondition(condition metav1.Condition)

func (*OpsRequest) SetupWebhookWithManager

func (r *OpsRequest) SetupWebhookWithManager(mgr ctrl.Manager) error

func (*OpsRequest) Validate

func (r *OpsRequest) Validate(ctx context.Context,
	k8sClient client.Client,
	cluster *Cluster,
	isCreate bool) error

Validate validates OpsRequest

func (*OpsRequest) ValidateCreate

func (r *OpsRequest) ValidateCreate() (admission.Warnings, error)

ValidateCreate implements webhook.Validator so a webhook will be registered for the type

func (*OpsRequest) ValidateDelete

func (r *OpsRequest) ValidateDelete() (admission.Warnings, error)

ValidateDelete implements webhook.Validator so a webhook will be registered for the type

func (*OpsRequest) ValidateUpdate

func (r *OpsRequest) ValidateUpdate(old runtime.Object) (admission.Warnings, error)

ValidateUpdate implements webhook.Validator so a webhook will be registered for the type

type OpsRequestBehaviour

type OpsRequestBehaviour struct {
	FromClusterPhases                  []ClusterPhase
	ToClusterPhase                     ClusterPhase
	ProcessingReasonInClusterCondition string
}

type OpsRequestComponentStatus

type OpsRequestComponentStatus struct {
	// phase describes the component phase, reference Cluster.status.component.phase.
	// +optional
	Phase ClusterComponentPhase `json:"phase,omitempty"`

	// lastFailedTime is the last time the component phase transitioned to Failed or Abnormal.
	// +optional
	LastFailedTime metav1.Time `json:"lastFailedTime,omitempty"`

	// progressDetails describes the progress details of the component for this operation.
	// +optional
	ProgressDetails []ProgressStatusDetail `json:"progressDetails,omitempty"`

	// workloadType references workload type of component in ClusterDefinition.
	// +optional
	WorkloadType WorkloadType `json:"workloadType,omitempty"`

	// reason describes the reason for the component phase.
	// +kubebuilder:validation:MaxLength=1024
	// +optional
	Reason string `json:"reason,omitempty" protobuf:"bytes,5,opt,name=reason"`

	// message is a human-readable message indicating details about this operation.
	// +kubebuilder:validation:MaxLength=32768
	// +optional
	Message string `json:"message,omitempty" protobuf:"bytes,6,opt,name=message"`
}

type OpsRequestList

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

OpsRequestList contains a list of OpsRequest

type OpsRequestSpec

type OpsRequestSpec struct {
	// clusterRef references clusterDefinition.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.clusterRef"
	ClusterRef string `json:"clusterRef"`

	// cancel defines the action to cancel the Pending/Creating/Running opsRequest, supported types: [VerticalScaling, HorizontalScaling].
	// once cancel is set to true, this opsRequest will be canceled and modifying this property again will not take effect.
	// +optional
	Cancel bool `json:"cancel,omitempty"`

	// type defines the operation type.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.type"
	Type OpsType `json:"type"`

	// ttlSecondsAfterSucceed OpsRequest will be deleted after TTLSecondsAfterSucceed second when OpsRequest.status.phase is Succeed.
	// +optional
	TTLSecondsAfterSucceed int32 `json:"ttlSecondsAfterSucceed,omitempty"`

	// upgrade specifies the cluster version by specifying clusterVersionRef.
	// +optional
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.upgrade"
	Upgrade *Upgrade `json:"upgrade,omitempty"`

	// horizontalScaling defines what component need to horizontal scale the specified replicas.
	// +optional
	// +patchMergeKey=componentName
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=componentName
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.horizontalScaling"
	HorizontalScalingList []HorizontalScaling `json:"horizontalScaling,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"componentName"`

	// volumeExpansion defines what component and volumeClaimTemplate need to expand the specified storage.
	// +optional
	// +patchMergeKey=componentName
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=componentName
	VolumeExpansionList []VolumeExpansion `json:"volumeExpansion,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"componentName"`

	// restart the specified components.
	// +optional
	// +patchMergeKey=componentName
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=componentName
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.restart"
	RestartList []ComponentOps `json:"restart,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"componentName"`

	// switchover the specified components.
	// +optional
	// +patchMergeKey=componentName
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=componentName
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.switchover"
	SwitchoverList []Switchover `json:"switchover,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"componentName"`

	// verticalScaling defines what component need to vertical scale the specified compute resources.
	// +optional
	// +patchMergeKey=componentName
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=componentName
	VerticalScalingList []VerticalScaling `json:"verticalScaling,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"componentName"`

	// reconfigure defines the variables that need to input when updating configuration.
	// +optional
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.reconfigure"
	// +kubebuilder:validation:XValidation:rule="self.configurations.size() > 0", message="Value can not be empty"
	Reconfigure *Reconfigure `json:"reconfigure,omitempty"`

	// expose defines services the component needs to expose.
	// +optional
	// +patchMergeKey=componentName
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=componentName
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.expose"
	ExposeList []Expose `json:"expose,omitempty" patchStrategy:"merge,retainKeys" patchMergeKey:"componentName"`

	// cluster RestoreFrom backup or point in time
	// +optional
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.restoreFrom"
	RestoreFrom *RestoreFromSpec `json:"restoreFrom,omitempty"`

	// ttlSecondsBeforeAbort OpsRequest will wait at most TTLSecondsBeforeAbort seconds for start-conditions to be met.
	// If not specified, the default value is 0, which means that the start-conditions must be met immediately.
	// +kubebuilder:default=0
	// +optional
	TTLSecondsBeforeAbort *int32 `json:"ttlSecondsBeforeAbort,omitempty"`

	// scriptSpec defines the script to be executed.
	// +optional
	ScriptSpec *ScriptSpec `json:"scriptSpec,omitempty"`

	// backupSpec defines how to backup the cluster.
	// +optional
	BackupSpec *BackupSpec `json:"backupSpec,omitempty"`
}

OpsRequestSpec defines the desired state of OpsRequest +kubebuilder:validation:XValidation:rule="has(self.cancel) && self.cancel ? (self.type in ['VerticalScaling', 'HorizontalScaling']) : true",message="forbidden to cancel the opsRequest which type not in ['VerticalScaling','HorizontalScaling']"

func (OpsRequestSpec) GetDataScriptComponentNameSet added in v0.6.0

func (r OpsRequestSpec) GetDataScriptComponentNameSet() ComponentNameSet

GetDataScriptComponentNameSet gets the component name map with switchover operation.

func (OpsRequestSpec) GetExposeComponentNameSet

func (r OpsRequestSpec) GetExposeComponentNameSet() ComponentNameSet

func (OpsRequestSpec) GetHorizontalScalingComponentNameSet

func (r OpsRequestSpec) GetHorizontalScalingComponentNameSet() ComponentNameSet

GetHorizontalScalingComponentNameSet gets the component name map with horizontal scaling operation.

func (OpsRequestSpec) GetReconfiguringComponentNameSet

func (r OpsRequestSpec) GetReconfiguringComponentNameSet() ComponentNameSet

GetReconfiguringComponentNameSet gets the component name map with reconfiguring operation.

func (OpsRequestSpec) GetRestartComponentNameSet

func (r OpsRequestSpec) GetRestartComponentNameSet() ComponentNameSet

GetRestartComponentNameSet gets the component name map with restart operation.

func (OpsRequestSpec) GetSwitchoverComponentNameSet added in v0.6.0

func (r OpsRequestSpec) GetSwitchoverComponentNameSet() ComponentNameSet

GetSwitchoverComponentNameSet gets the component name map with switchover operation.

func (OpsRequestSpec) GetVerticalScalingComponentNameSet

func (r OpsRequestSpec) GetVerticalScalingComponentNameSet() ComponentNameSet

GetVerticalScalingComponentNameSet gets the component name map with vertical scaling operation.

func (OpsRequestSpec) GetVolumeExpansionComponentNameSet

func (r OpsRequestSpec) GetVolumeExpansionComponentNameSet() ComponentNameSet

GetVolumeExpansionComponentNameSet gets the component name map with volume expansion operation.

func (OpsRequestSpec) ToExposeListToMap

func (r OpsRequestSpec) ToExposeListToMap() map[string]Expose

ToExposeListToMap build expose map

func (OpsRequestSpec) ToHorizontalScalingListToMap

func (r OpsRequestSpec) ToHorizontalScalingListToMap() map[string]HorizontalScaling

ToHorizontalScalingListToMap converts OpsRequest.spec.horizontalScaling list to map

func (OpsRequestSpec) ToVerticalScalingListToMap

func (r OpsRequestSpec) ToVerticalScalingListToMap() map[string]VerticalScaling

ToVerticalScalingListToMap converts OpsRequest.spec.verticalScaling list to map

func (OpsRequestSpec) ToVolumeExpansionListToMap

func (r OpsRequestSpec) ToVolumeExpansionListToMap() map[string]VolumeExpansion

ToVolumeExpansionListToMap converts volumeExpansionList to map

type OpsRequestStatus

type OpsRequestStatus struct {

	// ClusterGeneration records the cluster generation after handling the opsRequest action.
	// +optional
	ClusterGeneration int64 `json:"clusterGeneration,omitempty"`

	// phase describes OpsRequest phase.
	Phase OpsPhase `json:"phase,omitempty"`

	// +kubebuilder:validation:Pattern:=`^(\d+|\-)/(\d+|\-)$`
	// +kubebuilder:default=-/-
	Progress string `json:"progress"`

	// lastConfiguration records the last configuration before this operation take effected.
	// +optional
	LastConfiguration LastConfiguration `json:"lastConfiguration,omitempty"`

	// components defines the recorded the status information of changed components for operation request.
	// +optional
	Components map[string]OpsRequestComponentStatus `json:"components,omitempty"`

	// startTimestamp The time when the OpsRequest started processing.
	// +optional
	StartTimestamp metav1.Time `json:"startTimestamp,omitempty"`

	// completionTimestamp defines the OpsRequest completion time.
	// +optional
	CompletionTimestamp metav1.Time `json:"completionTimestamp,omitempty"`

	// CancelTimestamp defines cancel time.
	// +optional
	CancelTimestamp metav1.Time `json:"cancelTimestamp,omitempty"`

	// reconfiguringStatus defines the status information of reconfiguring.
	// +optional
	ReconfiguringStatus *ReconfiguringStatus `json:"reconfiguringStatus,omitempty"`

	// conditions describes opsRequest detail status.
	// +optional
	// +patchMergeKey=type
	// +patchStrategy=merge
	// +listType=map
	// +listMapKey=type
	Conditions []metav1.Condition `json:"conditions,omitempty"`
}

OpsRequestStatus defines the observed state of OpsRequest

type OpsRequestVolumeClaimTemplate

type OpsRequestVolumeClaimTemplate struct {
	// Request storage size.
	// +kubebuilder:validation:Required
	Storage resource.Quantity `json:"storage"`

	// name references volumeClaimTemplate name from cluster components.
	// +kubebuilder:validation:Required
	Name string `json:"name"`
}

type OpsType

type OpsType string

OpsType defines operation types. +enum +kubebuilder:validation:Enum={Upgrade,VerticalScaling,VolumeExpansion,HorizontalScaling,Restart,Reconfiguring,Start,Stop,Expose,Switchover,DataScript,Backup}

const (
	VerticalScalingType   OpsType = "VerticalScaling"
	HorizontalScalingType OpsType = "HorizontalScaling"
	VolumeExpansionType   OpsType = "VolumeExpansion"
	UpgradeType           OpsType = "Upgrade"
	ReconfiguringType     OpsType = "Reconfiguring"
	SwitchoverType        OpsType = "Switchover"
	RestartType           OpsType = "Restart" // RestartType the restart operation is a special case of the rolling update operation.
	StopType              OpsType = "Stop"    // StopType the stop operation will delete all pods in a cluster concurrently.
	StartType             OpsType = "Start"   // StartType the start operation will start the pods which is deleted in stop operation.
	ExposeType            OpsType = "Expose"
	DataScriptType        OpsType = "DataScript" // DataScriptType the data script operation will execute the data script against the cluster.
	BackupType            OpsType = "Backup"
)

type ParameterConfig

type ParameterConfig struct {
	// key indicates the key name of ConfigMap.
	// +kubebuilder:validation:Required
	Key string `json:"key"`

	// Setting the list of parameters for a single configuration file.
	// update specified the parameters.
	// +optional
	Parameters []ParameterPair `json:"parameters,omitempty"`

	// fileContent indicates the configuration file content.
	// update whole file.
	// +optional
	FileContent string `json:"fileContent,omitempty"`
}

type ParameterPair

type ParameterPair struct {
	// key is name of the parameter to be updated.
	// +kubebuilder:validation:Required
	Key string `json:"key"`

	// parameter values to be updated.
	// if set nil, the parameter defined by the key field will be deleted from the configuration file.
	// +optional
	Value *string `json:"value"`
}

type PasswordConfig

type PasswordConfig struct {
	// length defines the length of password.
	// +kubebuilder:validation:Maximum=32
	// +kubebuilder:validation:Minimum=8
	// +kubebuilder:default=10
	// +optional
	Length int32 `json:"length,omitempty"`
	//  numDigits defines number of digits.
	// +kubebuilder:validation:Maximum=20
	// +kubebuilder:validation:Minimum=0
	// +kubebuilder:default=2
	// +optional
	NumDigits int32 `json:"numDigits,omitempty"`
	// numSymbols defines number of symbols.
	// +kubebuilder:validation:Maximum=20
	// +kubebuilder:validation:Minimum=0
	// +kubebuilder:default=0
	// +optional
	NumSymbols int32 `json:"numSymbols,omitempty"`
	// letterCase defines to use lower-cases, upper-cases or mixed-cases of letters.
	// +kubebuilder:default=MixedCases
	// +optional
	LetterCase LetterCase `json:"letterCase,omitempty"`
}

PasswordConfig helps provide to customize complexity of password generation pattern.

type PersistentVolumeClaimSpec

type PersistentVolumeClaimSpec struct {
	// accessModes contains the desired access modes the volume should have.
	// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1.
	// +kubebuilder:pruning:PreserveUnknownFields
	// +optional
	AccessModes []corev1.PersistentVolumeAccessMode `json:"accessModes,omitempty" protobuf:"bytes,1,rep,name=accessModes,casttype=PersistentVolumeAccessMode"`
	// resources represents the minimum resources the volume should have.
	// If RecoverVolumeExpansionFailure feature is enabled users are allowed to specify resource requirements
	// that are lower than previous value but must still be higher than capacity recorded in the
	// status field of the claim.
	// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources.
	// +kubebuilder:pruning:PreserveUnknownFields
	// +optional
	Resources corev1.ResourceRequirements `json:"resources,omitempty" protobuf:"bytes,2,opt,name=resources"`
	// storageClassName is the name of the StorageClass required by the claim.
	// More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1.
	// +optional
	StorageClassName *string `json:"storageClassName,omitempty" protobuf:"bytes,5,opt,name=storageClassName"`
	// volumeMode defines what type of volume is required by the claim.
	// +optional
	VolumeMode *corev1.PersistentVolumeMode `json:"volumeMode,omitempty" protobuf:"bytes,6,opt,name=volumeMode,casttype=PersistentVolumeMode"`
}

func (*PersistentVolumeClaimSpec) ToV1PersistentVolumeClaimSpec

func (r *PersistentVolumeClaimSpec) ToV1PersistentVolumeClaimSpec() corev1.PersistentVolumeClaimSpec

ToV1PersistentVolumeClaimSpec converts to corev1.PersistentVolumeClaimSpec.

type Phase

type Phase string

Phase defines the ClusterDefinition and ClusterVersion CR .status.phase +enum +kubebuilder:validation:Enum={Available,Unavailable}

const (
	AvailablePhase   Phase = "Available"
	UnavailablePhase Phase = "Unavailable"
)

type PodAntiAffinity

type PodAntiAffinity string

PodAntiAffinity defines pod anti-affinity strategy. +enum +kubebuilder:validation:Enum={Preferred,Required}

const (
	Preferred PodAntiAffinity = "Preferred"
	Required  PodAntiAffinity = "Required"
)

type PointInTimeRefSpec

type PointInTimeRefSpec struct {
	// specify the time point to restore, with UTC as the time zone.
	// +optional
	Time *metav1.Time `json:"time,omitempty"`

	// specify a reference source cluster to restore
	// +optional
	Ref RefNamespaceName `json:"ref,omitempty"`
}

type ProgressStatus

type ProgressStatus string

ProgressStatus defines the status of the opsRequest progress. +enum +kubebuilder:validation:Enum={Processing,Pending,Failed,Succeed}

const (
	PendingProgressStatus    ProgressStatus = "Pending"
	ProcessingProgressStatus ProgressStatus = "Processing"
	FailedProgressStatus     ProgressStatus = "Failed"
	SucceedProgressStatus    ProgressStatus = "Succeed"
)

type ProgressStatusDetail

type ProgressStatusDetail struct {
	// group describes which group the current object belongs to.
	// if the objects of a component belong to the same group, we can ignore it.
	// +optional
	Group string `json:"group,omitempty"`

	// objectKey is the unique key of the object.
	// +kubebuilder:validation:Required
	ObjectKey string `json:"objectKey"`

	// status describes the state of processing the object.
	// +kubebuilder:validation:Required
	Status ProgressStatus `json:"status"`

	// message is a human readable message indicating details about the object condition.
	// +optional
	Message string `json:"message,omitempty"`

	// startTime is the start time of object processing.
	// +optional
	StartTime metav1.Time `json:"startTime,omitempty"`

	// endTime is the completion time of object processing.
	// +optional
	EndTime metav1.Time `json:"endTime,omitempty"`
}

func (*ProgressStatusDetail) SetStatusAndMessage

func (p *ProgressStatusDetail) SetStatusAndMessage(status ProgressStatus, message string)

type ProtectedVolume added in v0.6.0

type ProtectedVolume struct {
	// Name of volume to protect.
	// +optional
	Name string `json:"name,omitempty"`

	// Volume specified high watermark threshold, it will override the component level threshold.
	// If the value is invalid, it will be ignored and the component level threshold will be used.
	// +kubebuilder:validation:Maximum=100
	// +kubebuilder:validation:Minimum=0
	// +optional
	HighWatermark *int `json:"highWatermark,omitempty"`
}

type ProvisionPolicy

type ProvisionPolicy struct {
	// type defines the way to provision an account, either `CreateByStmt` or `ReferToExisting`.
	// +kubebuilder:validation:Required
	Type ProvisionPolicyType `json:"type"`
	// scope is the scope to provision account, and the scope could be `AnyPods` or `AllPods`.
	// +kubebuilder:default=AnyPods
	Scope ProvisionScope `json:"scope"`
	// statements will be used when Type is CreateByStmt.
	// +optional
	Statements *ProvisionStatements `json:"statements,omitempty"`
	// secretRef will be used when Type is ReferToExisting.
	// +optional
	SecretRef *ProvisionSecretRef `json:"secretRef,omitempty"`
}

ProvisionPolicy defines the policy details for creating accounts.

type ProvisionPolicyType

type ProvisionPolicyType string

ProvisionPolicyType defines the policy for creating accounts. +enum

const (
	// CreateByStmt will create account w.r.t. deletion and creation statement given by provider.
	CreateByStmt ProvisionPolicyType = "CreateByStmt"
	// ReferToExisting will not create account, but create a secret by copying data from referred secret file.
	ReferToExisting ProvisionPolicyType = "ReferToExisting"
)

type ProvisionScope

type ProvisionScope string

ProvisionScope defines the scope (within component) of provision. +enum

const (
	// AllPods will create accounts for all pods belong to the component.
	AllPods ProvisionScope = "AllPods"
	// AndyPods will only create accounts on one pod.
	AnyPods ProvisionScope = "AnyPods"
)

type ProvisionSecretRef

type ProvisionSecretRef struct {
	// name refers to the name of the secret.
	// +kubebuilder:validation:Required
	Name string `json:"name"`
	// namespace refers to the namespace of the secret.
	// +kubebuilder:validation:Required
	Namespace string `json:"namespace"`
}

ProvisionSecretRef defines the information of secret referred to.

type ProvisionStatements

type ProvisionStatements struct {
	// creation specifies statement how to create this account with required privileges.
	// +kubebuilder:validation:Required
	CreationStatement string `json:"creation"`
	// update specifies statement how to update account's password.
	// +optional
	UpdateStatement string `json:"update,omitempty"`
	// deletion specifies statement how to delete this account.
	// Used in combination with `CreateionStatement` to delete the account before create it.
	// For instance, one usually uses `drop user if exists` statement followed by `create user` statement to create an account.
	// Deprecated: this field is deprecated, use `update` instead.
	// +optional
	DeletionStatement string `json:"deletion,omitempty"`
}

ProvisionStatements defines the statements used to create accounts.

type RSMSpec added in v0.7.0

type RSMSpec struct {
	// Roles, a list of roles defined in the system.
	// +optional
	Roles []workloads.ReplicaRole `json:"roles,omitempty"`

	// RoleProbe provides method to probe role.
	// +optional
	RoleProbe *workloads.RoleProbe `json:"roleProbe,omitempty"`

	// MembershipReconfiguration provides actions to do membership dynamic reconfiguration.
	// +optional
	MembershipReconfiguration *workloads.MembershipReconfiguration `json:"membershipReconfiguration,omitempty"`

	// MemberUpdateStrategy, Members(Pods) update strategy.
	// serial: update Members one by one that guarantee minimum component unavailable time.
	// 		Learner -> Follower(with AccessMode=none) -> Follower(with AccessMode=readonly) -> Follower(with AccessMode=readWrite) -> Leader
	// bestEffortParallel: update Members in parallel that guarantee minimum component un-writable time.
	//		Learner, Follower(minority) in parallel -> Follower(majority) -> Leader, keep majority online all the time.
	// parallel: force parallel
	// +kubebuilder:validation:Enum={Serial,BestEffortParallel,Parallel}
	// +optional
	MemberUpdateStrategy *workloads.MemberUpdateStrategy `json:"memberUpdateStrategy,omitempty"`
}

type ReconcileDetail added in v0.7.0

type ReconcileDetail struct {
	// policy is the policy of the latest execution.
	// +optional
	Policy string `json:"policy"`
	// execResult is the result of the latest execution.
	// +optional
	ExecResult string `json:"execResult"`

	// currentRevision is the current revision of configurationItem.
	// +optional
	CurrentRevision string `json:"currentRevision,omitempty"`

	// succeedCount is the number of pods for which configuration changes were successfully executed.
	// +kubebuilder:default=-1
	// +optional
	SucceedCount int32 `json:"succeedCount,omitempty"`

	// expectedCount is the number of pods that need to be executed for configuration changes.
	// +kubebuilder:default=-1
	// +optional
	ExpectedCount int32 `json:"expectedCount,omitempty"`

	// errMessage is the error message when the configuration change execution fails.
	// +optional
	ErrMessage string `json:"errMessage,omitempty"`
}

type Reconfigure

type Reconfigure struct {
	ComponentOps `json:",inline"`

	// configurations defines which components perform the operation.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MinItems=1
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	Configurations []ConfigurationItem `json:"configurations" patchStrategy:"merge,retainKeys" patchMergeKey:"name"`
}

Reconfigure defines the variables that need to input when updating configuration.

type ReconfiguringStatus

type ReconfiguringStatus struct {
	// configurationStatus describes the status of the component reconfiguring.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MinItems=1
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	ConfigurationStatus []ConfigurationItemStatus `json:"configurationStatus"`
}

type RefNamespaceName

type RefNamespaceName struct {
	// specified the name
	// +optional
	Name string `json:"name,omitempty"`

	// specified the namespace
	// +optional
	Namespace string `json:"namespace,omitempty"`
}

type ReloadOptions

type ReloadOptions struct {
	// unixSignalTrigger used to reload by sending a signal.
	// +optional
	UnixSignalTrigger *UnixSignalTrigger `json:"unixSignalTrigger,omitempty"`

	// shellTrigger performs the reload command.
	// +optional
	ShellTrigger *ShellTrigger `json:"shellTrigger,omitempty"`

	// goTplTrigger performs the reload command.
	// +optional
	TPLScriptTrigger *TPLScriptTrigger `json:"tplScriptTrigger"`
}

ReloadOptions defines reload options Only one of its members may be specified.

type ReplicationMemberStatus

type ReplicationMemberStatus struct {
	// Pod name.
	// +kubebuilder:validation:Required
	// +kubebuilder:default=Unknown
	Pod string `json:"pod"`
}

type ReplicationSetSpec added in v0.6.0

type ReplicationSetSpec struct {
	StatefulSetSpec `json:",inline"`
}

func (*ReplicationSetSpec) FinalStsUpdateStrategy added in v0.6.0

func (*ReplicationSetSpec) GetUpdateStrategy added in v0.6.0

func (r *ReplicationSetSpec) GetUpdateStrategy() UpdateStrategy

type ReplicationSetStatus

type ReplicationSetStatus struct {
	// Primary status.
	// +kubebuilder:validation:Required
	Primary ReplicationMemberStatus `json:"primary"`

	// Secondaries status.
	// +optional
	Secondaries []ReplicationMemberStatus `json:"secondaries,omitempty"`
}

type ResourceConstraintRule added in v0.6.0

type ResourceConstraintRule struct {
	// The name of the constraint.
	// +kubebuilder:validation:Required
	Name string `json:"name"`

	// The constraint for vcpu cores.
	// +kubebuilder:validation:Required
	CPU CPUConstraint `json:"cpu"`

	// The constraint for memory size.
	// +kubebuilder:validation:Required
	Memory MemoryConstraint `json:"memory"`

	// The constraint for storage size.
	// +optional
	Storage StorageConstraint `json:"storage"`
}

func (*ResourceConstraintRule) CompleteResources added in v0.6.0

func (*ResourceConstraintRule) GetMinimalResources added in v0.6.0

func (m *ResourceConstraintRule) GetMinimalResources() corev1.ResourceList

GetMinimalResources gets the minimal resources meets the constraint

func (*ResourceConstraintRule) ValidateCPU added in v0.6.0

func (m *ResourceConstraintRule) ValidateCPU(cpu *resource.Quantity) bool

ValidateCPU validates if the CPU meets the constraint

func (*ResourceConstraintRule) ValidateMemory added in v0.6.0

func (m *ResourceConstraintRule) ValidateMemory(cpu *resource.Quantity, memory *resource.Quantity) bool

ValidateMemory validates if the memory meets the constraint

func (*ResourceConstraintRule) ValidateResources added in v0.6.0

func (m *ResourceConstraintRule) ValidateResources(r corev1.ResourceList) bool

ValidateResources validates if the resources meets the constraint

func (*ResourceConstraintRule) ValidateStorage added in v0.6.0

func (m *ResourceConstraintRule) ValidateStorage(storage *resource.Quantity) bool

ValidateStorage validates if the storage meets the constraint

type ResourceMeta added in v0.8.0

type ResourceMeta struct {
	// name is the name of the referenced the Configmap/Secret object.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	Name string `json:"name"`

	// mountPath is the path at which to mount the volume.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=256
	// +kubebuilder:validation:Pattern:=`^/[a-z]([a-z0-9\-]*[a-z0-9])?$`
	MountPoint string `json:"mountPoint"`

	// subPath is a relative file path within the volume to mount.
	// +optional
	SubPath string `json:"subPath,omitempty"`

	// asVolumeFrom defines the list of containers where volumeMounts will be injected into.
	// +listType=set
	// +optional
	AsVolumeFrom []string `json:"asVolumeFrom,omitempty"`
}

type RestoreFromSpec

type RestoreFromSpec struct {
	// use the backup name and component name for restore, support for multiple components' recovery.
	// +optional
	Backup []BackupRefSpec `json:"backup,omitempty"`

	// specified the point in time to recovery
	// +optional
	PointInTime *PointInTimeRefSpec `json:"pointInTime,omitempty"`
}

type SchedulePolicy

type SchedulePolicy struct {
	// enabled specifies whether the backup schedule is enabled or not.
	// +optional
	Enabled *bool `json:"enabled,omitempty"`

	// backupMethod specifies the backup method name that is defined in backupPolicy.
	// +kubebuilder:validation:Required
	BackupMethod string `json:"backupMethod"`

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

type ScriptConfig added in v0.6.0

type ScriptConfig struct {
	// scriptConfigMapRef used to execute for reload.
	// +kubebuilder:validation:Required
	ScriptConfigMapRef string `json:"scriptConfigMapRef"`

	// Specify the namespace of the referenced the tpl script ConfigMap object.
	// An empty namespace is equivalent to the "default" namespace.
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:default="default"
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\-]*[a-z0-9])?$`
	// +optional
	Namespace string `json:"namespace,omitempty"`
}

type ScriptFrom added in v0.6.0

type ScriptFrom struct {
	// configMapRef defines the configMap to be executed.
	// +optional
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.scriptSpec.scriptFrom.configMapRef"
	ConfigMapRef []corev1.ConfigMapKeySelector `json:"configMapRef,omitempty"`
	// secretRef defines the secret to be executed.
	// +optional
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.scriptSpec.scriptFrom.secretRef"
	SecretRef []corev1.SecretKeySelector `json:"secretRef,omitempty"`
}

ScriptFrom defines the script to be executed from configMap or secret.

type ScriptSecret added in v0.6.0

type ScriptSecret struct {
	// name is the name of the secret.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	Name string `json:"name"`
	// usernameKey field is used to specify the username of the secret.
	// +kubebuilder:default:="username"
	// +optional
	UsernameKey string `json:"usernameKey,omitempty"`
	// passwordKey field is used to specify the password of the secret.
	// +kubebuilder:default:="password"
	// +optional
	PasswordKey string `json:"passwordKey,omitempty"`
}

ScriptSecret defines the secret to be used to execute the script.

type ScriptSpec added in v0.6.0

type ScriptSpec struct {
	ComponentOps `json:",inline"`
	// exec command with image, by default use the image of kubeblocks-datascript.
	// +optional
	Image string `json:"image,omitempty"`
	// secret defines the secret to be used to execute the script.
	// If not specified, the default cluster root credential secret will be used.
	// +optional
	Secret *ScriptSecret `json:"secret,omitempty"`
	// script defines the script to be executed.
	// +optional
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.scriptSpec.script"
	Script []string `json:"script,omitempty"`
	// scriptFrom defines the script to be executed from configMap or secret.
	// +optional
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.scriptSpec.scriptFrom"
	ScriptFrom *ScriptFrom `json:"scriptFrom,omitempty"`
	// KubeBlocks, by default, will execute the script on the primary pod, with role=leader.
	// There are some exceptions, such as Redis, which does not synchronize accounts info between primary and secondary.
	// In this case, we need to execute the script on all pods, matching the selector.
	// selector indicates the components on which the script is executed.
	// +optional
	// +kubebuilder:validation:XValidation:rule="self == oldSelf",message="forbidden to update spec.scriptSpec.script.selector"
	Selector *metav1.LabelSelector `json:"selector,omitempty"`
}

ScriptSpec defines the script to be executed. It is not a general purpose script executor. It is designed to execute the script to perform some specific operations, such as create database, create user, etc. It is applicable for engines, such as MySQL, PostgreSQL, Redis, MongoDB, etc.

type ScriptSpecSelector added in v0.6.0

type ScriptSpecSelector struct {
	// ScriptSpec name of the referent, refer to componentDefs[x].scriptSpecs[y].Name.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	Name string `json:"name"`
}

type SecretRef added in v0.8.0

type SecretRef struct {
	ResourceMeta `json:",inline"`

	// secret defines the secret volume source.
	// +kubebuilder:validation:Required
	Secret corev1.SecretVolumeSource `json:"secret"`
}

type ServiceDescriptor added in v0.7.0

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

	Spec   ServiceDescriptorSpec   `json:"spec,omitempty"`
	Status ServiceDescriptorStatus `json:"status,omitempty"`
}

ServiceDescriptor is the Schema for the servicedescriptors API

func (*ServiceDescriptor) Default added in v0.7.0

func (r *ServiceDescriptor) Default()

Default implements webhook.Defaulter so a webhook will be registered for the type

func (*ServiceDescriptor) SetupWebhookWithManager added in v0.7.0

func (r *ServiceDescriptor) SetupWebhookWithManager(mgr ctrl.Manager) error

func (*ServiceDescriptor) ValidateCreate added in v0.7.0

func (r *ServiceDescriptor) ValidateCreate() (admission.Warnings, error)

ValidateCreate implements webhook.Validator so a webhook will be registered for the type

func (*ServiceDescriptor) ValidateDelete added in v0.7.0

func (r *ServiceDescriptor) ValidateDelete() (admission.Warnings, error)

ValidateDelete implements webhook.Validator so a webhook will be registered for the type

func (*ServiceDescriptor) ValidateUpdate added in v0.7.0

func (r *ServiceDescriptor) ValidateUpdate(old runtime.Object) (admission.Warnings, error)

ValidateUpdate implements webhook.Validator so a webhook will be registered for the type

type ServiceDescriptorList added in v0.7.0

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

ServiceDescriptorList contains a list of ServiceDescriptor

type ServiceDescriptorSpec added in v0.7.0

type ServiceDescriptorSpec struct {
	// service kind, indicating the type or nature of the service. It should be well-known application cluster type, e.g. {mysql, redis, mongodb}.
	// The serviceKind is case-insensitive and supports abbreviations for some well-known databases.
	// For example, both 'zk' and 'zookeeper' will be considered as a ZooKeeper cluster, and 'pg', 'postgres', 'postgresql' will all be considered as a PostgreSQL cluster.
	// +kubebuilder:validation:Required
	ServiceKind string `json:"serviceKind"`

	// The version of the service reference.
	// +kubebuilder:validation:Required
	ServiceVersion string `json:"serviceVersion"`

	// endpoint is the endpoint of the service connection credential.
	// +optional
	Endpoint *CredentialVar `json:"endpoint,omitempty"`

	// auth is the auth of the service connection credential.
	// +optional
	Auth *ConnectionCredentialAuth `json:"auth,omitempty"`

	// port is the port of the service connection credential.
	// +optional
	Port *CredentialVar `json:"port,omitempty" protobuf:"bytes,4,opt,name=port"`
}

ServiceDescriptorSpec defines the desired state of ServiceDescriptor

type ServiceDescriptorStatus added in v0.7.0

type ServiceDescriptorStatus struct {
	// phase - in list of [Available,Unavailable]
	// +optional
	Phase Phase `json:"phase,omitempty"`

	// A human-readable message indicating details about why the ServiceConnectionCredential is in this phase.
	// +optional
	Message string `json:"message,omitempty"`

	// generation number
	// +optional
	ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

ServiceDescriptorStatus defines the observed state of ServiceDescriptor

func (ServiceDescriptorStatus) GetTerminalPhases added in v0.7.0

func (r ServiceDescriptorStatus) GetTerminalPhases() []Phase

type ServicePort

type ServicePort struct {
	// The name of this port within the service. This must be a DNS_LABEL.
	// All ports within a ServiceSpec must have unique names. When considering
	// the endpoints for a Service, this must match the 'name' field in the
	// EndpointPort.
	// +kubebuilder:validation:Required
	Name string `json:"name,omitempty" protobuf:"bytes,1,opt,name=name"`

	// The IP protocol for this port. Supports "TCP", "UDP", and "SCTP".
	// Default is TCP.
	// +kubebuilder:validation:Enum={TCP,UDP,SCTP}
	// +default="TCP"
	// +optional
	Protocol corev1.Protocol `json:"protocol,omitempty" protobuf:"bytes,2,opt,name=protocol,casttype=Protocol"`

	// The application protocol for this port.
	// This field follows standard Kubernetes label syntax.
	// Un-prefixed names are reserved for IANA standard service names (as per
	// RFC-6335 and https://www.iana.org/assignments/service-names).
	// Non-standard protocols should use prefixed names such as
	// mycompany.com/my-custom-protocol.
	// +optional
	AppProtocol *string `json:"appProtocol,omitempty" protobuf:"bytes,6,opt,name=appProtocol"`

	// The port that will be exposed by this service.
	Port int32 `json:"port" protobuf:"varint,3,opt,name=port"`

	// Number or name of the port to access on the pods targeted by the service.
	// Number must be in the range 1 to 65535. Name must be an IANA_SVC_NAME.
	// If this is a string, it will be looked up as a named port in the
	// target Pod's container ports. If this is not specified, the value
	// of the 'port' field is used (an identity map).
	// This field is ignored for services with clusterIP=None, and should be
	// omitted or set equal to the 'port' field.
	// More info: https://kubernetes.io/docs/concepts/services-networking/service/#defining-a-service
	// +kubebuilder:validation:XIntOrString
	// +optional
	TargetPort intstr.IntOrString `json:"targetPort,omitempty" protobuf:"bytes,4,opt,name=targetPort"`
}

type ServiceRef added in v0.7.0

type ServiceRef struct {
	// name of the service reference declaration. references the serviceRefDeclaration name defined in clusterDefinition.componentDefs[*].serviceRefDeclarations[*].name
	// +kubebuilder:validation:Required
	Name string `json:"name"`

	// namespace defines the namespace of the referenced Cluster or the namespace of the referenced ServiceDescriptor object.
	// If not set, the referenced Cluster and ServiceDescriptor will be searched in the namespace of the current cluster by default.
	// +optional
	Namespace string `json:"namespace,omitempty" protobuf:"bytes,3,opt,name=namespace"`

	// When referencing a service provided by other KubeBlocks cluster, you need to provide the name of the Cluster being referenced.
	// By default, when other KubeBlocks Cluster are referenced, the ClusterDefinition.spec.connectionCredential secret corresponding to the referenced Cluster will be used to bind to the current component.
	// Currently, if a KubeBlocks cluster is to be referenced, the connection credential secret should include and correspond to the following fields: endpoint, port, username, and password.
	// Under this referencing approach, the ServiceKind and ServiceVersion of service reference declaration defined in the ClusterDefinition will not be validated.
	// If both Cluster and ServiceDescriptor are specified, the Cluster takes precedence.
	// +optional
	Cluster string `json:"cluster,omitempty"`

	// serviceDescriptor defines the service descriptor of the service provided by external sources.
	// When referencing a service provided by external sources, you need to provide the ServiceDescriptor object name to establish the service binding.
	// And serviceDescriptor is the name of the ServiceDescriptor object, furthermore, the ServiceDescriptor.spec.serviceKind and ServiceDescriptor.spec.serviceVersion
	// should match clusterDefinition.componentDefs[*].serviceRefDeclarations[*].serviceRefDeclarationSpecs[*].serviceKind
	// and the regular expression defines in clusterDefinition.componentDefs[*].serviceRefDeclarations[*].serviceRefDeclarationSpecs[*].serviceVersion.
	// If both Cluster and ServiceDescriptor are specified, the Cluster takes precedence.
	// +optional
	ServiceDescriptor string `json:"serviceDescriptor,omitempty"`
}

type ServiceRefDeclaration added in v0.7.0

type ServiceRefDeclaration struct {
	// The name of the service reference declaration.
	// The service reference can come from an external service that is not part of KubeBlocks, or services provided by other KubeBlocks Cluster objects.
	// The specific type of service reference depends on the binding declaration when creates a Cluster.
	// +kubebuilder:validation:Required
	Name string `json:"name"`

	// serviceRefDeclarationSpecs is a collection of service descriptions for a service reference declaration.
	// Each ServiceRefDeclarationSpec defines a service Kind and Version. When multiple ServiceRefDeclarationSpecs are defined,
	// it indicates that the ServiceRefDeclaration can be any one of the specified ServiceRefDeclarationSpecs.
	// For example, when the ServiceRefDeclaration is declared to require an OLTP database, which can be either MySQL or PostgreSQL,
	// you can define a ServiceRefDeclarationSpec for MySQL and another ServiceRefDeclarationSpec for PostgreSQL,
	// when referencing the service within the cluster, as long as the serviceKind and serviceVersion match either MySQL or PostgreSQL, it can be used.
	// +kubebuilder:validation:Required
	ServiceRefDeclarationSpecs []ServiceRefDeclarationSpec `json:"serviceRefDeclarationSpecs"`
}

type ServiceRefDeclarationSpec added in v0.7.0

type ServiceRefDeclarationSpec struct {
	// service kind, indicating the type or nature of the service. It should be well-known application cluster type, e.g. {mysql, redis, mongodb}.
	// The serviceKind is case-insensitive and supports abbreviations for some well-known databases.
	// For example, both 'zk' and 'zookeeper' will be considered as a ZooKeeper cluster, and 'pg', 'postgres', 'postgresql' will all be considered as a PostgreSQL cluster.
	// +kubebuilder:validation:Required
	ServiceKind string `json:"serviceKind"`

	// The service version of the service reference. It is a regular expression that matches a version number pattern.
	// For example, `^8.0.8$`, `8.0.\d{1,2}$`, `^[v\-]*?(\d{1,2}\.){0,3}\d{1,2}$`
	// +kubebuilder:validation:Required
	ServiceVersion string `json:"serviceVersion"`
}

type ServiceSpec

type ServiceSpec struct {
	// The list of ports that are exposed by this service.
	// More info: https://kubernetes.io/docs/concepts/services-networking/service/#virtual-ips-and-service-proxies
	// +patchMergeKey=port
	// +patchStrategy=merge
	// +listType=map
	// +listMapKey=port
	// +listMapKey=protocol
	// +optional
	Ports []ServicePort `json:"ports,omitempty" patchStrategy:"merge" patchMergeKey:"port" protobuf:"bytes,1,rep,name=ports"`
}

func (ServiceSpec) ToSVCSpec

func (r ServiceSpec) ToSVCSpec() corev1.ServiceSpec

type ShellTrigger

type ShellTrigger struct {
	// command used to execute for reload.
	// +kubebuilder:validation:Required
	Command []string `json:"command"`

	// Specify synchronize updates parameters to the config manager.
	// +optional
	Sync *bool `json:"sync,omitempty"`
}

type SignalType

type SignalType string

SignalType defines which signals are valid. +enum +kubebuilder:validation:Enum={SIGHUP,SIGINT,SIGQUIT,SIGILL,SIGTRAP,SIGABRT,SIGBUS,SIGFPE,SIGKILL,SIGUSR1,SIGSEGV,SIGUSR2,SIGPIPE,SIGALRM,SIGTERM,SIGSTKFLT,SIGCHLD,SIGCONT,SIGSTOP,SIGTSTP,SIGTTIN,SIGTTOU,SIGURG,SIGXCPU,SIGXFSZ,SIGVTALRM,SIGPROF,SIGWINCH,SIGIO,SIGPWR,SIGSYS}

const (
	SIGHUP    SignalType = "SIGHUP"
	SIGINT    SignalType = "SIGINT"
	SIGQUIT   SignalType = "SIGQUIT"
	SIGILL    SignalType = "SIGILL"
	SIGTRAP   SignalType = "SIGTRAP"
	SIGABRT   SignalType = "SIGABRT"
	SIGBUS    SignalType = "SIGBUS"
	SIGFPE    SignalType = "SIGFPE"
	SIGKILL   SignalType = "SIGKILL"
	SIGUSR1   SignalType = "SIGUSR1"
	SIGSEGV   SignalType = "SIGSEGV"
	SIGUSR2   SignalType = "SIGUSR2"
	SIGPIPE   SignalType = "SIGPIPE"
	SIGALRM   SignalType = "SIGALRM"
	SIGTERM   SignalType = "SIGTERM"
	SIGSTKFLT SignalType = "SIGSTKFLT"
	SIGCHLD   SignalType = "SIGCHLD"
	SIGCONT   SignalType = "SIGCONT"
	SIGSTOP   SignalType = "SIGSTOP"
	SIGTSTP   SignalType = "SIGTSTP"
	SIGTTIN   SignalType = "SIGTTIN"
	SIGTTOU   SignalType = "SIGTTOU"
	SIGURG    SignalType = "SIGURG"
	SIGXCPU   SignalType = "SIGXCPU"
	SIGXFSZ   SignalType = "SIGXFSZ"
	SIGVTALRM SignalType = "SIGVTALRM"
	SIGPROF   SignalType = "SIGPROF"
	SIGWINCH  SignalType = "SIGWINCH"
	SIGIO     SignalType = "SIGIO"
	SIGPWR    SignalType = "SIGPWR"
	SIGSYS    SignalType = "SIGSYS"
)

type StatefulSetSpec added in v0.6.0

type StatefulSetSpec struct {
	// updateStrategy, Pods update strategy.
	// In case of workloadType=Consensus the update strategy will be following:
	//
	// serial: update Pods one by one that guarantee minimum component unavailable time.
	// 		Learner -> Follower(with AccessMode=none) -> Follower(with AccessMode=readonly) -> Follower(with AccessMode=readWrite) -> Leader
	// bestEffortParallel: update Pods in parallel that guarantee minimum component un-writable time.
	//		Learner, Follower(minority) in parallel -> Follower(majority) -> Leader, keep majority online all the time.
	// parallel: force parallel
	// +kubebuilder:default=Serial
	// +optional
	UpdateStrategy UpdateStrategy `json:"updateStrategy,omitempty"`

	// llPodManagementPolicy is the low-level controls how pods are created during initial scale up,
	// when replacing pods on nodes, or when scaling down.
	// `OrderedReady` policy specify where pods are created in increasing order (pod-0, then
	// pod-1, etc) and the controller will wait until each pod is ready before
	// continuing. When scaling down, the pods are removed in the opposite order.
	// `Parallel` policy specify create pods in parallel
	// to match the desired scale without waiting, and on scale down will delete
	// all pods at once.
	// +optional
	LLPodManagementPolicy appsv1.PodManagementPolicyType `json:"llPodManagementPolicy,omitempty"`

	// llUpdateStrategy indicates the low-level StatefulSetUpdateStrategy that will be
	// employed to update Pods in the StatefulSet when a revision is made to
	// Template. Will ignore `updateStrategy` attribute if provided.
	// +optional
	LLUpdateStrategy *appsv1.StatefulSetUpdateStrategy `json:"llUpdateStrategy,omitempty"`
}

func (*StatefulSetSpec) FinalStsUpdateStrategy added in v0.6.0

func (*StatefulSetSpec) GetUpdateStrategy added in v0.6.0

func (r *StatefulSetSpec) GetUpdateStrategy() UpdateStrategy

type StatefulSetWorkload added in v0.6.0

type StatefulSetWorkload interface {
	FinalStsUpdateStrategy() (appsv1.PodManagementPolicyType, appsv1.StatefulSetUpdateStrategy)
	GetUpdateStrategy() UpdateStrategy
}

StatefulSetWorkload interface +kubebuilder:object:generate=false

type StatelessSetSpec added in v0.6.0

type StatelessSetSpec struct {
	// updateStrategy defines the underlying deployment strategy to use to replace existing pods with new ones.
	// +optional
	// +patchStrategy=retainKeys
	UpdateStrategy appsv1.DeploymentStrategy `json:"updateStrategy,omitempty"`
}

type StorageConstraint added in v0.6.0

type StorageConstraint struct {
	// The minimum size of storage.
	// +kubebuilder:default="20Gi"
	// +optional
	Min *resource.Quantity `json:"min,omitempty"`

	// The maximum size of storage.
	// +kubebuilder:default="10Ti"
	// +optional
	Max *resource.Quantity `json:"max,omitempty"`
}

type SwitchPolicyType

type SwitchPolicyType string

SwitchPolicyType defines switchPolicy type. Currently, only Noop is supported. MaximumAvailability and MaximumDataProtection will be supported in the future. +enum +kubebuilder:validation:Enum={Noop}

const (
	MaximumAvailability   SwitchPolicyType = "MaximumAvailability"
	MaximumDataProtection SwitchPolicyType = "MaximumDataProtection"
	Noop                  SwitchPolicyType = "Noop"
)

type SwitchStepRole

type SwitchStepRole string

SwitchStepRole defines the role to execute the switch command. +enum +kubebuilder:validation:Enum={NewPrimary, OldPrimary, Secondaries}

const (
	NewPrimary  SwitchStepRole = "NewPrimary"
	OldPrimary  SwitchStepRole = "OldPrimary"
	Secondaries SwitchStepRole = "Secondaries"
)

type Switchover added in v0.6.0

type Switchover struct {
	ComponentOps `json:",inline"`

	// instanceName is used to specify the candidate primary or leader instanceName for switchover.
	// If instanceName is set to "*", it means that no specific primary or leader is specified for the switchover,
	// and the switchoverAction defined in clusterDefinition.componentDefs[x].switchoverSpec.withoutCandidate will be executed,
	// It is required that clusterDefinition.componentDefs[x].switchoverSpec.withoutCandidate is not empty.
	// If instanceName is set to a valid instanceName other than "*", it means that a specific candidate primary or leader is specified for the switchover.
	// the value of instanceName can be obtained using `kbcli cluster list-instances`, any other value is invalid.
	// In this case, the `switchoverAction` defined in clusterDefinition.componentDefs[x].switchoverSpec.withCandidate will be executed,
	// and it is required that clusterDefinition.componentDefs[x].switchoverSpec.withCandidate is not empty.
	// +kubebuilder:validation:Required
	InstanceName string `json:"instanceName"`
}

type SwitchoverAction added in v0.6.0

type SwitchoverAction struct {
	// cmdExecutorConfig is the executor configuration of the switchover command.
	// +kubebuilder:validation:Required
	CmdExecutorConfig *CmdExecutorConfig `json:"cmdExecutorConfig"`

	// scriptSpecSelectors defines the selector of the scriptSpecs that need to be referenced.
	// Once ScriptSpecSelectors is defined, the scripts defined in scriptSpecs can be referenced in the SwitchoverAction.CmdExecutorConfig.
	// +optional
	ScriptSpecSelectors []ScriptSpecSelector `json:"scriptSpecSelectors,omitempty"`
}

type SwitchoverShortSpec added in v0.6.0

type SwitchoverShortSpec struct {
	// CmdExecutorConfig is the command executor config.
	// +kubebuilder:validation:Required
	CmdExecutorConfig *CommandExecutorEnvItem `json:"cmdExecutorConfig"`
}

SwitchoverShortSpec is a short version of SwitchoverSpec, with only CommandExecutorEnvItem field.

type SwitchoverSpec added in v0.6.0

type SwitchoverSpec struct {
	// withCandidate corresponds to the switchover of the specified candidate primary or leader instance.
	// +optional
	WithCandidate *SwitchoverAction `json:"withCandidate,omitempty"`

	// withoutCandidate corresponds to a switchover that does not specify a candidate primary or leader instance.
	// +optional
	WithoutCandidate *SwitchoverAction `json:"withoutCandidate,omitempty"`
}

type SystemAccountConfig

type SystemAccountConfig struct {
	// name is the name of a system account.
	// +kubebuilder:validation:Required
	Name AccountName `json:"name"`
	// provisionPolicy defines how to create account.
	// +kubebuilder:validation:Required
	ProvisionPolicy ProvisionPolicy `json:"provisionPolicy"`
}

SystemAccountConfig specifies how to create and delete system accounts.

type SystemAccountShortSpec added in v0.6.0

type SystemAccountShortSpec struct {
	// cmdExecutorConfig configs how to get client SDK and perform statements.
	// +kubebuilder:validation:Required
	CmdExecutorConfig *CommandExecutorEnvItem `json:"cmdExecutorConfig"`
}

SystemAccountShortSpec is a short version of SystemAccountSpec, with only CmdExecutorConfig field.

type SystemAccountSpec

type SystemAccountSpec struct {
	// cmdExecutorConfig configs how to get client SDK and perform statements.
	// +kubebuilder:validation:Required
	CmdExecutorConfig *CmdExecutorConfig `json:"cmdExecutorConfig"`
	// passwordConfig defines the pattern to generate password.
	// +kubebuilder:validation:Required
	PasswordConfig PasswordConfig `json:"passwordConfig"`
	// accounts defines system account config settings.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MinItems=1
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	Accounts []SystemAccountConfig `json:"accounts" patchStrategy:"merge,retainKeys" patchMergeKey:"name"`
}

SystemAccountSpec specifies information to create system accounts.

type TLSSecretRef

type TLSSecretRef struct {
	// Name of the Secret
	// +kubebuilder:validation:Required
	Name string `json:"name"`

	// CA cert key in Secret
	// +kubebuilder:validation:Required
	CA string `json:"ca"`

	// Cert key in Secret
	// +kubebuilder:validation:Required
	Cert string `json:"cert"`

	// Key of TLS private key in Secret
	// +kubebuilder:validation:Required
	Key string `json:"key"`
}

TLSSecretRef defines Secret contains Tls certs

type TPLScriptTrigger

type TPLScriptTrigger struct {
	ScriptConfig `json:",inline"`

	// Specify synchronize updates parameters to the config manager.
	// +optional
	Sync *bool `json:"sync,omitempty"`
}

type TargetInstance

type TargetInstance struct {
	// select instance of corresponding role for backup, role are:
	// - the name of Leader/Follower/Leaner for Consensus component.
	// - primary or secondary for Replication component.
	// finally, invalid role of the component will be ignored.
	// such as if workload type is Replication and component's replicas is 1,
	// the secondary role is invalid. and it also will be ignored when component is Stateful/Stateless.
	// the role will be transformed to a role LabelSelector for BackupPolicy's target attribute.
	// +optional
	Role string `json:"role"`

	// refer to spec.componentDef.systemAccounts.accounts[*].name in ClusterDefinition.
	// the secret created by this account will be used to connect the database.
	// if not set, the secret created by spec.ConnectionCredential of the ClusterDefinition will be used.
	// it will be transformed to a secret for BackupPolicy's target secret.
	// +optional
	Account string `json:"account,omitempty"`

	// connectionCredentialKey defines connection credential key in secret
	// which created by spec.ConnectionCredential of the ClusterDefinition.
	// it will be ignored when "account" is set.
	ConnectionCredentialKey ConnectionCredentialKey `json:"connectionCredentialKey,omitempty"`
}

type TenancyType

type TenancyType string

TenancyType for cluster tenant resources. +enum +kubebuilder:validation:Enum={SharedNode,DedicatedNode}

const (
	SharedNode    TenancyType = "SharedNode"
	DedicatedNode TenancyType = "DedicatedNode"
)

type TerminationPolicyType

type TerminationPolicyType string

TerminationPolicyType defines termination policy types. +enum +kubebuilder:validation:Enum={DoNotTerminate,Halt,Delete,WipeOut}

const (
	DoNotTerminate TerminationPolicyType = "DoNotTerminate"
	Halt           TerminationPolicyType = "Halt"
	Delete         TerminationPolicyType = "Delete"
	WipeOut        TerminationPolicyType = "WipeOut"
)

type ToolConfig added in v0.6.0

type ToolConfig struct {
	// Specify the name of initContainer. Must be a DNS_LABEL name.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=63
	// +kubebuilder:validation:Pattern:=`^[a-z]([a-z0-9\-]*[a-z0-9])?$`
	Name string `json:"name,omitempty"`

	// tools Container image name.
	// +optional
	Image string `json:"image,omitempty"`

	// exec used to execute for init containers.
	// +kubebuilder:validation:Required
	Command []string `json:"command"`
}

type ToolsImageSpec added in v0.6.0

type ToolsImageSpec struct {

	// mountPoint is the mount point of the scripts file.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:MaxLength=128
	MountPoint string `json:"mountPoint"`

	// toolConfig used to config init container.
	// +optional
	ToolConfigs []ToolConfig `json:"toolConfigs,omitempty"`
}

type UnixSignalTrigger

type UnixSignalTrigger struct {
	// signal is valid for unix signal.
	// e.g: SIGHUP
	// url: ../../pkg/configuration/configmap/handler.go:allUnixSignals
	// +kubebuilder:validation:Required
	Signal SignalType `json:"signal"`

	// processName is process name, sends unix signal to proc.
	// +kubebuilder:validation:Required
	ProcessName string `json:"processName"`
}

type UpdateStrategy

type UpdateStrategy string

UpdateStrategy defines Cluster Component update strategy. +enum +kubebuilder:validation:Enum={Serial,BestEffortParallel,Parallel}

const (
	SerialStrategy             UpdateStrategy = "Serial"
	BestEffortParallelStrategy UpdateStrategy = "BestEffortParallel"
	ParallelStrategy           UpdateStrategy = "Parallel"
)

type UpdatedParameters

type UpdatedParameters struct {
	// addedKeys describes the key added.
	// +optional
	AddedKeys map[string]string `json:"addedKeys,omitempty"`

	// deletedKeys describes the key deleted.
	// +optional
	DeletedKeys map[string]string `json:"deletedKeys,omitempty"`

	// updatedKeys describes the key updated.
	// +optional
	UpdatedKeys map[string]string `json:"updatedKeys,omitempty"`
}

type Upgrade

type Upgrade struct {
	// clusterVersionRef references ClusterVersion name.
	// +kubebuilder:validation:Required
	ClusterVersionRef string `json:"clusterVersionRef"`
}

Upgrade defines the variables of upgrade operation.

type UpgradePolicy

type UpgradePolicy string

UpgradePolicy defines the policy of reconfiguring. +enum +kubebuilder:validation:Enum={simple,parallel,rolling,autoReload,operatorSyncUpdate}

const (
	NonePolicy         UpgradePolicy = "none"
	NormalPolicy       UpgradePolicy = "simple"
	RestartPolicy      UpgradePolicy = "parallel"
	RollingPolicy      UpgradePolicy = "rolling"
	AutoReload         UpgradePolicy = "autoReload"
	OperatorSyncUpdate UpgradePolicy = "operatorSyncUpdate"
)

type UserResourceRefs added in v0.8.0

type UserResourceRefs struct {
	// secretRefs defines the user-defined secrets.
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	// +optional
	SecretRefs []SecretRef `json:"secretRefs,omitempty"`

	// configMapRefs defines the user-defined configmaps.
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	// +optional
	ConfigMapRefs []ConfigMapRef `json:"configMapRefs,omitempty"`
}

type ValueFrom added in v0.7.0

type ValueFrom struct {
	// mapped ClusterVersionRef to env value.
	// +kubebuilder:validation:Required
	ClusterVersionRef []ClusterVersionMapping `json:"clusterVersionRef"`
}

type VersionsContext

type VersionsContext struct {
	// Provide ClusterDefinition.spec.componentDefs.podSpec.initContainers override
	// values, typical scenarios are application container image updates.
	// +kubebuilder:pruning:PreserveUnknownFields
	// +patchMergeKey=name
	// +patchStrategy=merge
	// +listType=map
	// +listMapKey=name
	// +optional
	InitContainers []corev1.Container `json:"initContainers,omitempty"`

	// Provide ClusterDefinition.spec.componentDefs.podSpec.containers override
	// values, typical scenarios are application container image updates.
	// +kubebuilder:pruning:PreserveUnknownFields
	// +patchMergeKey=name
	// +patchStrategy=merge
	// +listType=map
	// +listMapKey=name
	// +optional
	Containers []corev1.Container `json:"containers,omitempty"`
}

type VerticalScaling

type VerticalScaling struct {
	ComponentOps `json:",inline"`

	// resources specifies the computing resource size of verticalScaling.
	// +kubebuilder:pruning:PreserveUnknownFields
	corev1.ResourceRequirements `json:",inline"`

	// classDefRef reference class defined in ComponentClassDefinition.
	// +optional
	ClassDefRef *ClassDefRef `json:"classDefRef,omitempty"`
}

VerticalScaling defines the variables that need to input when scaling compute resources.

type VolumeExpansion

type VolumeExpansion struct {
	ComponentOps `json:",inline"`

	// volumeClaimTemplates specifies the storage size and volumeClaimTemplate name.
	// +kubebuilder:validation:Required
	// +patchMergeKey=name
	// +patchStrategy=merge,retainKeys
	// +listType=map
	// +listMapKey=name
	VolumeClaimTemplates []OpsRequestVolumeClaimTemplate `json:"volumeClaimTemplates" patchStrategy:"merge,retainKeys" patchMergeKey:"name"`
}

VolumeExpansion defines the variables of volume expansion operation.

type VolumeProtectionSpec added in v0.6.0

type VolumeProtectionSpec struct {
	// The high watermark threshold for volume space usage.
	// If there is any specified volumes who's space usage is over the threshold, the pre-defined "LOCK" action
	// will be triggered to degrade the service to protect volume from space exhaustion, such as to set the instance
	// as read-only. And after that, if all volumes' space usage drops under the threshold later, the pre-defined
	// "UNLOCK" action will be performed to recover the service normally.
	// +kubebuilder:validation:Maximum=100
	// +kubebuilder:validation:Minimum=0
	// +kubebuilder:default=90
	// +optional
	HighWatermark int `json:"highWatermark,omitempty"`

	// Volumes to protect.
	// +optional
	Volumes []ProtectedVolume `json:"volumes,omitempty"`
}

type VolumeType

type VolumeType string

VolumeType defines volume type for backup data or log. +enum +kubebuilder:validation:Enum={data,log}

const (
	VolumeTypeData VolumeType = "data"
	VolumeTypeLog  VolumeType = "log"
)

type VolumeTypeSpec

type VolumeTypeSpec struct {
	// name definition is the same as the name of the VolumeMounts field in PodSpec.Container,
	// similar to the relations of Volumes[*].name and VolumesMounts[*].name in Pod.Spec.
	// +kubebuilder:validation:Required
	// +kubebuilder:validation:Pattern:=`^[a-z0-9]([a-z0-9\.\-]*[a-z0-9])?$`
	Name string `json:"name"`

	// type is in enum of {data, log}.
	// VolumeTypeData: the volume is for the persistent data storage.
	// VolumeTypeLog: the volume is for the persistent log storage.
	// +optional
	Type VolumeType `json:"type,omitempty"`
}

type WorkloadType

type WorkloadType string

WorkloadType defines ClusterDefinition's component workload type. +enum +kubebuilder:validation:Enum={Stateless,Stateful,Consensus,Replication}

const (
	Stateless   WorkloadType = "Stateless"
	Stateful    WorkloadType = "Stateful"
	Consensus   WorkloadType = "Consensus"
	Replication WorkloadType = "Replication"
)

Jump to

Keyboard shortcuts

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