Search in sources :

Example 61 with ApiClient

use of io.kubernetes.client.openapi.ApiClient in project java by kubernetes-client.

the class KubernetesInformerFactoryProcessor method informer.

@SuppressWarnings({ "unchecked", "rawtypes" })
private <T extends KubernetesObject> SharedInformer<T> informer(Class<T> type, KubernetesInformer kubernetesInformer) {
    ApiClient apiClient = this.beanFactory.getBean(ApiClient.class);
    if (apiClient.getHttpClient().readTimeoutMillis() > 0) {
        log.warn("Enforcing read-timeout of the ApiClient {} to {} so that the watch connection won't abort from client-side", apiClient, informerProperties.getClientReadTimeout());
        apiClient.setHttpClient(apiClient.getHttpClient().newBuilder().readTimeout(informerProperties.getClientReadTimeout()).build());
    }
    SharedInformerFactory sharedInformerFactory = this.beanFactory.getBean(SharedInformerFactory.class);
    final GenericKubernetesApi api = new GenericKubernetesApi(kubernetesInformer.apiTypeClass(), kubernetesInformer.apiListTypeClass(), kubernetesInformer.groupVersionResource().apiGroup(), kubernetesInformer.groupVersionResource().apiVersion(), kubernetesInformer.groupVersionResource().resourcePlural(), apiClient);
    SharedIndexInformer<T> sharedIndexInformer = sharedInformerFactory.sharedIndexInformerFor(api, type, kubernetesInformer.resyncPeriodMillis(), kubernetesInformer.namespace());
    return sharedIndexInformer;
}
Also used : SharedInformerFactory(io.kubernetes.client.informer.SharedInformerFactory) GenericKubernetesApi(io.kubernetes.client.util.generic.GenericKubernetesApi) ApiClient(io.kubernetes.client.openapi.ApiClient)

Aggregations

ApiClient (io.kubernetes.client.openapi.ApiClient)61 Test (org.junit.Test)28 CoreV1Api (io.kubernetes.client.openapi.apis.CoreV1Api)13 V1Pod (io.kubernetes.client.openapi.models.V1Pod)12 IOException (java.io.IOException)11 V1PodList (io.kubernetes.client.openapi.models.V1PodList)9 ClientBuilder (io.kubernetes.client.util.ClientBuilder)6 V1ObjectMeta (io.kubernetes.client.openapi.models.V1ObjectMeta)5 Before (org.junit.Before)5 ApiException (io.kubernetes.client.openapi.ApiException)4 SharedInformerFactory (io.kubernetes.client.informer.SharedInformerFactory)3 V1Job (io.kubernetes.client.openapi.models.V1Job)3 V1JobList (io.kubernetes.client.openapi.models.V1JobList)3 V1Namespace (io.kubernetes.client.openapi.models.V1Namespace)3 OkHttpClient (okhttp3.OkHttpClient)3 NodeMetrics (io.kubernetes.client.custom.NodeMetrics)2 PodMetrics (io.kubernetes.client.custom.PodMetrics)2 V1Patch (io.kubernetes.client.custom.V1Patch)2 LeaderElectionConfig (io.kubernetes.client.extended.leaderelection.LeaderElectionConfig)2 LeaderElector (io.kubernetes.client.extended.leaderelection.LeaderElector)2