亚洲在线久爱草,狠狠天天香蕉网,天天搞日日干久草,伊人亚洲日本欧美

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

GKE 無法訪問 MongoDB Atlas

GKE 無法訪問 MongoDB Atlas

Go
小唯快跑啊 2022-06-06 16:45:52
我在嘗試將容器化應用部署到 GKE 時遇到問題。它無法訪問我的 MongoDB Atlas 集群。在本地運行 Docker 容器不會產生任何問題并且運行良好。我絕不是 Docker 或 Kubernetes 方面的專家,但我認為這與 DNS 名稱解析有關。我已遵循本教程-部署容器化 Web 應用程序,并在 MongoDB Atlas 控制臺中將 LoadBalancer 的 EXTERNAL-IP 添加到我的“網絡訪問”IP 白名單中,并使用端口映射 443 -> 8443,因為我使用的是 HTTPS .僅記錄我的應用程序在失敗之前能夠生成的日志:(mongodb): 2020/05/30 15:07:39 logger.go:96: 2020-05-30T15:07:39Z [error] Failed to connect to mongodb. Check if mongo is running...(mongodb): 2020/05/30 15:07:39 logger.go:132: 2020-05-30T15:07:39Z [fatal] server selection error: server selection timeout, current topology: { Type: ReplicaSetNoPrimary, Servers: [{ Addr: biomas- cluster-shard-<removed>.azure.mongodb.net:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : connection(biomas-cluster-shard-<removed>.azure.mongodb.net:27017[-180]) incomplete read of message header: EOF }, { Addr: biomas-cluster-shard-<removed>.azure.mongodb.net:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : connection(biomas-cluster-shard-<removed>.azure.mongodb.net:27017[-181]) incomplete read of message header: EOF }, { Addr: biomas-cluster-shard-<removed>.azure.mongodb.net:27017, Type: Unknown, State: Connected, Average RTT: 0, Last error: connection() : connection(biomas-cluster-shard-<removed>.azure.mongodb.net:27017[-179]) incomplete read of message header: EOF }, ] }如果有一個簡單的解決方法,那將是首選,因為該應用程序仍處于開發階段,所以我只需要一個使用上述技術的基本工作應用程序。完整的工作流程:Android 應用程序 -> 在 Docker 上運行的 Golang API -> MongoDB Atlas
查看完整描述

1 回答

?
德瑪西亞99

TA貢獻1770條經驗 獲得超3個贊

您的流量是通過工作節點的EXTERNAL-IP 流出的,而不是您的負載均衡器。

要查找節點 EXTERNAL-IP IP,請使用:

kubectl get nodes -owide

更準確地說,僅輸出 IP 使用(取自kubectl Cheat Sheet):

kubectl get nodes -o jsonpath='{.items[*].status.addresses[?(@.type=="ExternalIP")].address}'

接下來將這些 IP 列入白名單,您應該會很好,但請記住,在 Kubernetes 升級或集群擴展之后,IP 可能會發生變化,因此我建議使用Cloud NAT始終為您的傳出流量使用相同的 IP。


查看完整回答
反對 回復 2022-06-06
  • 1 回答
  • 0 關注
  • 157 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯系客服咨詢優惠詳情

幫助反饋 APP下載

慕課網APP
您的移動學習伙伴

公眾號

掃描二維碼
關注慕課網微信公眾號