@Nullable
  @Override
  public NameResolver newNameResolver(URI targetUri, Attributes params) {
    if (SCHEME.equals(targetUri.getScheme())) {
      String targetPath = Preconditions.checkNotNull(targetUri.getPath(), "targetPath");
      Preconditions.checkArgument(targetPath.startsWith("/"),
          "the path component (%s) of the target (%s) must start with '/'", targetPath, targetUri);

      String[] parts = targetPath.split("/");
      if (parts.length != 4) {
        throw new IllegalArgumentException("Must be formatted like kubernetes:///{namespace}/{service}/{port}");
      }

      try {
        int port = Integer.valueOf(parts[3]);
        return new KubernetesNameResolver(parts[1], parts[2], port, params, GrpcUtil.TIMER_SERVICE,
            GrpcUtil.SHARED_CHANNEL_EXECUTOR);
      } catch (NumberFormatException e) {
        throw new IllegalArgumentException("Unable to parse port number", e);
      }
    } else {
      return null;
    }
  }
Usage: kubernetes:///{namespace}/{service}/{port}
E.g.: kubernetes:///default/echo-server/8080
kubernetes-lb-example/echo-client-lb-api/src/main/java/com/example/grpc/client/KubernetesNameResolverProvider.java