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?
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).
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.
kubectl get service/servicename -o jsonpath='{.spec.clusterIP}'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With