Invoke–CopyLocalToRemote - anongitmous/k8sShell GitHub Wiki

Copy files and directories from a local source to a destination on remote pods (containers).

Syntax

Invoke-CopyLocalToRemote

[-Containers] <Mtf.Kubernetes.Models.V1K8sContainer[]>
-Source <String>
-Destination <String>
[<K8sShellCommonParameters>]
[<CommonParameters>]

Invoke-CopyLocalToRemote

[-Pods] <Mtf.Kubernetes.Models.V1K8sPod[]>
[-ContainerName <String>]
-Source <String>
-Destination <String>
[<K8sShellCommonParameters>]
[<CommonParameters>]

Description

For every result of Get–Pods or Get–Containers piped into this cmdlet, the local file or directory indicated by Source will be copied to the remote directory indicated by Destination.

Examples

ℹ️ See A Note about the Examples

1. Copy the 'C:\Staging' directory to the '/home' directory on every pod

Get-Pods | Invoke-CopyLocalToRemote -Source 'C:/Staging' -Destination '/home'

  • If the ContainerName argument is not supplied, then the source pods in this example must have a single container. If not, then the copy operation will fail for that pod.
  • Using aliasing, the above can be shortened to
    ksgp | ksclr -s 'C:/Staging' -d '/home'

2. Copy the 'C:\Staging' directory to the '/home' directory on every container in every pod

Get-Pods | Get-Containers | Invoke-CopyLocalToRemote -Source 'C:/Staging' -Destination '/home'

  • Using aliasing, the above can be shortened to
    ksgp | ksgc | ksclr -s 'C:/Staging' -d '/home'

Parameters

-Containers

Type: Mtf.Kubernetes.Models.V1K8sContainer[]
Aliases:
Position: 0
Default value: None
Accept pipeline input: True
Accept wildcard characters: False

-Pods

  • The pod(s) resulting from a call to Get–Pods to copy to.
Type: Mtf.Kubernetes.Models.V1K8sPod[]
Aliases:
Position: 0
Default value: None
Accept pipeline input: True
Accept wildcard characters: False

-ContainerName

  • The name of the container to copy to.
  • Specify along with the -Pods parameter to specify which container to copy to when the pods have more than a single container.
Type: String
Aliases:
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Source

  • Full path of the source file or directory on the local filesystem.
Type: String
Aliases: s
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

-Destination

  • Full path of the remote destination directory to which local file(s) are to be copied.
Type: String
Aliases: d
Position: Named
Default value: None
Accept pipeline input: False
Accept wildcard characters: False

Notes

K8sShell includes the following alias for Invoke-CopyLocalToRemote:

  • ksclr

Related

⚠️ **GitHub.com Fallback** ⚠️