I have a REST-api in one pod that needs to whitelist all hostnames or ips that connects to it. In another deployment/pod I have my own kotlin program that tries to connect to the REST-api
Both deployment are exposed with ClusterIp services. I can do a "ping" request. So that works fine.
I thougt that one way was to use the service dns-name of the kotlin service. But that ip is not the same as that from the kotlin-pods.
The REST-api doesn't support subnet masks. And I can't really add all ips in the k8s cluster.
You need a way to have reliable IPs for your pods or a reliable host name. Your best option for that is statefulSets. The stateful set will try to maintain the pods state, including the IP if possible. But it also allows you to set a hostname for the pod instead of just the service