Module io.inverno.mod.discovery.http.k8s


module io.inverno.mod.discovery.http.k8s

The Inverno framework HTTP Kubernetes discovery module provides services to resolve HTTP services in a Kubernetes cluster.

The module defines the following sockets:

httpClient (required)
the HTTP client
configuration
the HTTP discovery meta module configuration

It exposes the following beans:

configuration
the HTTP discovery meta module configuration
k8sEnvHttpDiscoveryService
the Kubernetes environment HTTP discovery service

The Kubernetes environment HTTP discovery service resolves services from service environment variables, a Kubernetes environment HTTP service URI being of the form k8s-env://<service_name>.


 HttpClient httpClient = ...

 K8s k8sDiscoveryModule = new K8s.Builder(httpClient).build();
 try {
     k8sDiscoveryModule.start();

     httpClient.exchange("/")
         .flatMap(exchange -> k8sDiscoveryModule.k8sEnvHttpDiscoveryService().resolve(ServiceId.of("k8s-env://sampleService")) // resolve the meta service
              .flatMap(service -> service.getInstance(exchange))                                                               // get an instance
              .map(serviceInstance -> serviceInstance.bind(exchange))                                                          // bind the exchange to the instance
          )
          .flatMap(Exchange::response)                                                                                         // send the request
          ...
 }
 finally {
     k8sDiscoveryModule.stop();
 }
 
Since:
1.12
Author:
Jeremy Kuhn