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?
kubectl get service/servicename -o jsonpath='{.spec.clusterIP}'
kubectl get svc <your-service> -o yaml | grep ip
The IP should be the external IP of your master-node. If you're running locally it should be localhost or your VM.
Of course with the given port added.
127.0.0.1:80
for example.
PS: Be sure you have containers/pods running already by running:
kubectl get pods
If this doesn't work, I would suggest proxying it, for test-purposes at least.
There are a couple of ways to do this:
kubectl get svc <service-name> -o yaml | grep clusterIP
or for example:
kubectl describe svc <service-name> | grep IP