Is it possible to assign static ip to a stateful container in kubernates? if yes how it can be

3/19/2019

I have two container deployed in kubernates, each container has stateful application which is tightly coupled with container IP & I need to have communication between two (application is not trusting service ip). Therefore I need to assign static IP to container. Could anyone help me here ? Thanks in advance

-- Vishnu
docker
ibm-cloud-private
kubernetes
stateful

1 Answer

3/19/2019

A static IP cannot be assigned to a Pod.

Withing StatefulSet, you can refer to a stable network ID

If you are using GKE for your cluster, it supports loadBalancerIP. So, at some point, you can rely on this service. Just mark the auto-assigned IP as static first.

apiVersion: v1
kind: Service
spec:
  type: LoadBalancer
  loadBalancerIP: 10.10.10.10
-- A_Suh
Source: StackOverflow