Which is the correct IP to run API tests on kubernetes cluster

2/19/2021

i have kubernetes cluster with pods which are type cluster IP. Which is the correct ip to shoot it if want to run integration tests IP:10.102.222.181 or Endpoints: 10.244.0.157:80,10.244.5.243:80

for example:

Type:              ClusterIP
IP Families:       <none>
IP:                10.102.222.181
IPs:               <none>
Port:              http  80/TCP
TargetPort:        80/TCP
Endpoints:         10.244.0.157:80,10.244.5.243:80
Session Affinity:  None
Events:            <none>
-- Alexa
api
kubernetes
testing

2 Answers

2/19/2021

IPs in the Endpoints are individual Pod IPs which are subject to change when new pods are created and replace the old pods. ClusterIP is stable IP which does not change unless you delete the service and recreate it. So recommendation is to use the clusterIP.

-- Arghya Sadhu
Source: StackOverflow

2/19/2021

If your test runner is running inside the cluster, use the name: of the Service as a host name. Don't use any of these IP addresses directly. Kubernetes provides a DNS service that will translate the Service's name to its address (the IP: from the kubectl describe service output), and the Service itself just forwards network traffic to the Endpoints: (individual pod addresses).

If the test runner is outside the cluster, none of these DNS names or IP addresses are reachable at all. For basic integration tests, it should be enough to kubectl port-forward service/its-name 12345:80, and then you can use http://localhost:12345 to reach the service (actually a fixed single pod from it). This isn't a good match for performance or load tests, and you'll either need to launch these from inside the cluster, or to use a NodePort or LoadBalancer service to make the service accessible from outside.

-- David Maze
Source: StackOverflow