简体   繁体   English

重新启动=从不导致 MongoDB 吊舱终止

[英]Restart=Never causes the MongoDB pod to terminate

I am trying to follow the instructions here: https://github.com/bitnami/charts/tree/master/bitnami/mongodb我正在尝试按照此处的说明进行操作: https://github.com/bitnami/charts/tree/master/bitnami/mongodb

1) helm install mongorelease --set mongodbRootPassword=secretpassword,mongodbUsername=my-user,mongodbPassword=my-password,mongodbDatabase=my-database bitnami/mongodb 1) helm install mongorelease --set mongodbRootPassword=secretpassword,mongodbUsername=my-user,mongodbPassword=my-password,mongodbDatabase=my-database bitnami/mongodb

which says:其中说:

To connect to your database run the following command:要连接到您的数据库,请运行以下命令:

kubectl run --namespace default mongorelease-mongodb-client --rm --tty -i --restart='Never' --image docker.io/bitnami/mongodb:4.2.5-debian-10-r44 --command -- mongo admin --host mongorelease-mongodb --authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD kubectl run --namespace default mongorelease-mongodb-client --rm --tty -i --restart='Never' --image docker.io/bitnami/mongodb:4.2.5-debian-10-r44 --command - - mongo admin --host mongorelease-mongodb --authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD

I run the command above (replacing $MONGODB_ROOT_PASSWORD with my password) and I see this error:我运行上面的命令(用我的密码替换 $MONGODB_ROOT_PASSWORD),我看到了这个错误:

error: invalid restart policy: 'Never'
See 'kubectl run -h' for help and examples

I remove the single quotes around Never and see this:我删除了 Never 周围的单引号,然后看到:

MongoDB shell version v4.2.5
connecting to: mongodb://mongorelease-mongodb:27017/admin?authSource=admin&compressors=disabled&gssapiServiceName=mongodb
2020-04-11T10:04:52.187+0000 E  QUERY    [js] Error: Authentication failed. :
connect@src/mongo/shell/mongo.js:341:17
@(connect):2:6
2020-04-11T10:04:52.189+0000 F  -        [main] exception: connect failed
2020-04-11T10:04:52.189+0000 E  -        [main] exiting with code 1
pod "mongorelease-mongodb-client" deleted
pod default/mongorelease-mongodb-client terminated (Error)

I then remove --restart=Never from the command and run it again.然后我从命令中删除 --restart=Never 并再次运行它。 It then works expected and I can interact with MongoDB, however I am presented with this warning:然后它可以正常工作,我可以与 MongoDB 交互,但是我收到了以下警告:

kubectl run --generator=deployment/apps.v1 is DEPRECATED and will be removed in a future version. Use kubectl run --generator=run-pod/v1 or kubectl create instead.

What is the command I should be using?我应该使用什么命令?

--restart=Never creates a pod. --restart=Never创建 pod。 So you instead can run this command with --generator=run-pod/v1 to create a pod.因此,您可以改为使用--generator=run-pod/v1运行此命令来创建 pod。 This avoids usage of --restart=Never and also the deprecation warning will not be there.这样可以避免使用--restart=Never并且不会出现弃用警告。

kubectl run --rm --grace-period=1 --force=true --generator=run-pod/v1 --namespace default mongorelease-mongodb-client --tty -i --image docker.io/bitnami/mongodb:4.2.5-debian-10-r44 --command -- mongo admin --host mongorelease-mongodb --authenticationDatabase admin -u root -p $MONGODB_ROOT_PASSWORD

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

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM