问题原文
原帖链接 · Héctor · CC BY-SA 3.0
I'm new in Kubernetes and there are some doubts I have. I have setup a Kubernetes cluster that consists of one master/node and one node. I have deployed a very simple NodeJS-based app, using Deployment kind with 2 replicas. Then, I have exposed it as a service by kubectl expose deployment my-app --port=80.
Now, my services looks like:
root@sw-kubernetes01:~# kubectl get services
NAME CLUSTER-IP EXTERNAL-IP PORT(S) AGE
my-app 192.168.100.167 <none> 80/TCP 10m
kubernetes 192.168.100.1 <none> 443/TCP 1h
Is it supposed that I should access to my app navigating to http://192.168.100.167:? I'm getting a timeout error. Otherwise, how can I get the external IP to access to the service externally?
I know that if I declare the service as type: NodePort, I can access my app using nodes IP, doesn't exist a way to auto-balance the load between pods?
已采纳解答
原帖链接 · Naveen · CC BY-SA 3.0
If you are working on local cluster you could use the --type=NodePort
kubectl expose deployment my-app --port=80 --type=NodePort
and then grep for the port
kubectl get svc my-service -o yaml | grep nodePort
and you could browse that using the cluster ip and the port which is output from the previous grep result.
摘自公开归档,保留原文语言,版式经整理,外部媒体与邮箱地址已移除。
