Warning: file_get_contents(/data/phpspider/zhask/data//catemap/7/kubernetes/5.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/8/.htaccess/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Networking Kubernetes:没有到主机的路由_Networking_Kubernetes_Kubernetes Service - Fatal编程技术网

Networking Kubernetes:没有到主机的路由

Networking Kubernetes:没有到主机的路由,networking,kubernetes,kubernetes-service,Networking,Kubernetes,Kubernetes Service,我有一个裸机Kubernetes自定义设置(使用Kubernetes手动设置集群)。一切似乎都正常,但我无法访问外部服务 我可以在以下情况下获取服务列表: https://<ip-addr>/api/v1/namespaces/kube-system/services 我得到: Error: 'dial tcp 10.44.0.16:3000: connect: no route to host' Trying to reach: 'http://10.44.0.16:3000/'

我有一个裸机Kubernetes自定义设置(使用Kubernetes手动设置集群)。一切似乎都正常,但我无法访问外部服务

我可以在以下情况下获取服务列表:

https://<ip-addr>/api/v1/namespaces/kube-system/services
我得到:

Error: 'dial tcp 10.44.0.16:3000: connect: no route to host'
Trying to reach: 'http://10.44.0.16:3000/'
  • 即使我通常卷曲
    http://10.44.0.16:3000/
    我也遇到了同样的错误。这就是我是否从安装Kubernetes的VM内部卷曲的结果。无法解决此问题,请检查以下内容

  • 我可以使用NodePort从外部访问我的服务

  • 如果我通过Nginx入口公开我的服务,我可以访问它们

  • 我使用Weave作为CNI,日志是正常的,除了开始时有几行日志说明它无法访问名称空间(RBAC错误)。虽然在那之后,原木还不错

  • 使用CoreDNS,日志看起来很正常。APIServer和Kubelet日志看起来很正常。库伯内特斯事件看起来也很正常

  • 附加说明:分配的DNS服务IP为
    10.3.0.10
    ,服务IP范围为:
    10.3.0.0/24
    ,POD网络为
    10.2.0.0/16
    。我不知道
    10.44.x.x
    是什么或者它来自哪里

    • 此外,我正在使用Nginx入口(头盔图表:)
以下是其中一项服务的输出:

{
  "kind": "Service",
  "apiVersion": "v1",
  "metadata": {
    "name": "kubernetes-dashboard",
    "namespace": "kube-system",
    "selfLink": "/api/v1/namespaces/kube-system/services/kubernetes-dashboard",
    "uid": "5c8bb34f-c6a2-11e8-84a7-00163cb4ceeb",
    "resourceVersion": "7054",
    "creationTimestamp": "2018-10-03T00:22:07Z",
    "labels": {
      "addonmanager.kubernetes.io/mode": "Reconcile",
      "k8s-app": "kubernetes-dashboard",
      "kubernetes.io/cluster-service": "true"
    },
    "annotations": {
      "kubectl.kubernetes.io/last-applied-configuration": "{\"apiVersion\":\"v1\",\"kind\":\"Service\",\"metadata\":{\"annotations\":{},\"labels\":{\"addonmanager.kubernetes.io/mode\":\"Reconcile\",\"k8s-app\":\"kubernetes-dashboard\",\"kubernetes.io/cluster-service\":\"true\"},\"name\":\"kubernetes-dashboard\",\"namespace\":\"kube-system\"},\"spec\":{\"ports\":[{\"port\":443,\"targetPort\":8443}],\"selector\":{\"k8s-app\":\"kubernetes-dashboard\"}}}\n"
    }
  },
  "spec": {
    "ports": [
      {
        "protocol": "TCP",
        "port": 443,
        "targetPort": 8443,
        "nodePort": 30033
      }
    ],
    "selector": {
      "k8s-app": "kubernetes-dashboard"
    },
    "clusterIP": "10.3.0.30",
    "type": "NodePort",
    "sessionAffinity": "None",
    "externalTrafficPolicy": "Cluster"
  },
  "status": {
    "loadBalancer": {

    }
  }
}
我不知道如何调试这个,即使是一些指向正确方向的指针也会有所帮助。如果还需要什么,请告诉我


来自kubectl get svc的输出

NAME                   TYPE        CLUSTER-IP   EXTERNAL-IP   PORT(S)                  AGE
coredns-primary        ClusterIP   10.3.0.10    <none>        53/UDP,53/TCP,9153/TCP   4h51m
kubernetes-dashboard   NodePort    10.3.0.30    <none>        443:30033/TCP            4h51m
名称类型群集IP外部IP端口
coredns主群集IP 10.3.0.10 53/UDP、53/TCP、9153/TCP 4h51m
kubernetes仪表板节点端口10.3.0.30 443:30033/TCP 4h51m

编辑:

事实证明,尽管运行了CoreDNS,但出于某种原因,我没有运行
kube dns
服务。正如这里提到的:


现在我可以成功地从VM内部卷曲,但代理访问仍然会给我相同的错误:
没有到主机的路由
。我不知道为什么或者如何解决这个问题,因为我没有看到DNS在这里发挥作用,但它解决了问题regardles。如果您使用
kubectl代理
,默认情况下,您应该使用
127.0.0.1:8001
作为HTTP Kube API URL。您对
http://127.0.0.1:8001
然后用身份验证头进行扩充,并传递给API服务器。因此,您应该尝试
http://127.0.0.1:8001/api/v1/namespaces/kube-system/services/toned gecko grafana:80/proxy/
而不是https和api ip


另外,请确保在kube节点上安装了socat。

我遇到了相同的问题,并通过运行以下命令解决了此问题:

iptables --flush
iptables -tnat --flush
systemctl stop firewalld
systemctl disable firewalld
systemctl restart docker

对我来说,解决方案是按照所述修改iptables中的规则


尝试运行
curl https://:

如果端口打开,您应该会收到一条与证书或HTTPS相关的消息

It端口关闭(这可能是您的问题)-出现
无主机路由消息

(!)不要禁用iptables。

通过SSH连接到主节点并运行:
A)
sudo firewall cmd--add port=/tcp--permanent
(我假设安装了
firewalld

B)
sudo firewall cmd——重新加载

C)
sudo firewall cmd——列出所有
——您应该看到
已更新

public
  target: default
  icmp-block-inversion: no
  interfaces: 
  sources: 
  services: dhcpv6-client ssh
  ports: <relevant-port>/tcp <---- Here
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules:
公共
目标:默认值
icmp块反转:否
接口:
资料来源:
服务:dhcpv6客户端ssh

端口:/tcp代理时,您的意思是使用
kubectl代理
?或者只是代理端点。您从哪里运行
curl
请求?您还可以通过
proxy
kubectl get svc
发布一些输出,我的意思是
kubectl proxy
https://:/api/v1/namespace/kube system/services/toned gecko grafana:80/proxy/
Curl请求在安装Kubernetes的虚拟机内运行。我已经发布了上面讨论的
kubectl get svc
的输出。通过
kubectl proxy
之前是否有效,但它不起作用?不,它从未起作用。我几个小时前刚刚安装了群集。。。。另外,我更新了问题,请检查最后一部分/编辑。另外,发布你的
kubectl代理
commandFYI这会禁用防火墙,对安全性来说不是一个好选项。fyi:Ubuntu主机没有安装
firewall cmd
。您可以尝试
ufw
来管理
iptables
,但它会创建自己的一组规则,这些规则可能与现有的
iptables
规则冲突。
sudo iptables -D  INPUT -j REJECT --reject-with icmp-host-prohibited
sudo iptables -D  FORWARD -j REJECT --reject-with icmp-host-prohibited
public
  target: default
  icmp-block-inversion: no
  interfaces: 
  sources: 
  services: dhcpv6-client ssh
  ports: <relevant-port>/tcp <---- Here
  protocols: 
  masquerade: no
  forward-ports: 
  source-ports: 
  icmp-blocks: 
  rich rules: