func (e *JobExecutor) CopyFromPod(srcPath, dstPath string) error {
	return e.copyFromPodWithRetry(srcPath, dstPath)
}
CopyFromPod copy directory or files from specified path on Pod.
package kubejob
import (
	"archive/tar"
	"bytes"
	"context"
	"fmt"
	"io"
	"os"
	"path"
	"path/filepath"
	"strings"
	"sync"
	"time"
	"github.com/lestrrat-go/backoff"
	core "k8s.io/api/core/v1"
	"k8s.io/client-go/kubernetes/scheme"
	"k8s.io/client-go/tools/remotecommand"
)
func (e *JobExecutor) CopyToPod(srcPath, dstPath string) error {
	if len(srcPath) == 0 || len(dstPath) == 0 {
		return errCopyWithEmptyPath(srcPath, dstPath)
	}
	if _, err := os.Stat(srcPath); err != nil {
		return errCopy(srcPath, dstPath, fmt.Errorf("%s doesn't exist in local filesystem", srcPath))
	}
	if dstPath != "/" && dstPath[len(dstPath)-1] == '/' {
		dstPath = dstPath[:len(dstPath)-1]
	}
	if _, err := e.exec([]string{"test", "-d", dstPath}); err == nil {
		dstPath = filepath.Join(dstPath, path.Base(srcPath))
	}
	tarCmd := []string{"tar", "--no-same-owner", "-xmf", "-"}
	dstDir := filepath.Dir(dstPath)
	if len(dstDir) > 0 {
		tarCmd = append(tarCmd, "-C", dstDir)
	}
	pod := e.Pod
	req := e.job.restClient.Post().
		Namespace(pod.Namespace).
		Resource("pods").
		Name(pod.Name).
		SubResource("exec").
		VersionedParams(&core.PodExecOptions{
			Container: e.Container.Name,
			Command:   tarCmd,
			Stdin:     true,
			Stdout:    true,
			Stderr:    true,
		}, scheme.ParameterCodec)
	url := req.URL()
	exec, err := remotecommand.NewSPDYExecutor(e.job.config, "POST", url)
	if err != nil {
		return fmt.Errorf("job: failed to create spdy executor: %w", err)
	}
	reader, writer := io.Pipe()
	var writerErr error
	go func() {
		defer writer.Close()
		writerErr = e.writeWithTar(writer, srcPath, dstPath)
	}()
	var (
		outCapturer bytes.Buffer
		errCapturer bytes.Buffer
	)
	readerErr := exec.Stream(remotecommand.StreamOptions{
		Stdin:  reader,
		Stdout: &outCapturer,
		Stderr: &errCapturer,
		Tty:    false,
	})
	if readerErr != nil || writerErr != nil {
		buf := []string{}
		stdout := outCapturer.String()
		if len(stdout) > 0 {
			buf = append(buf, stdout)
		}
		stderr := errCapturer.String()
		if len(stderr) > 0 {
			buf = append(buf, stderr)
		}
		return errCopyWithReaderWriter(srcPath, dstPath, readerErr, writerErr, strings.Join(buf, ":"))
	}
	return nil
}