Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to get the service IP in Kubernetes?

I ran a local cluster according to its official doc here. I followed the steps and it worked properly until I set a replica and tried to exposed it. I mean:

./kubectl expose rc nginx --port=80

the output is this:

NAME      LABELS      SELECTOR    IP(S)     PORT(S)
nginx     run=nginx   run=nginx             80/TCP

When I tried another time it sayed the the same service is running. How can I figure out the IP?

like image 952
Hadi Avatar asked Aug 25 '15 10:08

Hadi


People also ask

What is service IP in Kubernetes?

A Kubernetes service is a logical abstraction for a deployed group of pods in a cluster (which all perform the same function). Since pods are ephemeral, a service enables a group of pods, which provide specific functions (web services, image processing, etc.) to be assigned a name and unique IP address (clusterIP).

How do I find services in Kubernetes?

With Kubernetes you don't need to modify your application to use an unfamiliar service discovery mechanism. Kubernetes gives Pods their own IP addresses and a single DNS name for a set of Pods, and can load-balance across them.


1 Answers

kubectl get service/servicename -o jsonpath='{.spec.clusterIP}'
like image 102
Leopd Avatar answered Oct 16 '22 17:10

Leopd