Skip to content

Commit

Permalink
Configure watcher with namespaces and align tests
Browse files Browse the repository at this point in the history
Related to smallrye#373
  • Loading branch information
aureamunoz committed Jul 11, 2023
1 parent d1d4d91 commit a736e13
Show file tree
Hide file tree
Showing 4 changed files with 308 additions and 329 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@
import io.fabric8.kubernetes.api.model.EndpointPort;
import io.fabric8.kubernetes.api.model.EndpointSubset;
import io.fabric8.kubernetes.api.model.Endpoints;
import io.fabric8.kubernetes.api.model.EndpointsList;
import io.fabric8.kubernetes.api.model.ObjectMeta;
import io.fabric8.kubernetes.api.model.Pod;
import io.fabric8.kubernetes.client.Config;
import io.fabric8.kubernetes.client.ConfigBuilder;
import io.fabric8.kubernetes.client.KubernetesClient;
import io.fabric8.kubernetes.client.KubernetesClientBuilder;
import io.fabric8.kubernetes.client.dsl.AnyNamespaceOperation;
import io.fabric8.kubernetes.client.dsl.Resource;
import io.fabric8.kubernetes.client.informers.ResourceEventHandler;
import io.smallrye.mutiny.Uni;
import io.smallrye.stork.api.Metadata;
Expand Down Expand Up @@ -84,7 +87,13 @@ public KubernetesServiceDiscovery(String serviceName, KubernetesConfiguration co
this.client = new KubernetesClientBuilder().withConfig(k8sConfig).build();
this.vertx = vertx;
this.secure = isSecure(config);
client.endpoints().inform(new ResourceEventHandler<Endpoints>() {
AnyNamespaceOperation<Endpoints, EndpointsList, Resource<Endpoints>> endpointsOperation;
if (allNamespaces) {
endpointsOperation = client.endpoints().inAnyNamespace();
} else {
endpointsOperation = client.endpoints().inNamespace(namespace);
}
endpointsOperation.inform(new ResourceEventHandler<>() {
@Override
public void onAdd(Endpoints obj) {
LOGGER.info("Endpoint added: {}", obj.getMetadata().getName());
Expand Down
Loading

0 comments on commit a736e13

Please sign in to comment.