Reputation: 129
I am using an external database that requires you to whitelist IPs for use, and I want a particular service in my k8s cluster to have access to this database.
I don't know which IP address to add to the whitelist. I tried whitelisting the IP
field from kubectl describe svc <service_name>
. That did not appear to work, so I then tried whitelisting the IP field from kubectl describe pod <pod_name>
, which also didn't work.
Ideally I would be able to whitelist the IP from the service instead of the pod, as the pod IP is not static.
Upvotes: 1
Views: 1845
Reputation: 2626
You cannot whitelist the service IP because there is a sorta of NAT that is connecting pods to pods and containers to containers etc (using etcd). But you can whitelist your global IP, which means you will have access to the database from every pod or service.
Read more about the network here
Upvotes: 2
Reputation: 18111
Services only route incoming traffic. Whitelisting a service IP for outgoing traffic doesn't make sense given that architecture. There is also not a 1:many correspondence between services and pods... multiple services could "select" (route to) the same pod.
The IP address for outgoing network traffic from pods ultimately depends on the network setup of the nodes the pods are running on.
Upvotes: 1