0

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.

  • It seems like you need to expose the application pod using Type LoadBalancer instead of Type ClusterIP. Although both services are used for communication purposes, since you needed a single(specific) IP address, Type loadBalancer suits more. Difference between these services are explained here. – Digil Sep 6 '19 at 3:52
  • You could visit this similar discussion thread as well. I hope this helps. – Digil Sep 6 '19 at 3:53
  • Also found this source-ip. Looks like it's not possible when running kube-proxy in iptables mode. Anyway, I solved my problem using an nginx sidecar in the same pod as the REST-api. – Arlukin Sep 7 '19 at 14:42
  • Since you find a solid resolution for your concern please post the same as an answer for the visibility of other community members. This might help them. – Digil Sep 9 '19 at 20:06
1

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.