transfer_pvc

package
v0.0.5 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2022 License: Apache-2.0 Imports: 44 Imported by: 0

README

Transfer Persistent Volume Claims

The transfer-pvc subcommand in Crane can be used to transfer PersistentVolumeClaim resource and volume data to destination cluster. It establishes connection to the destination cluster by creating a public endpoint of user's choice in the destination namespace. It then creates a PVC and an rsync daemon Pod in the destination namespace to receive data from the source PVC. Finally, it creates an rsync client Pod in the source namespace which transfers data to the rsync daemon using the endpoint. The connection is encrypted using self-signed cerificates created automatically at the time of transfer.

Example

crane transfer-pvc --source-context=<source> --destination-context=<destination> --pvc-name=<pvc_name> --endpoint=route

The above command transfers PVC (along with PV data) named <pvc_name> in the namespace specified by <source> context into the namespace specified by <destination> context. The --endpoint argument specifies the kind of public endpoint to use to establish a connection between the source and the destination cluster.

Options

transfer-pvc subcommand can be configured using various additional options available:

Option Type Required Description
source-context string Yes Kube context of the source cluster
destination-context string Yes Kube context of the destination cluster
pvc-name string Yes Mapping of the source/destination PVC names (See PVC options)
pvc-namespace string No Mapping of the source/destination PVC namespaces (See PVC options)
dest-storage-class string No Storage class of destination PVC (Defaults to source storage class)
dest-storage-requests string No Requested storage capacity of destination PVC (Defaults to source capacity)
destination-image string No Custom image to use for destination rsync Pod
source-image string No Custom image to use for source rsync Pod
endpoint string No Kind of endpoint to create in destination cluster (See Endpoint Options)
ingress-class string No Ingress class when endpoint is nginx-ingress (See Endpoint Options)
subdomain string No Custom subdomain to use for the endpoint (See Endpoint Options)
output string No Output transfer stats in the specified file
verify bool No Verify transferred files using checksums
help bool No Display help
PVC Options

--pvc-name option allows specifying a mapping of source and destination PVC names. This is a required option.

--pvc-namespace=<namespace> option allows specifying a mapping of namespaces of source and destination PVC. By default, the namespaces in the source and destination contexts are used. When this option is specified the namespaces in kube contexts are ignored and specified namespaces are used.

Both --pvc-name and --pvc-namespaces follow mapping format <source>:<destination>, where <source> specifies the name in the source cluster while <destination> is the name in the destination cluster. If only <source> is specified, the same names are used in destination cluster.

Examples

To transfer a PVC test-pvc in namespace test-ns to a destination PVC by same name & namespace:

crane transfer-pvc --pvc-name=test-pvc --pvc-namespace=test-ns ...

To transfer a PVC source-pvc in namespace source-ns to a destination PVC destination-pvc in namespace destination-ns:

crane transfer-pvc --pvc-name=source-pvc:destination-pvc --pvc-namespace=source-ns:destination-ns ...
Endpoint Options

Endpoint enables a connection between the source and destination cluster for data transfer. It is created in the destination cluster. The destination cluster must support the kind of endpoint used.

By default, nginx-ingress is used as endpoint. For nginx-ingress, --subdomain and --ingress-class are required.

In an OpenShift cluster, route endpoint can be used. A subdomain option can be specified but is not required. By default, the cluster's subdomain will be used.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewTransferPVCCommand added in v0.0.5

func NewTransferPVCCommand(streams genericclioptions.IOStreams) *cobra.Command

Types

type EndpointFlags added in v0.0.5

type EndpointFlags struct {
	// Type defines the endpoint type
	Type endpointType
	// Subdomain defines host of the endpoint
	Subdomain string
	// IngressClass defines class for ingress
	IngressClass string
}

EndpointFlags defines command line flags specific to the endpoint to be used in transfer

func (EndpointFlags) Validate added in v0.0.5

func (e EndpointFlags) Validate() error

type FailedFile added in v0.0.5

type FailedFile struct {
	Name string `json:"name"`
	Err  string `json:"error"`
}

type Flags added in v0.0.5

type Flags struct {
	PVC                PvcFlags
	Endpoint           EndpointFlags
	SourceContext      string
	DestinationContext string
	SourceImage        string
	DestinationImage   string
	Verify             bool
	RsyncFlags         []string
	ProgressOutput     string
}

Flags defines options configured by users via command line flags of the subcommand

type LogStreams added in v0.0.5

type LogStreams interface {
	// Init initiates the log streams
	Init() error
	// Streams returns streams for output and error logs
	// returns a stream to communicate errors
	Streams() (stdout chan string, stderr chan string, err chan error)
	// Close closes log streams
	Close()
}

LogStreams defines functions to read from a stream of pod logs

func NewRsyncLogStream added in v0.0.5

func NewRsyncLogStream(restCfg *rest.Config, pvc types.NamespacedName, labels map[string]string, output string) LogStreams

type Progress added in v0.0.5

type Progress struct {
	PVC                types.NamespacedName `json:"pvc"`
	TransferPercentage *int64               `json:"transferPercentage"`
	TransferRate       *dataSize            `json:"transferRate"`
	TransferredData    *dataSize            `json:"transferredData"`
	TotalFiles         *int64               `json:"totalFiles"`
	TransferredFiles   int64                `json:"transferredFiles"`
	ExitCode           *int32               `json:"exitCode"`
	FailedFiles        []FailedFile         `json:"failedFiles"`
	Errors             []string             `json:"miscErrors"`
	// contains filtered or unexported fields
}

Progress defines transfer Progress

func NewProgress added in v0.0.5

func NewProgress(name types.NamespacedName) *Progress

func (*Progress) AsString added in v0.0.5

func (p *Progress) AsString() (out string, err string)

func (*Progress) Merge added in v0.0.5

func (p *Progress) Merge(in *Progress)

Merge merges two progress objects

func (*Progress) Status added in v0.0.5

func (p *Progress) Status() status

Status returns current status of transfer

type PvcFlags added in v0.0.5

type PvcFlags struct {
	// Name defines Name of the PVC,
	// mapped in format <source>:<destination>
	Name mappedNameVar
	// Namespace defines Namespace of the PVC,
	// mapped in format <source>:<destination>
	Namespace mappedNameVar
	// StorageClassName defines storage class of destination PVC
	StorageClassName string
	// StorageRequests defines requested capacity of destination PVC
	StorageRequests quantityVar
}

PvcFlags defines command line flags for the PVC to be transferred

func (*PvcFlags) Validate added in v0.0.5

func (p *PvcFlags) Validate() error

type TransferPVCCommand added in v0.0.5

type TransferPVCCommand struct {
	genericclioptions.IOStreams

	// user defined flags for the subcommand
	Flags
	// contains filtered or unexported fields
}

func (*TransferPVCCommand) Complete added in v0.0.5

func (t *TransferPVCCommand) Complete(c *cobra.Command, args []string) error

func (*TransferPVCCommand) Run added in v0.0.5

func (t *TransferPVCCommand) Run() error

func (*TransferPVCCommand) Validate added in v0.0.5

func (t *TransferPVCCommand) Validate() error

Jump to

Keyboard shortcuts

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