Skip to content

Commit 1b9dd66

Browse files
authored
Merge pull request #1379 from yue9944882/doc/trim-controller-example
Trim controller example based on controller auto-configuration
2 parents b9be575 + f91bfa6 commit 1b9dd66

File tree

1 file changed

+0
-32
lines changed

1 file changed

+0
-32
lines changed

examples/src/main/java/io/kubernetes/client/examples/SpringControllerExample.java

Lines changed: 0 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -19,20 +19,14 @@
1919
import io.kubernetes.client.informer.SharedInformer;
2020
import io.kubernetes.client.informer.SharedInformerFactory;
2121
import io.kubernetes.client.informer.cache.Lister;
22-
import io.kubernetes.client.openapi.ApiClient;
2322
import io.kubernetes.client.openapi.models.V1Endpoints;
2423
import io.kubernetes.client.openapi.models.V1EndpointsList;
2524
import io.kubernetes.client.openapi.models.V1Node;
2625
import io.kubernetes.client.openapi.models.V1NodeList;
2726
import io.kubernetes.client.openapi.models.V1Pod;
2827
import io.kubernetes.client.openapi.models.V1PodList;
29-
import io.kubernetes.client.spring.extended.controller.KubernetesInformerConfigurer;
3028
import io.kubernetes.client.spring.extended.controller.annotation.*;
3129
import io.kubernetes.client.spring.extended.controller.factory.KubernetesControllerFactory;
32-
import io.kubernetes.client.spring.extended.controller.metrics.PrometheusScrapeEndpoint;
33-
import io.kubernetes.client.util.ClientBuilder;
34-
import java.io.IOException;
35-
import java.time.Duration;
3630
import org.springframework.beans.factory.annotation.Autowired;
3731
import org.springframework.beans.factory.annotation.Qualifier;
3832
import org.springframework.beans.factory.annotation.Value;
@@ -66,14 +60,6 @@ public CommandLineRunner commandLineRunner(
6660
};
6761
}
6862

69-
// *REQUIRED*
70-
// Configurer components that registers informers to the informer-factory in the context.
71-
@Bean
72-
public KubernetesInformerConfigurer kubernetesInformerConfigurer(
73-
ApiClient apiClient, SharedInformerFactory sharedInformerFactory) {
74-
return new KubernetesInformerConfigurer(apiClient, sharedInformerFactory);
75-
}
76-
7763
// *REQUIRED*
7864
// factorybean to crete controller
7965
@Bean("node-printing-controller")
@@ -82,30 +68,12 @@ public KubernetesControllerFactory kubernetesReconcilerConfigurer(
8268
return new KubernetesControllerFactory(sharedInformerFactory, reconciler);
8369
}
8470

85-
// *OPTIONAL*
86-
// Injecting and customize your ApiClient, if not specified, fallbacks to {@link
87-
// io.kubernetes.client.util.ClientBuilder#standard}
88-
@Bean
89-
public ApiClient myApiClient() throws IOException {
90-
ApiClient apiClient = ClientBuilder.standard().build();
91-
return apiClient.setHttpClient(
92-
apiClient.getHttpClient().newBuilder().readTimeout(Duration.ZERO).build());
93-
}
94-
9571
// *REQUIRED*
9672
// Injecting your SharedInformerFactory class annotated `@KubernetesInformers`
9773
@Bean("sharedInformerFactory")
9874
public SharedInformerFactory sharedInformerFactory() {
9975
return new MySharedInformerFactory();
10076
}
101-
102-
// *OPTIONAL*
103-
// Enabling prometheus scraping endpoint at `/actuator/prometheus`
104-
// SHOULD set `management.endpoints.web.exposure.include=prometheus` property.
105-
@Bean
106-
public PrometheusScrapeEndpoint prometheusScrapeEndpoint() {
107-
return new PrometheusScrapeEndpoint();
108-
}
10977
}
11078

11179
@KubernetesInformers({ // Defining what resources is the informer-factory actually watching.

0 commit comments

Comments
 (0)