Skip to content

Commit

Permalink
fixed api client lookup
Browse files Browse the repository at this point in the history
  • Loading branch information
Katzen48 committed Dec 17, 2021
1 parent f6784b6 commit 4316d35
Showing 1 changed file with 16 additions and 14 deletions.
30 changes: 16 additions & 14 deletions shared/src/main/java/net/chrotos/ingress/minecraft/Watcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,9 +4,11 @@
import io.kubernetes.client.informer.SharedIndexInformer;
import io.kubernetes.client.informer.SharedInformerFactory;
import io.kubernetes.client.openapi.ApiClient;
import io.kubernetes.client.openapi.Configuration;
import io.kubernetes.client.openapi.apis.CoreV1Api;
import io.kubernetes.client.openapi.models.*;
import io.kubernetes.client.util.CallGeneratorParams;
import io.kubernetes.client.util.Config;
import okhttp3.OkHttpClient;

import java.io.IOException;
Expand All @@ -18,27 +20,27 @@ public class Watcher {
private SharedInformerFactory factory;

public Watcher(PodRessourceHandler handler) throws IOException {
ApiClient apiClient = Config.defaultClient();
Configuration.setDefaultApiClient(apiClient);

CoreV1Api v1Api = new CoreV1Api();
ApiClient apiClient = v1Api.getApiClient();
OkHttpClient httpClient =
apiClient.getHttpClient().newBuilder().readTimeout(0, TimeUnit.SECONDS).build();
apiClient.setHttpClient(httpClient);

factory = new SharedInformerFactory();
SharedIndexInformer<V1Pod> podInformer = factory.sharedIndexInformerFor(
(CallGeneratorParams params) -> {
return v1Api.listPodForAllNamespacesCall(
null,
null,
null,
"net.chrotos.ingress.minecraft/discover=true",
null,
null,
params.resourceVersion,
params.timeoutSeconds,
params.watch,
null);
},
(CallGeneratorParams params) -> v1Api.listPodForAllNamespacesCall(
null,
null,
null,
"net.chrotos.ingress.minecraft/discover=true",
null,
null,
params.resourceVersion,
params.timeoutSeconds,
params.watch,
null),
V1Pod.class,
V1PodList.class);

Expand Down

0 comments on commit 4316d35

Please sign in to comment.