parent
3af79ab185
commit
2cedaa4ce8
@ -0,0 +1,31 @@
|
||||
|
||||
import io.kubernetes.client.openapi.ApiClient;
|
||||
import io.kubernetes.client.openapi.ApiException;
|
||||
import io.kubernetes.client.openapi.Configuration;
|
||||
import io.kubernetes.client.openapi.apis.CoreV1Api;
|
||||
import io.kubernetes.client.openapi.models.V1Pod;
|
||||
import io.kubernetes.client.openapi.models.V1PodList;
|
||||
import io.kubernetes.client.util.Config;
|
||||
import java.io.IOException;
|
||||
|
||||
/**
|
||||
* A simple example of how to use the Java API
|
||||
*
|
||||
* <p>Easiest way to run this: mvn exec:java
|
||||
* -Dexec.mainClass="io.kubernetes.client.examples.Example"
|
||||
*
|
||||
* <p>From inside $REPO_DIR/examples
|
||||
*/
|
||||
public class Example {
|
||||
public static void main(String[] args) throws IOException, ApiException {
|
||||
ApiClient client = Config.defaultClient();
|
||||
Configuration.setDefaultApiClient(client);
|
||||
|
||||
CoreV1Api api = new CoreV1Api();
|
||||
V1PodList list = api.listPodForAllNamespaces()
|
||||
.execute();
|
||||
for (V1Pod item : list.getItems()) {
|
||||
System.out.println(item.getMetadata().getName());
|
||||
}
|
||||
}
|
||||
}
|
Loading…
Reference in new issue