0

我在 Ubuntu 16.04 机器上设置 Kubernetes 集群时遇到问题,我已正确设置:

  1. 主节点(机器IP:10.10.1.122)
  2. 工作节点(机器 IP:10.10.1.38)

进入包含以下信息的集群:

    NAME                                        READY   STATUS    RESTARTS   AGE
pod/coredns-86c58d9df4-78lnp                1/1     Running   0          80m
pod/coredns-86c58d9df4-lw7vl                1/1     Running   0          80m
pod/etcd-di-linux-host                      1/1     Running   0          111m
pod/kube-apiserver-di-linux-host            1/1     Running   0          110m
pod/kube-controller-manager-di-linux-host   1/1     Running   0          111m
pod/kube-flannel-ds-amd64-6wvkh             1/1     Running   0          109m
pod/kube-flannel-ds-amd64-p7ftb             1/1     Running   0          110m
pod/kube-proxy-rbfvz                        1/1     Running   0          109m
pod/kube-proxy-zwr7b                        1/1     Running   0          111m
pod/kube-scheduler-di-linux-host            1/1     Running   0          111m
pod/kubernetes-dashboard-79ff88449c-9f8qw   1/1     Running   0          89m

NAME                           TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)         AGE
service/kube-dns               ClusterIP   10.96.0.10      <none>        53/UDP,53/TCP   111m
service/kubernetes-dashboard   ClusterIP   10.98.188.215   <none>        443/TCP         89m

NAME                                     DESIRED   CURRENT   READY   UP-TO-DATE   AVAILABLE   NODE SELECTOR                     AGE
daemonset.apps/kube-flannel-ds-amd64     2         2         2       2            2           beta.kubernetes.io/arch=amd64     110m
daemonset.apps/kube-flannel-ds-arm       0         0         0       0            0           beta.kubernetes.io/arch=arm       110m
daemonset.apps/kube-flannel-ds-arm64     0         0         0       0            0           beta.kubernetes.io/arch=arm64     110m
daemonset.apps/kube-flannel-ds-ppc64le   0         0         0       0            0           beta.kubernetes.io/arch=ppc64le   110m
daemonset.apps/kube-flannel-ds-s390x     0         0         0       0            0           beta.kubernetes.io/arch=s390x     110m
daemonset.apps/kube-proxy                2         2         2       2            2           <none>                            111m

NAME                                   READY   UP-TO-DATE   AVAILABLE   AGE
deployment.apps/coredns                2/2     2            2           111m
deployment.apps/kubernetes-dashboard   1/1     1            1           89m

NAME                                              DESIRED   CURRENT   READY   AGE
replicaset.apps/coredns-86c58d9df4                2         2         2       111m
replicaset.apps/kubernetes-dashboard-79ff88449c   1         1         1       89m

我的集群信息

Kubernetes master is running at https://10.10.1.122:6443
KubeDNS is running at https://10.10.1.122:6443/api/v1/namespaces/kube-system/services/kube-dns:dns/proxy

我的豆荚

NAME                     READY   STATUS    RESTARTS   AGE
guids-68898f7dc9-c65nv   1/1     Running   0          102m
Name:               guids-68898f7dc9-c65nv
Namespace:          default
Priority:           0
PriorityClassName:  <none>
Node:               gmf.com/10.10.1.38
Start Time:         Sun, 16 Dec 2018 15:43:41 +0200
Labels:             pod-template-hash=68898f7dc9
                    run=guids
Annotations:        <none>
Status:             Running
IP:                 10.244.1.15
Controlled By:      ReplicaSet/guids-68898f7dc9
Containers:
  guids:
    Container ID:   docker://125ceccad4e572b514538292aaeaa55e22050c5e9129f834de8e01dfd452c6c1
    Image:          alexellis2/guid-service:latest
    Image ID:       docker-pullable://alexellis2/guid-service@sha256:17207f799760ccdccd0fa1e7f37838af5df915a33f9f27e97951a6eeee8c3a6f
    Port:           9000/TCP
    Host Port:      0/TCP
    State:          Running
      Started:      Sun, 16 Dec 2018 15:43:46 +0200
    Ready:          True
    Restart Count:  0
    Environment:    <none>
    Mounts:
      /var/run/secrets/kubernetes.io/serviceaccount from default-token-hnwtc (ro)
Conditions:
  Type              Status
  Initialized       True 
  Ready             True 
  ContainersReady   True 
  PodScheduled      True 
Volumes:
  default-token-hnwtc:
    Type:        Secret (a volume populated by a Secret)
    SecretName:  default-token-hnwtc
    Optional:    false
QoS Class:       BestEffort
Node-Selectors:  <none>
Tolerations:     node.kubernetes.io/not-ready:NoExecute for 300s
                 node.kubernetes.io/unreachable:NoExecute for 300s
Events:          <none>

我在这里面临的问题是,每当我想从主节点卷曲服务或 Pod IP 时,它永远不会命中,同时从工作节点卷曲服务/Pod 很好,我是 Kubernetes 的新手,但是我找不到任何线索如何诊断这个问题,任何帮助将不胜感激。

当我尝试卷曲暴露的服务时,即使我从主人那里得到了这个结果:

NAME         TYPE        CLUSTER-IP      EXTERNAL-IP   PORT(S)    AGE
guids        ClusterIP   10.97.160.160   <none>        9000/TCP   92m
kubernetes   ClusterIP   10.96.0.1       <none>        443/TCP    139m
ubuntu@master:/$ curl http://10.97.160.160:9000/guid
curl: (7) Failed to connect to 10.97.160.160 port 9000: Connection timed out
4

1 回答 1

1

可以从其他节点访问的 pod IP 和 clusterIP 可以从 kubernetes 集群内的 pod 访问。

service的ClusterIP不是pod的IP地址,它是根据service中定义的规则映射到pod的IP地址的虚拟地址,由kube-proxykubernetes集群中的daemonset管理。

ClusterIP 特别适用于集群内部的通信以访问服务后面的 pod,而无需关心存在多少个 pod 副本或存在哪个节点 pod,并且 clusterIP 与 pod 的 IP 不同,它是静态的。

如果可以在官方文档中了解服务 IP 的工作原理

我希望您遵循一些调试步骤:

您可以使用以下命令检查您的服务名称是否从 pod 内部解析为 ClusterIP:

kubectl exec -it <pod_name> bash
nslookup  <svc_name>.<namespace>.svc.cluster.local

上面的命令将为您提供服务的 clusterIP。

检查您的工作节点是否可以从您的主节点ping,如果不是,那么您的覆盖网络有问题,在您的情况下是法兰绒。

于 2018-12-16T17:02:49.240 回答