我已经按照the tutorial中的说明在Minikube上设置了“ hello world”入口。唯一的区别-我删除了特定的主机名,改为使用'*'。但是,它似乎只能与minikube(minikube addons enable ingress
)提供的入口控制器一起使用。当我尝试禁用它并改用helm install nginx-ingress stable/nginx-ingress
时,我将无法再访问Hello World示例网站。我收到的是“拒绝连接”错误:
$ kubectl get ingress
NAME HOSTS ADDRESS PORTS AGE
example-ingress * 192.168.64.6 80 6m23s
$ minikube ip
192.168.64.6
$ curl -iv "192.168.64.6"
* Rebuilt URL to: 192.168.64.6/
* Hostname was NOT found in DNS cache
* Trying 192.168.64.6...
* connect to 192.168.64.6 port 80 failed: Connection refused
* Failed to connect to 192.168.64.6 port 80: Connection refused
* Closing connection 0
curl: (7) Failed to connect to 192.168.64.6 port 80: Connection refused
如果我切换回内置插件,它将再次起作用:
$ helm uninstall nginx-ingress
release "nginx-ingress" uninstalled
$ minikube addons enable ingress
✅ ingress was successfully enabled
$ curl -iv "192.168.64.6"
* Rebuilt URL to: 192.168.64.6/
* Hostname was NOT found in DNS cache
* Trying 192.168.64.6...
* Connected to 192.168.64.6 (192.168.64.6) port 80 (#0)
> GET / HTTP/1.1
> User-Agent: curl/7.38.0
> Host: 192.168.64.6
> Accept: */*
>
< HTTP/1.1 200 OK
HTTP/1.1 200 OK
* Server openresty/1.15.8.2 is not blacklisted
< Server: openresty/1.15.8.2
Server: openresty/1.15.8.2
< Date: Sun, 09 Feb 2020 07:06:58 GMT
Date: Sun, 09 Feb 2020 07:06:58 GMT
< Content-Type: text/plain; charset=utf-8
Content-Type: text/plain; charset=utf-8
< Content-Length: 59
Content-Length: 59
< Connection: keep-alive
Connection: keep-alive
<
Hello, world!
Version: 1.0.0
Hostname: web-9bbd7b488-wsvsw
* Connection #0 to host 192.168.64.6 left intact
是否可以在minikube上正确安装使用此头盔图?
答案 0 :(得分:0)
我禁用了入口插件,并使用您提到的头盔图表安装了nginx入口。我对其进行了测试,并为您提供了解决方案。
运行时:
$ kubectl get services nginx-ingress-controller
您应该看到以下输出:
NAME TYPE CLUSTER-IP EXTERNAL-IP PORT(S) AGE
nginx-ingress-controller LoadBalancer 10.96.245.213 <pending> 80:30240/TCP,443:31224/TCP 50s
请注意,EXTERNAL-IP处于待处理状态。
minikube不会自行分配此IP,您需要手动进行。
运行kubectl edit svc nginx-ingress-controller
并在externalIPs
下添加spec:
字段,如下所示:
spec:
externalIPs:
- 192.168.39.241 # minikube ip
现在,让我们看看为什么会这样。 通常,在创建类型为LoadBalancer的服务时在云环境中运行kubernetes时,云控制器会创建一个负载均衡器并更新服务的IP,但是由于您是在minikube上运行它的,而其中没有特定于云的功能正在起作用,因此您需要添加地址手动。
这可以通过与群集相关联的任何接口的任何IP进行,因此在具有更多节点时也应该可以使用。您可以添加节点的任何接口的IP,并且kuberentes将在此接口上绑定端口,从现在开始,您可以向其发送流量,并将其转发到适当的服务/吊舱。
让我知道它很有帮助。