k8s pod启动报错: no route to host

k8s pod kuboard启动报错

查看pod命令

kubectl get pods -A
kubectl get pods --all-namespaces

k8s pod启动报错: no route to host_第1张图片

查看报错pod日志
命令:

kubectl logs -f -n namespace name

k8s pod启动报错: no route to host_第2张图片

time="2023-08-09T13:40:36+08:00" level=error msg="不能获取 AgentEndpointsGet \"http://kuboard-v3/kuboard-api/cluster/default/kind/KubernetesCluster/default/resource/installAgentGetAgentEndpoints\": dial tcp: lookup kuboard-v3 on 10.10.0.10:53: read udp 10.244.219.109:46173->10.10.0.10:53: read: no route to host"
使用环境变量中的参数
KUBOARD_AGENT_REMOTE_PORT_NGINX: 45001
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:01 --:--:--     0
curl: (7) Failed to connect to 10.10.0.1 port 443 after 1001 ms: Couldn't connect to server
 
K8S_VERSION:

 
AGENT_VERSION:
{"version":"v3.5.1","buildDate":"2023-01-02 20:51:33"}
 
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  0     0    0     0    0     0      0      0 --:--:--  0:00:04 --:--:--     0curl: (6) Could not resolve host: kuboard-v3
 
访问 kuboard-server 失败 http://kuboard-v3/kuboard-api/cluster/default/kind/KubernetesClusterToken

pod报错都一样: no route to host
原因:
找不到这个路由对应的地址,关闭防火墙,重启k8s,执行下面命令即可。
正常线上是不能关闭防火墙,这个属于pod内部之间的host调用失败,有大神知道的这种情况怎么处理的,
可以在评论区告知一下,谢谢

解决方案:

  1. 关闭防火墙,执行下前面命令
systemctl stop kubelet
systemctl stop docker
iptables --flush
iptables -tnat --flush
systemctl start kubelet
systemctl start docker
  1. 开放k8s对应的端口,上面报错是因为443、53端口没有开启
firewall-cmd --permanent --add-port=443/tcp
firewall-cmd --permanent --add-port=53/tcp
manager:
firewall-cmd --permanent --add-port=6443/tcp
firewall-cmd --permanent --add-port=2379-2380/tcp
firewall-cmd --permanent --add-port=10250-10252/tcp
firewall-cmd --reload

work nodes:
firewall-cmd --permanent --add-port=10250/tcp
firewall-cmd --permanent --add-port=30000-32767/tcp
firewall-cmd --reload
# 查看所有打开的端口: 
firewall-cmd --zone=public --list-ports

问题解决出处

你可能感兴趣的:(kubernetes,容器,云原生)