<p>Are there any recommendations on querying remote state stores between application instances that are deployed in Kubernetes? Our application instances are deployed with 2 or more replicas.</p>

<p>Based on documentation
<a href="https://kafka.apache.org/10/documentation/streams/developer-guide/interactive-queries.html#id7" rel="nofollow noreferrer">https://kafka.apache.org/10/documentation/streams/developer-guide/interactive-queries.html#id7</a></p>

<pre><code>streams.allMetadataForStore("word-count")
    .stream()
    .map(streamsMetadata -&gt; {
        // 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 -&gt; s != null)
    .findFirst();
</code></pre>

<p>will streamsMetadata.host() result in the POD IP? And if it does, will the call from this pod to another be allowed? Is this the correct approach?</p>

srini
<blockquote>
  <p>streamsMetadata.host() </p>
</blockquote>

<p>This method returns whatever you configured via <code>application.server</code> configuration parameter. I.e., each application instance (in your case each POD), must set this config to provide the information how it is reachable (e.g., its IP and port). Kafka Streams distributes this information for you to all application instances.</p>

<p>You also need to configure your PODs accordingly to allow sending/receiving query request via the specified port. This part is additional code you need to write yourself, i.e., some kind of "query routing layer". Kafka Streams has only built-in support to query local state and to distribute the metadata about which state is hosted where; but there is no built-in remove query support.</p>

<p>An example implementation (<code>WordCountInteractiveQueries</code>) of a query routing layer can be found on Github: <a href="https://github.com/confluentinc/kafka-streams-examples" rel="nofollow noreferrer">https://github.com/confluentinc/kafka-streams-examples</a></p>

<p>I would also recommend to checkout the docs and blog post:</p>

<ul>
<li><a href="https://docs.confluent.io/current/streams/developer-guide/interactive-queries.html" rel="nofollow noreferrer">https://docs.confluent.io/current/streams/developer-guide/interactive-queries.html</a></li>
<li><a href="https://www.confluent.io/blog/unifying-stream-processing-and-interactive-queries-in-apache-kafka/" rel="nofollow noreferrer">https://www.confluent.io/blog/unifying-stream-processing-and-interactive-queries-in-apache-kafka/</a></li>
</ul>
