migration

package
v0.7.5 Latest Latest
Warning

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

Go to latest
Published: Mar 14, 2024 License: AGPL-3.0 Imports: 32 Imported by: 0

Documentation

Index

Constants

View Source
const (
	MigrationTaskLabel          = "datamigration.apecloud.io/migrationtask"
	MigrationTaskStepAnnotation = "datamigration.apecloud.io/step"
	SerialJobOrderAnnotation    = "common.apecloud.io/serial_job_order"
)
View Source
const (
	StringBoolTrue  = "true"
	StringBoolFalse = "false"
)

Variables

View Source
var (
	CreateTemplate = templates.Examples(`
		# Create a migration task to migrate the entire database under mysql: mydb1 and mytable1 under database: mydb2 to the target mysql
		kbcli migration create mytask --template apecloud-mysql2mysql 
		--source user:123456@127.0.0.1:3306 
		--sink user:123456@127.0.0.1:3305 
		--migration-object '"mydb1","mydb2.mytable1"'
		
		# Create a migration task to migrate the schema: myschema under database: mydb1 under PostgreSQL to the target PostgreSQL
		kbcli migration create mytask --template apecloud-pg2pg 
		--source user:123456@127.0.0.1:3306/mydb1 
		--sink user:123456@127.0.0.1:3305/mydb1
		--migration-object '"myschema"'

		# Use prechecks, data initialization, CDC, but do not perform structure initialization
		kbcli migration create mytask --template apecloud-pg2pg 
		--source user:123456@127.0.0.1:3306/mydb1 
		--sink user:123456@127.0.0.1:3305/mydb1
		--migration-object '"myschema"'
		--steps precheck=true,init-struct=false,init-data=true,cdc=true

		# Create a migration task with two tolerations
		kbcli migration create mytask --template apecloud-pg2pg 
		--source user:123456@127.0.0.1:3306/mydb1 
		--sink user:123456@127.0.0.1:3305/mydb1
		--migration-object '"myschema"'
		--tolerations '"step=global,key=engineType,value=pg,operator=Equal,effect=NoSchedule","step=init-data,key=diskType,value=ssd,operator=Equal,effect=NoSchedule"'

		# Limit resource usage when performing data initialization
		kbcli migration create mytask --template apecloud-pg2pg 
		--source user:123456@127.0.0.1:3306/mydb1 
		--sink user:123456@127.0.0.1:3305/mydb1
		--migration-object '"myschema"'
		--resources '"step=init-data,cpu=1000m,memory=1Gi"'
	`)
	DescribeExample = templates.Examples(`
		# describe a specified migration task
		kbcli migration describe mytask
	`)
	ListExample = templates.Examples(`
		# list all migration tasks
		kbcli migration list

		# list a single migration task with specified NAME
		kbcli migration list mytask

		# list a single migration task in YAML output format
		kbcli migration list mytask -o yaml

		# list a single migration task in JSON output format
		kbcli migration list mytask -o json

		# list a single migration task in wide output format
		kbcli migration list mytask -o wide
	`)
	TemplateExample = templates.Examples(`
		# list all migration templates
		kbcli migration templates

		# list a single migration template with specified NAME
		kbcli migration templates mytemplate

		# list a single migration template in YAML output format
		kbcli migration templates mytemplate -o yaml

		# list a single migration template in JSON output format
		kbcli migration templates mytemplate -o json

		# list a single migration template in wide output format
		kbcli migration templates mytemplate -o wide
	`)
	DeleteExample = templates.Examples(`
		# terminate a migration task named mytask and delete resources in k8s without affecting source and target data in database
		kbcli migration terminate mytask
	`)
	LogsExample = templates.Examples(`
		# Logs when returning to the "init-struct" step from the migration task mytask
		kbcli migration logs mytask --step init-struct

		# Logs only the most recent 20 lines when returning to the "cdc" step from the migration task mytask
		kbcli migration logs mytask --step cdc --tail=20
	`)
)

Cli Migration Command Examples

Functions

func APIResource

func APIResource(dynamic *dynamic.Interface, resource *schema.GroupVersionResource, name string, namespace string, res interface{}) error

func BuildErrorMsg

func BuildErrorMsg(msgArr *[]string, msg string)

func BuildInitializationStepsOrder

func BuildInitializationStepsOrder(task *migrationv1.MigrationTask, template *migrationv1.MigrationTemplate) []string

func CliStepChangeToStructure

func CliStepChangeToStructure() (map[string]string, []string)

func IsMigrationCrdValidWithDynamic

func IsMigrationCrdValidWithDynamic(dynamic *dynamic.Interface) (bool, error)

func IsMigrationCrdValidWithFactory

func IsMigrationCrdValidWithFactory(factory cmdutil.Factory) (bool, error)

func NewMigrationCmd

func NewMigrationCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command

NewMigrationCmd creates the cluster command

func NewMigrationCreateCmd

func NewMigrationCreateCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command

func NewMigrationDescribeCmd

func NewMigrationDescribeCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command

func NewMigrationListCmd

func NewMigrationListCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command

func NewMigrationLogsCmd

func NewMigrationLogsCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command

func NewMigrationTemplatesCmd

func NewMigrationTemplatesCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command

func NewMigrationTerminateCmd

func NewMigrationTerminateCmd(f cmdutil.Factory, streams genericiooptions.IOStreams) *cobra.Command

func PrintCrdInvalidError

func PrintCrdInvalidError(err error)

Types

type CreateMigrationOptions

type CreateMigrationOptions struct {
	Template             string                   `json:"template"`
	TaskType             string                   `json:"taskType,omitempty"`
	Source               string                   `json:"source"`
	SourceEndpointModel  EndpointModel            `json:"sourceEndpointModel,omitempty"`
	Sink                 string                   `json:"sink"`
	SinkEndpointModel    EndpointModel            `json:"sinkEndpointModel,omitempty"`
	MigrationObject      []string                 `json:"migrationObject"`
	MigrationObjectModel MigrationObjectModel     `json:"migrationObjectModel,omitempty"`
	Steps                []string                 `json:"steps,omitempty"`
	StepsModel           []string                 `json:"stepsModel,omitempty"`
	Tolerations          []string                 `json:"tolerations,omitempty"`
	TolerationModel      map[string][]interface{} `json:"tolerationModel,omitempty"`
	Resources            []string                 `json:"resources,omitempty"`
	ResourceModel        map[string]interface{}   `json:"resourceModel,omitempty"`
	ServerID             uint32                   `json:"serverId,omitempty"`
	create.CreateOptions `json:"-"`
}

func (*CreateMigrationOptions) BuildWithResources

func (o *CreateMigrationOptions) BuildWithResources() error

func (*CreateMigrationOptions) BuildWithRuntimeParams

func (o *CreateMigrationOptions) BuildWithRuntimeParams() error

func (*CreateMigrationOptions) BuildWithSteps

func (o *CreateMigrationOptions) BuildWithSteps(errMsgArr *[]string) error

func (*CreateMigrationOptions) BuildWithTolerations

func (o *CreateMigrationOptions) BuildWithTolerations() error

func (*CreateMigrationOptions) Validate

func (o *CreateMigrationOptions) Validate() error

type DBObjectExpress

type DBObjectExpress struct {
	SchemaName string `json:"schemaName"`
	// +optional
	IsAll bool `json:"isAll"`
	// +optional
	TableList []TableObjectExpress `json:"tableList"`
}

type EndpointModel

type EndpointModel struct {
	UserName string `json:"userName"`
	Password string `json:"password"`
	Address  string `json:"address"`
	// +optional
	Database string `json:"databaseName,omitempty"`
}

func (*EndpointModel) BuildFromStr

func (e *EndpointModel) BuildFromStr(msgArr *[]string, endpointStr string) error

type LogsOptions

type LogsOptions struct {
	Client  *kubernetes.Clientset
	Dynamic dynamic.Interface
	*exec.ExecOptions
	// contains filtered or unexported fields
}

type MigrationObjectModel

type MigrationObjectModel struct {
	WhiteList []DBObjectExpress `json:"whiteList"`
}

func (*MigrationObjectModel) BuildFromStrs

func (m *MigrationObjectModel) BuildFromStrs(errMsgArr *[]string, objStrs []string) error

func (*MigrationObjectModel) ContainSchema

func (m *MigrationObjectModel) ContainSchema(schemaName string) (*DBObjectExpress, error)

type TableObjectExpress

type TableObjectExpress struct {
	TableName string `json:"tableName"`
	// +optional
	IsAll bool `json:"isAll"`
}

type TaskTypeEnum

type TaskTypeEnum string
const (
	Initialization       TaskTypeEnum = "initialization"
	InitializationAndCdc TaskTypeEnum = "initialization-and-cdc" // default value
)

func (TaskTypeEnum) String

func (s TaskTypeEnum) String() string

Jump to

Keyboard shortcuts

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