Will the pod IP change without the pod being recreated

164 Views Asked by At

I need a way to directly talk to a pod from another pod within the same namespace. When a pod is starting the IP details will be sent to the second pod. So as long as it doesn't change without the pod being recreated I'm good. So my question would be, will the Pod's IP change without pod being recreated.

PS: I'm trying to avoid Statefulsets for now.

1

There are 1 best solutions below

4
Harsh Manvar On BEST ANSWER

Less chances there without re-create, However few chances when IP gets changed which you can not control.

  • Node failed or Rescheduling
  • Network changes

The best option is to use the statefulset but you mentioned you not inclined toward it.

If you just using POD without any controller like Deployment you can use the Hostname & Subdomain in the spec section.

spec:
  hostname: pod-data
  subdomain: data-subdomain

Which you can resolve in another POD, however, if you use it in Deployment it will work but it's better to use service. As the hostname will be the same across all replicas of deployment.

i am not able to understand actually the requirement to use POD IP, you can keep single replicas of POD handled by deployment backed by service.