use of io.kubernetes.client.apis.CoreV1Api in project weblogic-kubernetes-operator by oracle.
the class TestEnhancedAuthenticationAT method testCreateClientByServiceAccount.
@Test
public void testCreateClientByServiceAccount() throws Exception {
try {
// First authenticate using the default service account in default
// namespace. The resultant client is used to do a trivial call
// to demonstrate that the rest API is available weith the new client.
Authenticator auth1 = new Authenticator();
ApiClient client = auth1.createClientByServiceAccountName("default", "default");
CoreV1Api coreApi = new CoreV1Api(client);
System.out.println("authenticated by service account");
V1APIResourceList rslist = coreApi.getAPIResources();
System.out.println(rslist);
// Pickup the token from the first authentication and use it to
// find the same service account that was just authenticated. Then
// do a REST api call with the returned client to verify the API
// is available through the new client.
Authenticator auth2 = new Authenticator(client);
client = auth2.createClientByToken(auth1.getServiceToken());
coreApi = new CoreV1Api(client);
System.out.println("authenticated by token");
rslist = coreApi.getAPIResources();
System.out.println(rslist);
System.out.println("Successful end of this test");
} catch (Exception e) {
System.out.println("Test failed with exception - " + e);
e.printStackTrace();
}
}
use of io.kubernetes.client.apis.CoreV1Api in project weblogic-kubernetes-operator by oracle.
the class CallBuilder method listNamespace.
/* Namespaces */
/**
* List namespaces
* @return List of namespaces
* @throws ApiException API Exception
*/
public V1NamespaceList listNamespace() throws ApiException {
String _continue = "";
ApiClient client = helper.take();
try {
return new CoreV1Api(client).listNamespace(pretty, _continue, fieldSelector, includeUninitialized, labelSelector, limit, resourceVersion, timeoutSeconds, watch);
} finally {
helper.recycle(client);
}
}
use of io.kubernetes.client.apis.CoreV1Api in project weblogic-kubernetes-operator by oracle.
the class CallBuilder method listPod.
/* Pods */
/**
* List pods
* @param namespace Namespace
* @return Listed pods
* @throws ApiException API Exception
*/
public V1PodList listPod(String namespace) throws ApiException {
String _continue = "";
ApiClient client = helper.take();
try {
return new CoreV1Api(client).listNamespacedPod(namespace, pretty, _continue, fieldSelector, includeUninitialized, labelSelector, limit, resourceVersion, timeoutSeconds, watch);
} finally {
helper.recycle(client);
}
}
use of io.kubernetes.client.apis.CoreV1Api in project weblogic-kubernetes-operator by oracle.
the class CallBuilder method deleteCollectionPod.
/**
* Delete collection of pods
* @param namespace Namespace
* @return Status of deletion
* @throws ApiException API Exception
*/
public V1Status deleteCollectionPod(String namespace) throws ApiException {
String _continue = "";
ApiClient client = helper.take();
try {
return new CoreV1Api(client).deleteCollectionNamespacedPod(namespace, pretty, _continue, fieldSelector, includeUninitialized, labelSelector, limit, resourceVersion, timeoutSeconds, watch);
} finally {
helper.recycle(client);
}
}
use of io.kubernetes.client.apis.CoreV1Api in project twister2 by DSC-SPIDAL.
the class KubernetesController method createApiInstances.
public void createApiInstances() {
try {
client = io.kubernetes.client.util.Config.defaultClient();
} catch (IOException e) {
LOG.log(Level.SEVERE, "Exception when creating ApiClient: ", e);
throw new RuntimeException(e);
}
Configuration.setDefaultApiClient(client);
coreApi = new CoreV1Api();
beta2Api = new AppsV1beta2Api(client);
}
Aggregations