Kubernetes Pod没有到达集群中另一个节点的Pod

时间:2018-10-18 20:27:05

标签: docker kubernetes rancher

我在牧场主/ kubernetes世界中是一个新手,并且遇到了问题。

我正在尝试部署需要状态的应用程序

说实话,我正在尝试部署服务注册表(是的,我需要这样做)。 我想做什么以及为什么要做:

内容: -部署多个在其间注册的服务注册表(用于高可用性) -我使用StatefulSet对象公开它们,以使用注册表的特定名称(出于客户端注册的目的),因此我需要获取诸如registry-0,registry-1之类的名称,并使用此名称来配置客户端

为什么: -如果我使用ClusterIP,则会在服务注册表之间保持平衡,而不是将客户端注册到每台服务器中(因为客户端和服务器只能自行注册到一个注册表中),这对我不利。

我的基础架构:

  • Rancher已安装到AWS
  • 配置为3个的Kubernetes集群
    节点为:
  • node1:全部(工作者,etcd,控制面板)
  • node2:工作者
  • node3:工作者

我的问题是

当我应用YAML并且Kubernetes部署我的应用程序时, 如果服务注册表在node1中,则它可以正常工作,并且可以看到自己和node1中的其他副本,例如:

node1:eureka1; eureka2(eureka1参见本身和eureka2)与eureka2(见其自身和eureka1)相同

但是,例如,如果我创建了另外四个尤里卡副本,并且将主节点部署到另一个节点,例如 另外2个eureka进入node2(仅适用于工作人员),然后再另外2个eureka进入node3(仅适用于工作人员) 他们自己也看不见彼此,而eureka1,eureka2也看不到eureka3,eureka4,eureka5和eureka6

TLDR:

  • 节点1中的Pod可以看到彼此,但看不到其他节点。
  • 节点2和节点3中的豆荚看不见自己,其他节点也看不到。
  • 如果我使用minikube在localhost中执行,一切正常。

要进行复制,只需在上方应用这两个文件并访问kubernetes的主IP。

服务注册表部署文件为:

Service-registry.yaml:

---
apiVersion: v1
kind: Service
metadata:
  name: eureka
  labels:
    app: eureka
spec:
  ports:
  - port: 7700
    name: eureka
  clusterIP: None
  selector:
    app: eureka
---    
apiVersion: apps/v1beta2
kind: StatefulSet
metadata:
  name: eureka
spec:
  serviceName: "eureka"
  replicas: 5 
  selector:
    matchLabels:
      app: eureka
  template:
    metadata:
      labels:
        app: eureka
    spec:
      containers:
      - name: eureka
        image: leandrozago/eureka
        ports:
        - containerPort: 7700
        env:
        - name: MY_POD_NAME
          valueFrom:
            fieldRef:
              fieldPath: metadata.name
          # Due to camelcase issues with "defaultZone" and "preferIpAddress", _JAVA_OPTIONS is used here
        - name: _JAVA_OPTIONS
          value: -Deureka.instance.preferIpAddress=false -Deureka.client.serviceUrl.defaultZone=http://eureka-0.eureka:7700/eureka/,http://eureka-1.eureka:7700/eureka/,http://eureka-2.eureka:7700/eureka/,http://eureka-3.eureka:7700/eureka/,http://eureka-4.eureka:7700/eureka/,http://eureka-5.eureka:7700/eureka/,http://eureka-6.eureka:7700/eureka/
        - name: EUREKA_CLIENT_REGISTERWITHEUREKA
          value: "true"
        - name: EUREKA_CLIENT_FETCHREGISTRY
          value: "true"
        # The hostnames must match with the eureka serviceUrls, otherwise, the replicas are reported as unavailable in the eureka dashboard      
        - name: EUREKA_INSTANCE_HOSTNAME
          value: ${MY_POD_NAME}.eureka
      # No need to start the pods in order. We just need the stable network identity
  podManagementPolicy: "Parallel"

入口Yaml:

apiVersion: extensions/v1beta1
kind: Ingress
metadata:
  name: ingress-service
  annotations:
    kubernetes.io/ingress.class: nginx
    nginx.ingress.kubernetes.io/rewrite-target: /
spec:
  rules:
    - http:
        paths:
          - path: /
            backend:
              serviceName: eureka
              servicePort: 7700

已编辑:

  

kubectl获取容器--all-namespaces -o宽

NAMESPACE       NAME                                      READY     STATUS             RESTARTS   AGE       IP              NODE
cattle-system   cattle-cluster-agent-557ff9f65d-5qsv6     0/1       CrashLoopBackOff   15         58m       10.42.1.41      rancher-b2b-rancheragent-1-worker
cattle-system   cattle-node-agent-mxfpm                   1/1       Running            0          4d        172.18.80.152   rancher-b2b-rancheragent-0-all
cattle-system   cattle-node-agent-x2wdc                   1/1       Running            0          4d        172.18.82.84    rancher-b2b-rancheragent-0-worker
cattle-system   cattle-node-agent-z6cnw                   1/1       Running            0          4d        172.18.84.152   rancher-b2b-rancheragent-1-worker
default         eureka-0                                  1/1       Running            0          52m       10.42.2.41      rancher-b2b-rancheragent-0-worker
default         eureka-1                                  1/1       Running            0          52m       10.42.1.42      rancher-b2b-rancheragent-1-worker
default         eureka-2                                  1/1       Running            0          52m       10.42.0.28      rancher-b2b-rancheragent-0-all
default         eureka-3                                  1/1       Running            0          52m       10.42.1.43      rancher-b2b-rancheragent-1-worker
default         eureka-4                                  1/1       Running            0          52m       10.42.2.42      rancher-b2b-rancheragent-0-worker
default         eureka-5                                  1/1       Running            0          59s       10.42.0.29      rancher-b2b-rancheragent-0-all
default         eureka-6                                  1/1       Running            0          59s       10.42.2.43      rancher-b2b-rancheragent-0-worker
ingress-nginx   default-http-backend-797c5bc547-wkp5z     1/1       Running            0          4d        10.42.0.5       rancher-b2b-rancheragent-0-all
ingress-nginx   nginx-ingress-controller-dd5mt            1/1       Running            0          4d        172.18.82.84    rancher-b2b-rancheragent-0-worker
ingress-nginx   nginx-ingress-controller-m6jkh            1/1       Running            1          4d        172.18.84.152   rancher-b2b-rancheragent-1-worker
ingress-nginx   nginx-ingress-controller-znr8c            1/1       Running            0          4d        172.18.80.152   rancher-b2b-rancheragent-0-all
kube-system     canal-bqh22                               3/3       Running            0          4d        172.18.80.152   rancher-b2b-rancheragent-0-all
kube-system     canal-bv7zp                               3/3       Running            0          3d        172.18.84.152   rancher-b2b-rancheragent-1-worker
kube-system     canal-m5jnj                               3/3       Running            0          4d        172.18.82.84    rancher-b2b-rancheragent-0-worker
kube-system     kube-dns-7588d5b5f5-wdkqm                 3/3       Running            0          4d        10.42.0.4       rancher-b2b-rancheragent-0-all
kube-system     kube-dns-autoscaler-5db9bbb766-snp4h      1/1       Running            0          4d        10.42.0.3       rancher-b2b-rancheragent-0-all
kube-system     metrics-server-97bc649d5-q2bxh            1/1       Running            0          4d        10.42.0.2       rancher-b2b-rancheragent-0-all
kube-system     rke-ingress-controller-deploy-job-bqvcl   0/1       Completed          0          4d        172.18.80.152   rancher-b2b-rancheragent-0-all
kube-system     rke-kubedns-addon-deploy-job-sf4w5        0/1       Completed          0          4d        172.18.80.152   rancher-b2b-rancheragent-0-all
kube-system     rke-metrics-addon-deploy-job-55xwp        0/1       Completed          0          4d        172.18.80.152   rancher-b2b-rancheragent-0-all
kube-system     rke-network-plugin-deploy-job-fdg9d       0/1       Completed          0          21h       172.18.80.152   rancher-b2b-rancheragent-0-all

0 个答案:

没有答案