1

We have a Kubernetes cluster with three pod running, i want to know what are the RPC endpoint we need to provide in application.server to make interactive query work.

So we have a use case where we need to query state-store with gRPC server. while creating gRPC server we are giving 50052 as a port..

but i am not able to get what should be the value of application.server as it take Host:Port

for host do we need to give the endpoint ip of each pod and port as 50052?

For Example below:

$>kubectl get ep
NAME                    ENDPOINTS                       AGE
myapp   10.8.2.85:8080,10.8.2.88:8080   10d


Pod1 -> 10.8.2.85:8080
Pod2 -> 10.8.2.88:8080

So the value of application.server will be?

 1. 10.8.2.85:50052 (port is what i am giving in gRPC server)
 2. 10.8.2.88:50052 (port is what i am giving in gRPC server)

If above application.server values are correct then How to get this POD IP dynamically?

Mohit Singh
  • 401
  • 1
  • 10
  • 30
  • Hello, have you checked the Headless Service? You can read more about it here: *[Kubernetes.io: Docs: Concepts: Headless service](https://kubernetes.io/docs/concepts/services-networking/service/#headless-services)* – Dawid Kruk Aug 13 '20 at 15:09

1 Answers1

0

You can make your pods IP address available as an environment variable and then reference the environment variable in your application.yml

See: https://kubernetes.io/docs/tasks/inject-data-application/environment-variable-expose-pod-information/

pod.yml

apiVersion: v1
kind: Pod
metadata:
  name: kafka-stream-app
spec:
  containers:
    - name: kafka-stream-app
      #... some more configs
      env:
        - name: MY_POD_IP
          valueFrom:
            fieldRef:
              fieldPath: status.podIP

application.yml

spring:
  cloud:
    stream:
      kafka:
        streams:
          binder:
            configuration:
              application.server: ${MY_POD_IP}:50052
m-kay
  • 260
  • 1
  • 11