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 2ca391a commit 23f79f6
Show file tree
Hide file tree
Showing 5 changed files with 310 additions and 330 deletions.
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@
<!-- override the testcontainers version with the newest one -->
<version.testcontainers>1.18.3</version.testcontainers>

<kubernetes-client.version>6.7.2</kubernetes-client.version>
<kubernetes-client.version>6.8-SNAPSHOT</kubernetes-client.version>
<!-- we cannot update to 2.x as jboss-logging does not support SLF4J 2 for now -->
<version.slf4j>1.7.36</version.slf4j>
<version.mockito>5.2.0</version.mockito>
Expand Down
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,14 @@ 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 23f79f6

Please sign in to comment.