Kubernetes Java Client API(CopyfileToPod)

问题描述 投票:0回答:1

在Kubernetes Java客户端API中,似乎不支持将文件复制到Pod。在Copy.java中有一个函数称为“ copyFileToPod(String名称空间,String pod,String容器,Path srcPath,Path destPath)”,我使用的是Java客户端版本:7.0.0,但它不起作用。我的srcPath是“ Paths.get(“ hello.txt”);“并且destPath是“ Paths.get(” / usr / share / logstash / logstashvolume / hello“);”。源文件未编码。如何使用kubernetes Java客户端库将文件复制到Pod。

java kubernetes
1个回答
0
投票

我使用fabric8.io Kubernetes java client完成了此操作>

try (final KubernetesClient client = new DefaultKubernetesClient(config);
         ExecWatch watch = client.pods().inNamespace(namespace).withName(podName)
            .readingInput(System.in)
            .writingOutput(System.out)
            .writingError(System.err)
            .withTTY()
            .usingListener(new SimpleListener())
            .exec()){

        Thread.sleep(10 * 1000);
    }

Full example here

© www.soinside.com 2019 - 2024. All rights reserved.