简体   繁体   English

将 MongoDB 罗盘客户端连接到 kubernetes 集群内的 mongodb 数据库

[英]Connect MongoDB compass client to the mongodb database inside kubernetes cluster

I am running a mongo docker container service inside a kubernetes cluster.我在 kubernetes 集群内运行 mongo docker 容器服务。 Incoming traffic from outside is routed via ingress-nginx ( https://kubernetes.github.io/ingress-nginx/ ) load balancer to the mongo docker container service.来自外部的传入流量通过 ingress-nginx ( https://kubernetes.github.io/ingress-nginx/ ) 负载均衡器路由到 mongo Z05B6053C41A2130AFD6FC3BE158 容器服务。

Application is working as expected and I need to know whether there is a way I can connect the MongoDB compass client (which i installed in my local machine) to the running mongodb container to visualize the data easily.应用程序按预期工作,我需要知道是否有一种方法可以将 MongoDB 罗盘客户端(我安装在本地机器上)连接到正在运行的 mongodb 容器以轻松可视化数据。

I am having issues since the container is inside kubernetes and there is a load balancer in between.我遇到了问题,因为容器在 kubernetes 内部,并且中间有一个负载均衡器。

Would be of great help if someone could assist.如果有人可以提供帮助,将会有很大帮助。 Thanks谢谢

You can use port-forward您可以使用端口转发

$ kubectl port-forward -h
Forward one or more local ports to a pod. This command requires the node to have 'socat' installed.

 Use resource type/name such as deployment/mydeployment to select a pod. Resource type defaults to 'pod' if omitted.

 If there are multiple pods matching the criteria, a pod will be selected automatically. The forwarding session ends
when the selected pod terminates, and rerun of the command is needed to resume forwarding.

Examples:
  # Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in the pod
  kubectl port-forward pod/mypod 5000 6000

  # Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the
deployment
  kubectl port-forward deployment/mydeployment 5000 6000

  # Listen on ports 5000 and 6000 locally, forwarding data to/from ports 5000 and 6000 in a pod selected by the service
  kubectl port-forward service/myservice 5000 6000

  # Listen on port 8888 locally, forwarding to 5000 in the pod
  kubectl port-forward pod/mypod 8888:5000

  # Listen on port 8888 on all addresses, forwarding to 5000 in the pod
  kubectl port-forward --address 0.0.0.0 pod/mypod 8888:5000

  # Listen on port 8888 on localhost and selected IP, forwarding to 5000 in the pod
  kubectl port-forward --address localhost,10.19.21.23 pod/mypod 8888:5000

  # Listen on a random port locally, forwarding to 5000 in the pod
  kubectl port-forward pod/mypod :5000

Options:
      --address=[localhost]: Addresses to listen on (comma separated). Only accepts IP addresses or localhost as a
value. When localhost is supplied, kubectl will try to bind on both 127.0.0.1 and ::1 and will fail if neither of these
addresses are available to bind.
      --pod-running-timeout=1m0s: The length of time (like 5s, 2m, or 3h, higher than zero) to wait until at least one
pod is running

Usage:
  kubectl port-forward TYPE/NAME [options] [LOCAL_PORT:]REMOTE_PORT [...[LOCAL_PORT_N:]REMOTE_PORT_N]

Use "kubectl options" for a list of global command-line options (applies to all commands).

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

相关问题 如何从 mongodb 指南针连接 mongodb 集群? - How to connect mongodb cluster from mongodb compass? 如何通过 MongoDB Compass 或 RoboMongo 等 UI 工具连接在 Kubernetes 集群上运行的 MongoDB? - How to connect MongoDB which is running on Kubernetes cluster through UI tools like MongoDB Compass or RoboMongo? 无法使用 Compass 连接到本地 MongoDB docker 集群 - Unable to connect to local MongoDB docker cluster with Compass 使用 MongoDb 指南针 GUI 连接到 MongoDB 副本集(在 kubernetes 内) - Connecting to a MongoDB replicaset (inside kubernetes) with MongoDb compass GUI 如何使用 MongoDB Compass 连接到 DogitalOcean Droplets 数据库? - How to connect to DogitalOcean Droplets database with MongoDB Compass? 无法连接到Kubernetes群集中的mongodb服务 - Cannot connect to a mongodb service in a Kubernetes cluster 指南针 - 无法使用指南针或其他方式连接到任何 MongoDB Atlas 数据库 - Compass - Unable to connect to any MongoDB Atlas database using compass or otherwise 如何从 Kubernetes 集群外部连接到 Mongodb - How to connect to Mongodb from outside Kubernetes cluster 无法连接到 mongoDB Atlas Cluster 内的特定数据库和集合 - Cant connect to specific database and collection inside mongoDB Atlas Cluster 无法连接MongoDB Compass - Not able to connect MongoDB Compass
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM