use of com.marcnuri.yakc.apiextensions.ExtendedCoreV1Api in project yakc by manusa.
the class PodExec method main.
public static void main(String[] args) {
try (KubernetesClient kc = new KubernetesClient()) {
final ExtendedCoreV1Api api = kc.create(ExtendedCoreV1Api.class);
createPod(api);
api.execInNamespacedPod(POD_NAME, NAMESPACE, Collections.singletonList("pwd")).exec().skip(1).subscribe(em -> System.out.printf("Current container Directory: %s", em.toString()));
System.out.println("Running memory monitor for 5s in the background");
api.execInNamespacedPod(POD_NAME, NAMESPACE, Arrays.asList("/bin/sh", "-c", "for i in $(seq 1 5); do cat /proc/meminfo | grep MemFree & sleep 1; done")).exec().subscribeOn(Schedulers.io()).skip(1).subscribe(t -> System.out.printf(" ++ %s", t.toString()), Throwable::printStackTrace);
api.execInNamespacedPod(POD_NAME, NAMESPACE, Arrays.asList("/bin/sh", "-c", "echo 'Waiting 5S' && sleep 5" + "&& echo 'Hello World in error standard stream' >> /dev/stderr" + "&& echo 'Container execution completed, bye!'")).exec().skip(1).subscribe(t -> System.out.printf("%s: %s", t.getStandardStream(), t.toString()), Throwable::printStackTrace);
System.out.println("Subscriptions completed, cleaning up.");
deletePod(api);
} catch (Exception ex) {
ex.printStackTrace();
}
}
Aggregations