I am deploying the microservice benchmark here using helm charts.
However, when I uninstall the helm chart and re-install (basically, equivalent to re-deploying all kubernetes pods), the IP addresses change. Specifically, the IP addresses keep on increasing on subsequent runs. Here is the workflow:
$ helm install social-network ./socialnetwork
$ kubectl get pods -o custom-columns=PodName:.metadata.name,PodIP:.status.podIP
PodName PodIP
compose-post-service-866f6d7b74-rzqh6 10.244.0.198
home-timeline-redis-7994f7cb85-8fjlh 10.244.0.199
...
$ helm uninstall social-network
...
$ helm install social-network ./socialnetwork
$ kubectl get pods -o custom-columns=PodName:.metadata.name,PodIP:.status.podIP
PodName PodIP
compose-post-service-866f6d7b74-2d4jf 10.244.0.254
home-timeline-redis-7994f7cb85-dc8jn 10.244.0.250
My concern is that for my development and testing, I need to re-deploy the benchmark several times.
Is there a limit to how many times I can restart the application? If so, how can I force Kubernetes to reuse the same IP addresses?
2
Answers
No, there is no limit.
There is no need for that since inside the CNI (Container Network Interface, your network plugin e.g. Calico, Cilium, …) there is an IPAM (IP Address Management) running, which takes care of assigning a subnet to a node, which then is used to give a Pod an IP via DHCP.
If you would like to connect to your pod, you should use a Kubernetes Service
Kubernetes assigns a new IP to every started POD. That is done by design, so you should not make any assumptions on the POD IP, but rather use Kubernetes Service (or possibly Pod’s hostname) for communication.