【问题标题】:Deploying monstache in kubernetes在 Kubernetes 中部署 monstache
【发布时间】:2021-11-27 00:23:02
【问题描述】:

我已经使用 docker-compose 部署了 monstache,如下所示:

  blascal_tasks_monstache:
    image: rwynn/monstache:6.7.6
    container_name: dev_monstache
    working_dir: /monstache
    command: -f ./config.toml
    volumes:
      - ./monstache/dev:/monstache/
    ports:
      - "5556:8080"
    restart: always

它工作正常,但尝试在 kubernetes 中部署它时出现错误:

ERROR 2021/10/06 20:07:56 open ./config.toml: no such file or directory

这是我的规格:

   spec:
         containers:
           - args:
               - -f
               - ./config.toml
             image: rwynn/monstache:6.7.6
             name: dev-monstache
             ports:
               - containerPort: 8080
             resources: {}
             volumeMounts:
               - mountPath: /monstache/dev
                 name: monstache-claim
             workingDir: /monstache 

如何指定文件?

【问题讨论】:

  • 面向开发人员的 Docker 方法运行未修改的基础映像,然后将代码绑定安装到其中,在 Kubernetes 中效果不佳;集群通常无法访问您的本地文件系统,并且复制两条 Compose volumes: 行可以使 Kubernetes YAML 的总大小增加一倍或三倍。您可以将应用程序代码构建到映像中而不是尝试将其挂载到容器中吗?
  • @david-maze 请在这里咨询stackoverflow.com/questions/69475221/…

标签: mongodb docker kubernetes docker-compose yaml


【解决方案1】:

./config.toml: no such file or directory

要使配置对您的 pod 可用,首先使用配置文件创建一个 ConfigMap 资源:

kubectl create configmap monstache-claim --from-file=config.toml

然后将配置挂载到您的 pod 规范中:

spec:
  volumes:
  - name: monstache-claim
    configMap:
      name: monstache-claim
  containers:
  - args:
  ...

您将能够访问 pod 中的 /monstache/dev/config.toml。

【讨论】:

    猜你喜欢
    • 2021-02-22
    • 2019-06-25
    • 1970-01-01
    • 2016-04-18
    • 1970-01-01
    • 1970-01-01
    • 2020-04-08
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多