Search in sources :

Example 11 with ApiClient

use of io.kubernetes.client.ApiClient in project weblogic-kubernetes-operator by oracle.

the class Authenticator method authenticateByServiceAccount.

/**
 * Given a V1ServiceAccount object, pull the authentication secrets and
 * initialize a new ApiClient to authenticate with those credentials.
 *
 * @param serviceAccount The name of the Service Account to authenticate with.
 * @return ApiClient An ApiClient for the given Service Account.
 * @throws ApiException if there is an API error.
 */
private ApiClient authenticateByServiceAccount(V1ServiceAccount serviceAccount) throws ApiException {
    LOGGER.entering();
    byte[] caCert = null;
    String token = null;
    List<V1ObjectReference> secretList = serviceAccount.getSecrets();
    for (V1ObjectReference reference : secretList) {
        // Get the secret.
        V1Secret secret = helper.readSecretByReference(reference, serviceAccount.getMetadata().getNamespace());
        Map<String, byte[]> secretMap = secret.getData();
        for (Entry<String, byte[]> entry : secretMap.entrySet()) {
            if (entry.getKey().equals("ca.crt")) {
                caCert = entry.getValue();
            }
            if (entry.getKey().equals("token")) {
                token = new String(entry.getValue());
            }
        }
    }
    serviceToken = token;
    String serviceHost = System.getenv(_SERVICE_HOST);
    String servicePort = System.getenv(_SERVICE_PORT);
    String serviceUrl = "https://" + serviceHost + ":" + servicePort;
    ApiClient newClient = new ApiClient();
    newClient.setBasePath(serviceUrl);
    newClient.setApiKey("Bearer " + token);
    newClient.setSslCaCert(new ByteArrayInputStream(caCert));
    LOGGER.exiting(newClient);
    return newClient;
}
Also used : V1ObjectReference(io.kubernetes.client.models.V1ObjectReference) ByteArrayInputStream(java.io.ByteArrayInputStream) ApiClient(io.kubernetes.client.ApiClient) V1Secret(io.kubernetes.client.models.V1Secret)

Example 12 with ApiClient

use of io.kubernetes.client.ApiClient in project weblogic-kubernetes-operator by oracle.

the class CallBuilder method listDomain.

/* Domains */
/**
 * List domains
 * @param namespace Namespace
 * @return Domain list
 * @throws ApiException API exception
 */
public DomainList listDomain(String namespace) throws ApiException {
    String _continue = "";
    ApiClient client = helper.take();
    try {
        return new WeblogicApi(client).listWebLogicOracleV1NamespacedDomain(namespace, pretty, _continue, fieldSelector, includeUninitialized, labelSelector, limit, resourceVersion, timeoutSeconds, watch);
    } finally {
        helper.recycle(client);
    }
}
Also used : WeblogicApi(oracle.kubernetes.weblogic.domain.v1.api.WeblogicApi) ApiClient(io.kubernetes.client.ApiClient)

Example 13 with ApiClient

use of io.kubernetes.client.ApiClient in project weblogic-kubernetes-operator by oracle.

the class CallBuilder method listPersistentVolume.

/* Persistent Volumes */
/**
 * List persistent volumes
 * @return List of persistent volumes
 * @throws ApiException API Exception
 */
public V1PersistentVolumeList listPersistentVolume() throws ApiException {
    String _continue = "";
    ApiClient client = helper.take();
    try {
        return new CoreV1Api(client).listPersistentVolume(pretty, _continue, fieldSelector, includeUninitialized, labelSelector, limit, resourceVersion, timeoutSeconds, watch);
    } finally {
        helper.recycle(client);
    }
}
Also used : ApiClient(io.kubernetes.client.ApiClient) CoreV1Api(io.kubernetes.client.apis.CoreV1Api)

Example 14 with ApiClient

use of io.kubernetes.client.ApiClient in project weblogic-kubernetes-operator by oracle.

the class CallBuilder method listPersistentVolumeClaim.

/* Persistent Volume Claims */
/**
 * List persistent volume claims
 * @param namespace Namespace
 * @return List of persistent volume claims
 * @throws ApiException API Exception
 */
public V1PersistentVolumeClaimList listPersistentVolumeClaim(String namespace) throws ApiException {
    String _continue = "";
    ApiClient client = helper.take();
    try {
        return new CoreV1Api(client).listNamespacedPersistentVolumeClaim(namespace, pretty, _continue, fieldSelector, includeUninitialized, labelSelector, limit, resourceVersion, timeoutSeconds, watch);
    } finally {
        helper.recycle(client);
    }
}
Also used : ApiClient(io.kubernetes.client.ApiClient) CoreV1Api(io.kubernetes.client.apis.CoreV1Api)

Example 15 with ApiClient

use of io.kubernetes.client.ApiClient in project weblogic-kubernetes-operator by oracle.

the class CallBuilder method listConfigMap.

/* Config Maps */
/**
 * List config maps
 * @param namespace Namespace
 * @return List of config maps
 * @throws ApiException API Exception
 */
public V1ConfigMapList listConfigMap(String namespace) throws ApiException {
    String _continue = "";
    ApiClient client = helper.take();
    try {
        return new CoreV1Api(client).listNamespacedConfigMap(namespace, pretty, _continue, fieldSelector, includeUninitialized, labelSelector, limit, resourceVersion, timeoutSeconds, watch);
    } finally {
        helper.recycle(client);
    }
}
Also used : ApiClient(io.kubernetes.client.ApiClient) CoreV1Api(io.kubernetes.client.apis.CoreV1Api)

Aggregations

ApiClient (io.kubernetes.client.ApiClient)18 CoreV1Api (io.kubernetes.client.apis.CoreV1Api)9 ApiException (io.kubernetes.client.ApiException)4 IOException (java.io.IOException)4 InvalidProtocolBufferException (com.google.protobuf.InvalidProtocolBufferException)3 CustomObjectsApi (io.kubernetes.client.apis.CustomObjectsApi)3 ExtensionsV1beta1Api (io.kubernetes.client.apis.ExtensionsV1beta1Api)3 Gson (com.google.gson.Gson)2 GsonBuilder (com.google.gson.GsonBuilder)2 TypeToken (com.google.gson.reflect.TypeToken)2 Watch (io.kubernetes.client.util.Watch)2 SocketTimeoutException (java.net.SocketTimeoutException)2 JsonFactory (com.fasterxml.jackson.core.JsonFactory)1 JsonParser (com.fasterxml.jackson.core.JsonParser)1 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)1 Response (com.squareup.okhttp.Response)1 TopologyRuntimeManagementException (com.twitter.heron.scheduler.TopologyRuntimeManagementException)1 ExtensionsV1beta1Deployment (io.kubernetes.client.models.ExtensionsV1beta1Deployment)1 ExtensionsV1beta1DeploymentList (io.kubernetes.client.models.ExtensionsV1beta1DeploymentList)1