-
Notifications
You must be signed in to change notification settings - Fork 2
Open
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed
Milestone
Description
Describe the feature
When using kubernetes services, it is usual that the same service provides different ports. Each of this port is used for different purposes, like handling traffic, management, metrics, etc.
After testing the ServiceResolver in vertx 5.0.0, using kuberntes Service Resolver:
AddressResolver resolver = KubeResolver.create(new KubeResolverOptions());
LoadBalancer loadBalancer = LoadBalancer.ROUND_ROBIN;
client = vertx
.httpClientBuilder()
.withLoadBalancer(loadBalancer)
.withAddressResolver(resolver)
.build();
...
ServiceAddress serviceAddress = ServiceAddress.of("service-name");
Future<HttpClientRequest> fut = client.request(new RequestOptions()
.setMethod(HttpMethod.GET)
.setServer(serviceAddress)
.setURI("/"));
I discovered that when request is sent to service "service-name" to specific port (e.g. 8080), request ends in another port (e.g. 10002), just because the service is providing several ports and just this "10002" is the first one.
It should be nice that when the "ServiceAddress" is created, it could specify a name and a port(s), so when the KubeServiceState is created, it only adds the endpoints for that port.
class KubeServiceState {
...
void handleEndpoints(JsonObject item) {
...
for (int k = 0;k < ports.size();k++) {
JsonObject port = ports.getJsonObject(k);
int podPort = port.getInteger("port");
// i.e. something like this!!
if (serviceAddress.ports().contains(podPort)){
for (String podIp : podIps) {
SocketAddress podAddress = SocketAddress.inetSocketAddress(podPort, podIp);
builder = builder.addServer(podAddress, podIp + "-" + podPort);
}
}
...
Contribution
No response
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or requestgood first issueGood for newcomersGood for newcomershelp wantedExtra attention is neededExtra attention is needed