背景

搭建完集群式k8s后,各个节点都已经Ready,但是在创建echo服务进行访问时报错:No route to host

解决

参考链接:https://imlc.me/v/zh-cn/kuai-su-jie-jue-kubernetes-no-route-to-host

(一)集群式部署

[root@k8s-master kong]# systemctl stop kubelet
[root@k8s-master kong]# systemctl stop docker
[root@k8s-master kong]# iptables --flush
[root@k8s-master kong]# iptables -tnat --flush
[root@k8s-master kong]# systemctl start kubelet
[root@k8s-master kong]# systemctl start docker

(二)Microk8s部署

[root@k8s-master kong]# microk8s stop
[root@k8s-master kong]# systemctl stop docker
[root@k8s-master kong]# iptables --flush
[root@k8s-master kong]# iptables -tnat --flush
[root@k8s-master kong]# systemctl start docker
[root@k8s-master kong]# microk8s start

测试

[root@k8s-master kong]# kubectl get svc -n demo -o wide
NAME   TYPE        CLUSTER-IP       EXTERNAL-IP   PORT(S)           AGE   SELECTOR
echo   ClusterIP   10.105.104.233   <none>        8080/TCP,80/TCP   26m   app=echo
[root@k8s-master kong]# curl http://10.105.104.233


Hostname: echo-8467949b65-mt4vk

Pod Information:
        node name:      k8s-worker-1
        pod name:       echo-8467949b65-mt4vk
        pod namespace:  demo
        pod IP: 10.36.0.0

Server values:
        server_version=nginx: 1.13.3 - lua: 10008

Request Information:
        client_address=10.32.0.1
        method=GET
        real path=/
        query=
        request_version=1.1
        request_scheme=http
        request_uri=http://10.105.104.233:8080/

Request Headers:
        accept=*/*
        host=10.105.104.233
        user-agent=curl/7.29.0

Request Body:
        -no body in request-

 

Logo

开源、云原生的融合云平台

更多推荐