kubectl (node:7) [MONGODB DRIVER] 警告:当前的服务器发现和监控引擎已被弃用,将在未来版本中删除

Posted

技术标签:

【中文标题】kubectl (node:7) [MONGODB DRIVER] 警告:当前的服务器发现和监控引擎已被弃用,将在未来版本中删除【英文标题】:kubectl (node:7) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, and will be removed in a future version 【发布时间】:2022-01-04 21:13:40 【问题描述】:

尝试通过演练在 kubernetes 中制作应用程序 Docker 和 Kubernetes - 初学者完整课程 https://www.youtube.com/watch?v=Wf2eSG3owoA&t=14992s&ab_channel=freeCodeCamp.org

在命令之后:

wendel@wendel-VirtualBox:~/Docker-Kub-MongoDB$ kubectl apply -f mongo-configmap.yaml
configmap/mongodb-configmap created

    wendel@wendel-VirtualBox:~/Docker-Kub-MongoDB$ kubectl apply -f mongo-express.yaml
    deployment.apps/mongo-express created
    
    wendel@wendel-VirtualBox:~/Docker-Kub-MongoDB$ kubectl logs mongo-express-78fcf796b8-t9lqj
    Welcome to mongo-express
    ------------------------
    (...)
    (node:7) [MONGODB DRIVER] Warning: Current Server Discovery and Monitoring engine is deprecated, 
and will be removed in a future version. 
To use the new Server Discover and Monitoring engine, pass option  useUnifiedTopology: true  
to the MongoClient constructor.

Mongo Express server listening at http://0.0.0.0:8081
Server is open to allow connections from anyone (0.0.0.0)
basicAuth credentials are "admin:pass", it is recommended you change this in your config.js!

yaml列表:

https://gitlab.com/nanuchi/youtube-tutorial-series/-/blob/master/demo-kubernetes-components/mongo-configmap.yaml

https://gitlab.com/nanuchi/youtube-tutorial-series/-/blob/master/demo-kubernetes-components/mongo-express.yaml

https://gitlab.com/nanuchi/youtube-tutorial-series/-/blob/master/demo-kubernetes-components/mongo-secret.yaml

https://gitlab.com/nanuchi/youtube-tutorial-series/-/blob/master/demo-kubernetes-components/mongo.yaml

我错过了什么来显示此警告消息?

【问题讨论】:

您想进一步了解有关您的设置的此类问题。这已经有一个 *** 讨论。 ***.com/questions/57895175/… 【参考方案1】:

此警告消息与 k8s 无关。这与用于 mongodb 服务器发现的 js 驱动程序的更改有关。在您实例化 mongodb 客户端的代码中,您应该指定警告消息中建议的标志:

const driver = MongoClient(<connection string>, useUnifiedTopology: true )

警告应该会消失。

【讨论】:

以上是关于kubectl (node:7) [MONGODB DRIVER] 警告:当前的服务器发现和监控引擎已被弃用,将在未来版本中删除的主要内容,如果未能解决你的问题,请参考以下文章

06-kubectl常见命令整理

kubectl介绍及使用

K8s kubectl 常用命令总结,建议收藏!

kubernetes集群客户端命令 kubectl

kubectl logs

附001.kubectl介绍及使用