【问题标题】:deploy Restheart at kubernetes running mongodb sharded db在运行 mongodb 分片数据库的 kubernetes 上部署 Restheart
【发布时间】:2020-09-08 17:13:02
【问题描述】:

我有一个使用分片的正在运行的 mongodb。我已经提供了我需要的所有服务,并且我有 mongodb uri 可以连接到 mongos 路由器。现在我想使用 restheart 容器来处理 http 请求。我试过这个:

apiVersion: apps/v1
kind: Deployment
metadata:
  name: restheart
  labels:
    app: restheart
spec:
  replicas: 1
  selector:
    matchLabels:
      app: restheart
  template:
    metadata:
      labels:
        app: restheart
    spec:
      containers:
      - name: restheart-demo
        image: softinstigate/restheart
        #command:
                #- "--envFile /opt/restheart/etc/default.properties"
        ports:
        - containerPort: 8080
          protocol: TCP
        env:
        - name: MONGO_URI
          value: "mongodb://(uri here)"

然后我用了:

kubectl expose deploy restheart  --port 8080 --type NodePort

但获取请求返回 401 代码。我必须在这里提一下,在我的 mongo uri 中,我还包含了用户名:密码,因此 restheart 不需要进行身份验证。 如何在我的 yaml 中更改 restheart 的默认设置,以便我可以正确使用它。 根本没有关于在 kubernetes 上运行 restheart 的文档 我的问题是,在使用 yaml 文件构建部署时,我不知道如何配置 restheart

【问题讨论】:

标签: mongodb kubernetes restheart


【解决方案1】:

如果你会检查this URL

您可以看到 mongo-uri = mongodb://127.0.0.1 的默认值 您不能用环境变量覆盖它。相反,使用卷挂载将特定文件替换为包含此文件的配置映射,并进行更改,一切应该可以正常工作。

【讨论】:

  • 感谢您的回答,我会检查一下。由于我对 Kubernetes 很陌生,您能否提供一个卷挂载的示例?我将不胜感激。如果没有,请提前致谢。但是让我评论一下:你不能用我的环境变量工作的环境变量覆盖它。但你是对的,为了进一步配置,我必须进行卷挂载
  • 当我阅读 restheart 时,不要在 post 中使用 insert 命令,而是使用 find 和 modify。这是分片 mongo 的一个问题:分片集合的写入请求必须指定 shardkey。使用 'shardkey' 查询参数"
  • 如果您不太了解 K8s,那么另一个选择是编辑属性文件 (github.com/SoftInstigate/restheart/tree/master/core/etc/…) 并使用“docker build -t softinstigate/restheart”重新构建 docker 映像。查看 Dockerfile github.com/SoftInstigate/restheart/blob/master/core/Dockerfile
猜你喜欢
  • 1970-01-01
  • 2019-05-06
  • 1970-01-01
  • 2021-07-05
  • 1970-01-01
  • 2021-04-23
  • 2022-12-20
  • 2019-01-08
  • 1970-01-01
相关资源
最近更新 更多