io.fabric8.kubernetes.client.informers.SharedInformerFactory Java Examples

The following examples show how to use io.fabric8.kubernetes.client.informers.SharedInformerFactory. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: PodSetControllerTest.java    From podsetoperatorinjava with Apache License 2.0 6 votes vote down vote up
@Test
@DisplayName("Should create pods for with respect to a specified PodSet")
public void testReconcile() throws InterruptedException {
    // Given
    String testNamespace = "ns1";
    PodSet testPodSet = getPodSet("example-podset", testNamespace, "0800cff3-9d80-11ea-8973-0e13a02d8ebd");
    server.expect().post().withPath("/api/v1/namespaces/" + testNamespace + "/pods")
            .andReturn(HttpURLConnection.HTTP_CREATED, new PodBuilder().withNewMetadata().withName("pod1-clone").endMetadata().build())
            .times(testPodSet.getSpec().getReplicas());
    KubernetesClient client = server.getClient();

    SharedInformerFactory informerFactory = client.informers();
    MixedOperation<PodSet, PodSetList, DoneablePodSet, Resource<PodSet, DoneablePodSet>> podSetClient = client.customResources(podSetCustomResourceDefinition, PodSet.class, PodSetList.class, DoneablePodSet.class);
    SharedIndexInformer<Pod> podSharedIndexInformer = informerFactory.sharedIndexInformerFor(Pod.class, PodList.class, RESYNC_PERIOD_MILLIS);
    SharedIndexInformer<PodSet> podSetSharedIndexInformer = informerFactory.sharedIndexInformerForCustomResource(podSetCustomResourceDefinitionContext, PodSet.class, PodSetList.class, RESYNC_PERIOD_MILLIS);
    PodSetController podSetController = new PodSetController(client, podSetClient, podSharedIndexInformer, podSetSharedIndexInformer, testNamespace);

    // When
    podSetController.reconcile(testPodSet);

    // Then
    RecordedRequest recordedRequest = server.getLastRequest();
    assertEquals("POST", recordedRequest.getMethod());
    assertTrue(recordedRequest.getBody().readUtf8().contains(testPodSet.getMetadata().getName()));
}
 
Example #2
Source File: ManagedOpenShiftClient.java    From kubernetes-client with Apache License 2.0 5 votes vote down vote up
@Override
public SharedInformerFactory informers() { return delegate.informers(); }
 
Example #3
Source File: DefaultKubernetesClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public SharedInformerFactory informers() {
  return new SharedInformerFactory(ForkJoinPool.commonPool(), httpClient, getConfiguration());
}
 
Example #4
Source File: DefaultKubernetesClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public SharedInformerFactory informers(ExecutorService executorService) {
  return new SharedInformerFactory(executorService, httpClient, getConfiguration());
}
 
Example #5
Source File: ManagedKubernetesClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public SharedInformerFactory informers() {
  return delegate.informers();
}
 
Example #6
Source File: ManagedKubernetesClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public SharedInformerFactory informers(ExecutorService executorService) {
  return delegate.informers(executorService);
}
 
Example #7
Source File: ManagedOpenShiftClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public SharedInformerFactory informers(ExecutorService executorService) { return delegate.informers(executorService); }
 
Example #8
Source File: DefaultOpenShiftClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public SharedInformerFactory informers() { return new SharedInformerFactory(ForkJoinPool.commonPool(), httpClient, getConfiguration()); }
 
Example #9
Source File: DefaultOpenShiftClient.java    From kubernetes-client with Apache License 2.0 4 votes vote down vote up
@Override
public SharedInformerFactory informers(ExecutorService executorService) { return new SharedInformerFactory(executorService, httpClient, getConfiguration()); }
 
Example #10
Source File: KubernetesClient.java    From kubernetes-client with Apache License 2.0 2 votes vote down vote up
/**
 * Get an instance of Kubernetes Client informer factory. It allows you to construct and
 * cache informers for API types. With it you can subscribe to all the events related to
 * your Kubernetes type. It's like watch but a bit organized.
 *
 * @return SharedInformerFactory object
 */
SharedInformerFactory informers();
 
Example #11
Source File: KubernetesClient.java    From kubernetes-client with Apache License 2.0 2 votes vote down vote up
/**
 * Get an instance of Kubernetes Client informer factory. It allows you to construct and
 * cache informers for API types. With it you can subscribe to all the events related to
 * your Kubernetes type. It's like watch but a bit organized.
 *
 * @param executorService thread pool for informer factory
 * @return SharedInformerFactory object
 */
SharedInformerFactory informers(ExecutorService executorService);