简体   繁体   English

不同节点中的 Pod 不能相互通信 - Kubernetes

[英]Pods in differents Nodes can't talk each other - Kubernetes

Context:语境:

I am building an application and now I am on the infrastructure step.我正在构建一个应用程序,现在我处于基础架构步骤。

The application is built with Java and persistence layer is MongoDB.该应用程序是用 Java 构建的,持久层是 MongoDB。

Problem:问题:

If the application is running in same Node as persistence Layer are, everything goes ok, but on different nodes the application cannot communicate with MongoDB.如果应用程序运行在与持久层相同的节点上,一切正常,但在不同的节点上,应用程序无法与 MongoDB 通信。

There is a print of Kubernetes Dashboard:有一张 Kubernetes Dashboard 的印刷品:

在此处输入图像描述 在此处输入图像描述

As you can see, two pods of application (gateway) are running in same node as Mongo, but other two don't.如您所见,应用程序(网关)的两个 pod 与 Mongo 在同一个节点上运行,但其他两个没有。 These two are not finding MongoDb.这两个都没有找到 MongoDb。

Here is the mongo-db.yaml:这是 mongo-db.yaml:


apiVersion: v1
kind: PersistentVolume
metadata:
  name: mongo-data
spec:
  accessModes:
    - ReadWriteOnce
  capacity:
    storage: 1Gi
  hostPath:
    path: /home/vitor/seguranca/mongo

---

apiVersion: v1
kind: PersistentVolumeClaim
metadata:
  name: pvc
spec:
  storageClassName: ""
  accessModes:
    - ReadWriteOnce 
  volumeName: mongo-data
  resources:
    requests:
      storage: 1Gi

---

apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: mongo
  name: mongo

spec:
  replicas: 1
  selector:
    matchLabels:
      app: mongo
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: mongo
      name: mongo-service

    spec:
      volumes:
      - name: "deployment-storage"
        persistentVolumeClaim:
          claimName: "pvc"

      containers:
      - image: mongo
        name: mongo
        ports:
          - containerPort: 27017
        volumeMounts:
          - name: "deployment-storage"
            mountPath: "/data/db"
        
status: {}
---

apiVersion: v1
kind: Service
metadata:
  labels:
    app: mongo
  name: mongo-service
spec:
  ports:
  - port: 27017
    targetPort: 27017
  selector:
    app: mongo
  clusterIP: None

and here the application.yaml:这里是application.yaml:


apiVersion: apps/v1
kind: Deployment
metadata:
  creationTimestamp: null
  labels:
    app: gateway
  name: gateway
spec:
  replicas: 4
  selector:
    matchLabels:
      app: gateway
  strategy: {}
  template:
    metadata:
      creationTimestamp: null
      labels:
        app: gateway
    spec:
      containers:

      - image: vitornilson1998/native-micro
        name: native-micro
        env:
        - name: MONGO_CONNECTION_STRING
          value: mongodb://mongo-service:27017 #HERE IS THE POINT THAT THE APPLICATION USES TO ACCESS MONGODB
        - name: MONGO_DB
          value: gateway
        resources: {}
        ports:
          - containerPort: 8080
        
status: {}

---

apiVersion: v1
kind: Service
metadata:
  creationTimestamp: null
  labels:
    app: gateway-service
  name: gateway-service
spec:
  ports:
  - name: 8080-8080
    port: 8080
    protocol: TCP
    targetPort: 8080
  selector:
    app: gateway
  type: NodePort
status:
  loadBalancer: {}


I can't see what is stopping application to reach MongoDB.我看不到是什么阻止了应用程序到达 MongoDB。

Should I do what?我应该怎么做?

I was using calico as CNI.我使用印花布作为 CNI。

I removed calico and let kube-proxy take care of everything.我删除了 calico,让 kube-proxy 处理所有事情。

Now everything is working fine.现在一切正常。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MongoDB 上 kubernetes 社区运营商。 唯一节点上的 Statefulset pod - MongoDB on kubernetes Community Operator. Statefulset pods on unique nodes MongoDB 中的 $in 和 $or 可以互相替换吗? - Can $in and $or replace each other in MongoDB? 具有 NFS 持久卷配置的 Kubernetes MongoDB pod - Kubernetes MongoDB pods with NFS persistent volume provisioning 在Kubernetes中部署MongoDB不会创建Pod /服务 - Deploying MongoDB in kubernetes does not create pods/services 在不同的 kubernetes pod 上连接 spring boot 和 mongodb - Connect spring boot and mongodb on different kubernetes pods 无法在 Kubernetes 集群上验证 MongoDb - Can't authenticate MongoDb on Kubernetes cluster 通过 docker 运行的 MongoDB 服务器无法看到彼此(名称解析暂时失败) - MongoDB servers running via docker can't see each other (Temporary failure in name resolution) 具有持久卷 FailedScheduling 0/1 节点的 Kubernetes Mongo 可用:1 个节点与节点选择器不匹配 - Kubernetes Mongo with persistent volume FailedScheduling 0/1 nodes are available: 1 node(s) didn't match node selector 如何从另一个集群 Pod 连接 kubernetes 集群上的 mongo 副本集 - How to connect mongo replicaset on kubernetes cluster from another cluster pods Kubernetes Pod 中的 MongoDb RAM 使用情况 - 不知道节点限制 - MongoDb RAM Usage in Kubernetes Pods - Not Aware of Node limits
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM