【问题标题】:Unable to establish connection with minikube cluster from host无法从主机建立与 minikube 集群的连接
【发布时间】:2017-09-04 22:07:25
【问题描述】:

我在远程裸机实例上关注this fission tutorial。当我运行 curl $FISSION_URL (http://192.168.42.152:31313) 时,它不会返回。我运行了以下命令:

  1. sudo lsof -i | grep 192.168.42.152。

ntpd 2860 ntp 32u IPv4 55241 0t0 UDP 192.168.42.1:ntp

dnsmasq 3392 libvirt-dnsmasq 5u IPv4 33870 0t0 UDP 192.168.42.1:域

dnsmasq 3392 libvirt-dnsmasq 6u IPv4 33871 0t0 TCP 192.168.42.1:domain (LISTEN)

  1. curl -vvv $FISSION_URL.

重建 URL 至:http://192.168.42.152:31313/

正在尝试 192.168.42.152...

连接到 192.168.42.152 (192.168.42.152) 端口 31313 (#0)

GET / HTTP/1.1

主机:192.168.42.152:31313

用户代理:curl/7.47.0

接受:/

  1. sudo iptables -L

    Chain INPUT (policy ACCEPT)
    target     prot opt source               destination         
    ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
    ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
    ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootps
    ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:bootps
    ACCEPT     udp  --  anywhere             anywhere             udp dpt:domain
    ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:domain
    ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootps
    ACCEPT     tcp  --  anywhere             anywhere             tcp dpt:bootps
    Chain FORWARD (policy ACCEPT)
    target     prot opt source               destination         
    DOCKER-ISOLATION  all  --  anywhere             anywhere            
    DOCKER     all  --  anywhere             anywhere            
    ACCEPT     all  --  anywhere             anywhere             ctstate RELATED,ESTABLISHED
    ACCEPT     all  --  anywhere             anywhere            
    ACCEPT     all  --  anywhere             anywhere            
    ACCEPT     all  --  anywhere             192.168.122.0/24     ctstate RELATED,ESTABLISHED
    ACCEPT     all  --  192.168.122.0/24     anywhere            
    ACCEPT     all  --  anywhere             anywhere            
    REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
    REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
    ACCEPT     all  --  anywhere             anywhere            
    REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
    REJECT     all  --  anywhere             anywhere             reject-with icmp-port-unreachable
    Chain OUTPUT (policy ACCEPT)
    target     prot opt source               destination         
    ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootpc
    ACCEPT     udp  --  anywhere             anywhere             udp dpt:bootpc
    Chain DOCKER (1 references)
    target     prot opt source               destination         
    Chain DOCKER-ISOLATION (1 references)
    target     prot opt source               destination                 
    
    RETURN     all  --  anywhere             anywhere     
    

我不确定应该如何进行调试。我相信主机能够与来宾(minikube IP)连接但无法检索数据。谁能指导我如何解决这个问题?

【问题讨论】:

    标签: curl networking kubernetes minikube virtual-network


    【解决方案1】:

    启动 minikube 实例并运行doc 中给出的命令后

    kubectl create -f http://fission.io/fission.yaml
    kubectl create -f http://fission.io/fission-nodeport.yaml
    

    然后运行以下设置 kubernetes 上下文

    kubectl config set-context minikube --namespace fission
    

    现在要获取当前部署刚刚运行的状态,请发布以下命令的输出:

    kubectl get pods -o wide
    kubectl get svc -o wide
    kubectl get events 
    

    对我来说它正在工作:

    $ export FISSION_URL=http://$(minikube ip):31313
    $ curl $FISSION_URL
    {"message": "Fission API", "version": "0.1.0"}
    

    我的状态是这样的:

    $ kubectl get pods -o wide
    NAME                           READY     STATUS    RESTARTS   AGE       IP           NODE
    controller-1637203237-g5lw1    1/1       Running   0          16m       172.17.0.6   minikube
    etcd-2122244727-6vl4v          1/1       Running   0          16m       172.17.0.8   minikube
    kubewatcher-2300228496-7kbw3   1/1       Running   1          16m       172.17.0.7   minikube
    poolmgr-3531518326-nsxmr       1/1       Running   3          16m       172.17.0.5   minikube
    router-2621354073-q1hw7        1/1       Running   3          16m       172.17.0.4   minikube
    

    $ kubectl get svc -o wide
    NAME         CLUSTER-IP   EXTERNAL-IP   PORT(S)        AGE       SELECTOR
    controller   10.0.0.191   <nodes>       80:31313/TCP   15m       svc=controller
    etcd         10.0.0.41    <none>        2379/TCP       16m       svc=etcd
    poolmgr      10.0.0.252   <none>        80/TCP         16m       svc=poolmgr
    router       10.0.0.108   <nodes>       80:31314/TCP   15m       svc=router
    

    事件是here

    【讨论】:

    • 感谢您的回复。当我运行 kubectl get pods -o wide 时,我看到我所有的 pod 都处于 ContainerCreating 状态。我检查了kubectl get events 并发现了这个错误:Warning FailedSync Error syncing pod, skipping: failed to "StartContainer" for "POD" with ImagePullBackOff: "Back-off pulling image \"gcr.io/google_containers/pause-amd64:3.0\"". 我在类似问题上找到了this 链接。你能指导我在哪里可以为代理设置--docker-env flag 吗?我无法理解修复。谢谢!
    • 你可以在这个issue找到代理帮助
    • 谢谢!但是当我运行 env | grep -i proxy 它不返回任何东西。所以我不认为代理是这个的原因。我注意到当我运行 kubectl get endpoints 时,它显示没有为任何 pod 分配 IP。这是正常的吗?我在网上找不到任何关于此的内容。
    • 如果您显示来自kubectl get events 的事件,我可以说是否有任何问题?
    • 感谢您的帮助。我的虚拟机确实存在互联网连接问题。现在它按预期工作了。
    猜你喜欢
    • 2018-09-03
    • 2019-03-11
    • 2019-04-26
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-03-01
    • 2012-12-20
    • 2018-07-03
    相关资源
    最近更新 更多