use of io.kubernetes.client.Attach in project java by kubernetes-client.
the class AttachExample method main.
public static void main(String[] args) throws IOException, ApiException, InterruptedException {
ApiClient client = Config.defaultClient();
Configuration.setDefaultApiClient(client);
Attach attach = new Attach();
final Attach.AttachResult result = attach.attach("default", "nginx-4217019353-k5sn9", true);
new Thread(new Runnable() {
public void run() {
BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
OutputStream output = result.getStandardInputStream();
try {
while (true) {
String line = in.readLine();
output.write(line.getBytes());
output.write('\n');
output.flush();
}
} catch (IOException ex) {
ex.printStackTrace();
}
}
}).start();
new Thread(new Runnable() {
public void run() {
try {
ByteStreams.copy(result.getStandardOutputStream(), System.out);
} catch (IOException ex) {
ex.printStackTrace();
}
}
}).start();
Thread.sleep(10 * 1000);
result.close();
System.exit(0);
}
Aggregations