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!");
}
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);
}
}
Aggregations