【问题标题】:Querying Remote State Stores in Kubernetes (Interactive Queries)查询 Kubernetes 中的远程状态存储(交互式查询)
【发布时间】:2020-07-31 14:18:52
【问题描述】:

对于在 Kubernetes 中部署的应用程序实例之间查询远程状态存储有什么建议吗?我们的应用程序实例部署有 2 个或更多副本。

基于文档 https://kafka.apache.org/10/documentation/streams/developer-guide/interactive-queries.html#id7

streams.allMetadataForStore("word-count")
    .stream()
    .map(streamsMetadata -> {
        // Construct the (fictituous) full endpoint URL to query the current remote application instance
        String url = "http://" + streamsMetadata.host() + ":" + streamsMetadata.port() + "/word-count/alice";
        // Read and return the count for 'alice', if any.
        return http.getLong(url);
    })
    .filter(s -> s != null)
    .findFirst();

streamsMetadata.host() 会产生 POD IP 吗?如果是这样,是否允许从这个 pod 调用另一个 pod?这是正确的方法吗?

【问题讨论】:

    标签: kubernetes apache-kafka apache-kafka-streams


    【解决方案1】:

    streamsMetadata.host()

    此方法返回您通过application.server 配置参数配置的任​​何内容。即,每个应用程序实例(在您的情况下是每个 POD)都必须设置此配置以提供如何访问它的信息(例如,它的 IP 和端口)。 Kafka Streams 会为您将此信息分发给所有应用程序实例。

    您还需要相应地配置您的 POD 以允许通过指定端口发送/接收查询请求。这部分是您需要自己编写的附加代码,即某种“查询路由层”。 Kafka Streams 仅内置支持查询本地状态和分发关于哪个状态托管在哪里的元数据;但没有内置的删除查询支持。

    查询路由层的示例实现 (WordCountInteractiveQueries) 可以在 Github 上找到:https://github.com/confluentinc/kafka-streams-examples

    我还建议您查看文档和博客文章:

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2020-02-03
      • 1970-01-01
      • 2012-08-25
      • 1970-01-01
      • 2021-11-08
      • 1970-01-01
      • 2020-12-02
      • 1970-01-01
      相关资源
      最近更新 更多