Within same stateful set afaik you can interact between particular pods just by referencing it directly, like this - pod-{0..N-1}.my_service.my_namespace.svc.cluster.local
.
(some more info here: https://kubernetes.io/docs/concepts/workloads/controllers/statefulset/#stable-network-id).
However in my case I have 2 different stateful sets, and I want to be able statefullset1-pod-0
from 1st stateful set to interact with statefullset2-pod-0
from 2nd stateful set(and also statefullset1-pod-1
with statefullset2-pod-1
, and so on). Is it possible? If yes, can you please provide example configuration?