github.com/1aal/kubeblocks@v0.0.0-20231107070852-e1c03e598921/pkg/cli/cmd/migration/examples.go (about)

     1  /*
     2  Copyright (C) 2022-2023 ApeCloud Co., Ltd
     3  
     4  This file is part of KubeBlocks project
     5  
     6  This program is free software: you can redistribute it and/or modify
     7  it under the terms of the GNU Affero General Public License as published by
     8  the Free Software Foundation, either version 3 of the License, or
     9  (at your option) any later version.
    10  
    11  This program is distributed in the hope that it will be useful
    12  but WITHOUT ANY WARRANTY; without even the implied warranty of
    13  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
    14  GNU Affero General Public License for more details.
    15  
    16  You should have received a copy of the GNU Affero General Public License
    17  along with this program.  If not, see <http://www.gnu.org/licenses/>.
    18  */
    19  
    20  package migration
    21  
    22  import "k8s.io/kubectl/pkg/util/templates"
    23  
    24  // Cli Migration Command Examples
    25  var (
    26  	CreateTemplate = templates.Examples(`
    27  		# Create a migration task to migrate the entire database under mysql: mydb1 and mytable1 under database: mydb2 to the target mysql
    28  		kbcli migration create mytask --template apecloud-mysql2mysql 
    29  		--source user:123456@127.0.0.1:3306 
    30  		--sink user:123456@127.0.0.1:3305 
    31  		--migration-object '"mydb1","mydb2.mytable1"'
    32  		
    33  		# Create a migration task to migrate the schema: myschema under database: mydb1 under PostgreSQL to the target PostgreSQL
    34  		kbcli migration create mytask --template apecloud-pg2pg 
    35  		--source user:123456@127.0.0.1:3306/mydb1 
    36  		--sink user:123456@127.0.0.1:3305/mydb1
    37  		--migration-object '"myschema"'
    38  
    39  		# Use prechecks, data initialization, CDC, but do not perform structure initialization
    40  		kbcli migration create mytask --template apecloud-pg2pg 
    41  		--source user:123456@127.0.0.1:3306/mydb1 
    42  		--sink user:123456@127.0.0.1:3305/mydb1
    43  		--migration-object '"myschema"'
    44  		--steps precheck=true,init-struct=false,init-data=true,cdc=true
    45  
    46  		# Create a migration task with two tolerations
    47  		kbcli migration create mytask --template apecloud-pg2pg 
    48  		--source user:123456@127.0.0.1:3306/mydb1 
    49  		--sink user:123456@127.0.0.1:3305/mydb1
    50  		--migration-object '"myschema"'
    51  		--tolerations '"step=global,key=engineType,value=pg,operator=Equal,effect=NoSchedule","step=init-data,key=diskType,value=ssd,operator=Equal,effect=NoSchedule"'
    52  
    53  		# Limit resource usage when performing data initialization
    54  		kbcli migration create mytask --template apecloud-pg2pg 
    55  		--source user:123456@127.0.0.1:3306/mydb1 
    56  		--sink user:123456@127.0.0.1:3305/mydb1
    57  		--migration-object '"myschema"'
    58  		--resources '"step=init-data,cpu=1000m,memory=1Gi"'
    59  	`)
    60  	DescribeExample = templates.Examples(`
    61  		# describe a specified migration task
    62  		kbcli migration describe mytask
    63  	`)
    64  	ListExample = templates.Examples(`
    65  		# list all migration tasks
    66  		kbcli migration list
    67  
    68  		# list a single migration task with specified NAME
    69  		kbcli migration list mytask
    70  
    71  		# list a single migration task in YAML output format
    72  		kbcli migration list mytask -o yaml
    73  
    74  		# list a single migration task in JSON output format
    75  		kbcli migration list mytask -o json
    76  
    77  		# list a single migration task in wide output format
    78  		kbcli migration list mytask -o wide
    79  	`)
    80  	TemplateExample = templates.Examples(`
    81  		# list all migration templates
    82  		kbcli migration templates
    83  
    84  		# list a single migration template with specified NAME
    85  		kbcli migration templates mytemplate
    86  
    87  		# list a single migration template in YAML output format
    88  		kbcli migration templates mytemplate -o yaml
    89  
    90  		# list a single migration template in JSON output format
    91  		kbcli migration templates mytemplate -o json
    92  
    93  		# list a single migration template in wide output format
    94  		kbcli migration templates mytemplate -o wide
    95  	`)
    96  	DeleteExample = templates.Examples(`
    97  		# terminate a migration task named mytask and delete resources in k8s without affecting source and target data in database
    98  		kbcli migration terminate mytask
    99  	`)
   100  	LogsExample = templates.Examples(`
   101  		# Logs when returning to the "init-struct" step from the migration task mytask
   102  		kbcli migration logs mytask --step init-struct
   103  
   104  		# Logs only the most recent 20 lines when returning to the "cdc" step from the migration task mytask
   105  		kbcli migration logs mytask --step cdc --tail=20
   106  	`)
   107  )