Search in sources :

Example 1 with Copy

use of io.kubernetes.client.Copy in project java by kubernetes-client.

the class CopyExample method main.

public static void main(String[] args) throws IOException, ApiException, InterruptedException, CopyNotSupportedException {
    String podName = "kube-addon-manager-minikube";
    String namespace = "kube-system";
    ApiClient client = Config.defaultClient();
    Configuration.setDefaultApiClient(client);
    Copy copy = new Copy();
    InputStream dataStream = copy.copyFileFromPod(namespace, podName, "/etc/motd");
    Streams.copy(dataStream, System.out);
    copy.copyDirectoryFromPod(namespace, podName, null, "/etc", Paths.get("/tmp/etc"));
    System.out.println("Done!");
}
Also used : Copy(io.kubernetes.client.Copy) InputStream(java.io.InputStream) ApiClient(io.kubernetes.client.openapi.ApiClient)

Example 2 with Copy

use of io.kubernetes.client.Copy in project java by kubernetes-client.

the class KubectlCopy method execute.

@Override
public Boolean execute() throws KubectlException {
    validate();
    Copy cp = new Copy(apiClient);
    try {
        if (toPod) {
            cp.copyFileToPod(namespace, name, container, Paths.get(from), Paths.get(to));
        } else {
            if (this.dir) {
                cp.copyDirectoryFromPod(namespace, name, container, from, Paths.get(to));
            } else {
                cp.copyFileFromPod(namespace, name, container, from, Paths.get(to));
            }
        }
        return true;
    } catch (ApiException | IOException | CopyNotSupportedException ex) {
        throw new KubectlException(ex);
    }
}
Also used : Copy(io.kubernetes.client.Copy) IOException(java.io.IOException) KubectlException(io.kubernetes.client.extended.kubectl.exception.KubectlException) CopyNotSupportedException(io.kubernetes.client.util.exception.CopyNotSupportedException) ApiException(io.kubernetes.client.openapi.ApiException)

Aggregations

Copy (io.kubernetes.client.Copy)2 KubectlException (io.kubernetes.client.extended.kubectl.exception.KubectlException)1 ApiClient (io.kubernetes.client.openapi.ApiClient)1 ApiException (io.kubernetes.client.openapi.ApiException)1 CopyNotSupportedException (io.kubernetes.client.util.exception.CopyNotSupportedException)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1