minikube:无法连接本地部署的 nginx 服务

minikube : not able to connect a locally deployed nginx service

我已经在我的 ubuntu 16.04 机器上安装了 minikube 并启动了一个集群,并显示一条消息

"Kubernetes is available at https://192.168.99.100:443"

接下来,我用下面的命令部署了nginx服务

> kubectl.sh run my-nginx --image=nginx --replicas=2 --port=80 --expose

> kubectl.sh get  pods -o wide
NAME                        READY     STATUS    RESTARTS   AGE       NODE
my-nginx-2494149703-8jnh4   1/1       Running   0          13m       127.0.0.1
my-nginx-2494149703-q09be   1/1       Running   0          13m       127.0.0.1

> kubectl.sh get  services -o wide
NAME         CLUSTER-IP   EXTERNAL-IP   PORT(S)   AGE       SELECTOR
kubernetes   10.0.0.1     <none>        443/TCP   14m       <none>
my-nginx     10.0.0.83    <none>        80/TCP    13m       run=my-nginx

> kubectl.sh get  nodes -o wide
NAME        STATUS    AGE
127.0.0.1   Ready     16m

问题:

1) node 127.0.0.1 是我的本地开发机器吗?这让我最困惑。

2)我的理解是否正确:集群(节点、kubernetes API服务器)的内网IP地址为10.0.0.x,对应的外网IP地址为192.168.99.x.然后 2 pods 的 IP 将在 10.0.1.x 和 10.0.2.x ?

范围内

3) 为什么没有服务的外部IP?甚至没有,对于 kubernetes 服务。这里的192.168.99.43不是外网IP吗?

4) 最重要的是,如何从笔记本电脑连接到 nginx 服务?

1) Is node 127.0.0.1 my local development machine? This has got me confused me the most.

当一个节点注册时,您提供要注册的 IP 或名称。默认情况下,节点只是注册 127.0.0.1。这是在引用您的 VM 运行 linux,而不是您的主机。

2) Is my following understanding correct: The cluster (nodes, kubernetes API server) has internal IP addresses in 10.0.0.x and their corresponding external IP addresses are 192.168.99.x. The 2 pods will then have IPs in the range like 10.0.1.x and 10.0.2.x ?

是的,10.0.0.x 网络是您的覆盖网络。 192.168.99.x 是您的 "public" 地址,在集群外部可见。

3) Why is the external IP for the services not there? Not even, for the kubernetes service. Isn't the 192.168.99.43 an external IP here?

外部 IP 通常用于通过特定 IP 进入流量。 kubernetes 服务使用 clusterIP 服务类型,这意味着它只对内部集群可见。

4) Most importantly, how do I connect to the nginx service from my laptop?

查看 nginx 服务最简单的方法是输入 NodePort,然后部署该服务。之后,描述服务以获取分配的端口(或者在您创建后它也会告诉您)。然后点击您的 VM 的 IP 并提供自动分配的 NodePort。

e.g. http://192.168.99.100:30001