Statefulset and Headless service

In Kubernetes , we need a set up where :

  1. We need to run 3 pods on three different Node/Vms i.e. one pod per Node/VM.
  2. We have got a EHCache replication using RMI (EHCache configuration) where if any of the data on a POD changes , we need to replicate the same data across rest of the two pods running on two different VMs.

I guess the first point could be achived by POD affinity/anti-affinity but we have the problem with second point reg. the EHCache replication.

Currently without Kubernetes , in our local env. to replicate the data on rest of the two nodes , we have a EHCache configuration to keep the IP address and Port of rest of the two Nodes so that we could connect those two nodes and replicate the data.

I understand that , in kuberenetes , using statefulset and headless service we could connect to specific POD as the name of the POD will be fixed. But my question is if the same POD restart or all the POD restart , the name of the POD on a given Node will not change e.g. earlier it might be POD-0 and now it could be POD-1 on the same node ? if that changes , then my EHCache replication will fail.

Let me know if we have any solution for this.