OpenShift / OKD Specify URL for each Pod Replica

3/11/2019

I am new to the Open shift / OKD. I am running Strimzi on top of open shift.

I have deployed an application which includes Rest API. This Application has Rest Api and One can control Producer and Consumer from rest Api. I have replicated the POD of my application to 3.

To have better control we want to have fire query to each pod replica personally. ex. pod-replica1 of my application kafka-testing to start the producer.pod-replica2 of my application kafka-testing to start the consumer and so on.

How can we access the each pod-replica individually to perform the test? We can't create multiple application with same source.

let me know if something is not clear.

Thanks A Lot

-- Akash Sethi
kubernetes
okd
openshift
openshift-origin
strimzi

2 Answers

3/12/2019

If your application also runs in OpenShift, run oc get svc to find names of each broker. Note these names are only accessible inside OpenShift cluster.

For example, if oc get svc returns:

> oc get svc
NAME                                  TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)                      AGE
my-cluster-kafka-0                    ClusterIP   172.30.210.241   <none>        9094/TCP                     109d
my-cluster-kafka-1                    ClusterIP   172.30.39.25     <none>        9094/TCP                     109d
my-cluster-kafka-2                    ClusterIP   172.30.93.193    <none>        9094/TCP                     109d

, you can access kafka-0 by my-cluster-kafka-0 or my-cluster-kafka-0.<pod_namespace>.svc.cluster.local

If your application runs outsides OpenShift, please configure strimzi external listeners. Among the three options to setup external listeners, NodePort may be easier if you run on-premise OKD.

-- ccshih
Source: StackOverflow

7/4/2019

If you have a statefulset with a headless service, then you can access each pod with $(podname).$(service name).$(namespace).svc

read more about stable network id here

-- Amir Masud Zare Bidaki
Source: StackOverflow