public static void main(String[] args) throws InterruptedException { String master = "https://localhost:8443/"; String podName = null; if (args.length == 2) { master = args[0]; podName = args[1]; } if (args.length == 1) { podName = args[0]; } Config config = new ConfigBuilder().withMasterUrl(master).build(); try (final KubernetesClient client = new DefaultKubernetesClient(config); ExecWatch watch = client .pods() .withName(podName) .readingInput(System.in) .writingOutput(System.out) .writingError(System.err) .withTTY() .usingListener(new SimpleListener()) .exec()) { Thread.sleep(10 * 1000); } }
@Override public Object lookup(ArquillianResource resource, Annotation... qualifiers) { KubernetesClient client = this.clientInstance.get(); Session session = sessionInstance.get(); String name = getServiceName(qualifiers); return client.pods().inNamespace(session.getNamespace()).withName(name).get(); }
public static void main(String... args) throws Exception { KubernetesClient client = new DefaultKubernetesClient(); client .services() .watch( new io.fabric8.kubernetes.client.Watcher<Service>() { @Override public void eventReceived(Action action, Service service) { System.out.println(action + ": " + service); } @Override public void onClose(KubernetesClientException e) { System.out.println("Closed: " + e); } }); client.close(); }
@Override public Service getService(String name) { String serviceNamespace = Systems.getEnvVarOrSystemProperty(KUBERNETES_NAMESPACE, DEFAULT_NAMESPACE); if (kubernetesClient == null) { kubernetesClient = beanFactory.getBean(KubernetesClient.class); } return kubernetesClient.services().inNamespace(serviceNamespace).withName(name).get(); }