gpt4 book ai didi

docker - kubernetes kompose up Unsupported env_file key

转载 作者:行者123 更新时间:2023-12-02 20:03:50 27 4
gpt4 key购买 nike

我正在尝试将一个文档化的项目迁移到 kubernetes,我使用 Kompose 来转换项目
kompose --file docker-compose.yml convert ,

当我运行 kompose up迁移文件后
我得到这个错误
$ kompose up
WARN Unsupported env_file key - ignoring

FATA Error while deploying application: k.Transform failed: image key required within build parameters in order to build and push service 'drkiq'

.env 文件:
SECRET_TOKEN=xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
WORKER_PROCESSES=1
LISTEN_ON=0.0.0.0:8000
DATABASE_URL=postgresql://drkiq:yourpassword@postgres:5432/drkiq?encoding=utf8&pool=5&timeout=5000
CACHE_URL=redis://redis:6379/0
JOB_WORKER_URL=redis://redis:6379/0

Dockerized项目链接here !

知道如何将 .env 文件转换为可与 kubernetes kompose 一起使用的格式

docker 撰写文件:

  postgres:
image: postgres:9.4.5
environment:
POSTGRES_USER: drkiq
POSTGRES_PASSWORD: yourpassword
ports:
- '5432:5432'
volumes:
- drkiq-postgres:/var/lib/postgresql/data

redis:
image: redis:3.0.5
ports:
- '6379:6379'
volumes:
- drkiq-redis:/var/lib/redis/data

drkiq:
build: .
links:
- postgres
- redis
volumes:
- .:/drkiq
ports:
- '8000:8000'
env_file:
- .drkiq.env
sidekiq:
build: .
command: bundle exec sidekiq -C config/sidekiq.yml
links:
- postgres
- redis
volumes:
- .:/drkiq
env_file:
- .drkiq.env

最佳答案

Kubernetes kompose 支持 env_fileDocker Compose 3.x 转换Conversion matrix 中描述的版本.

在 Kubernetes 中,您可以使用 ConfigMap存储来自 env_file 的环境变量.对于 SECRET_TOKEN变量,你可以使用 Secrets保存您的私有(private)和敏感数据。

您还可以检查其他工具以进行转换,例如 compose2kubek8s-env-gen .

根据附件Docker-composer文件和转换过程中的错误,我可以假设您错过了 drkiq 的图像键值和 sidekiq服务:

更新: docker-compose.yml 文件

version: '2'

services:
postgres:
image: postgres:9.4.5
environment:
POSTGRES_USER: drkiq
POSTGRES_PASSWORD: yourpassword
ports:
- '5432:5432'
volumes:
- drkiq-postgres:/var/lib/postgresql/data

redis:
image: redis:3.0.5
ports:
- '6379:6379'
volumes:
- drkiq-redis:/var/lib/redis/data

drkiq:
build: .
image: drkiq:tag
links:
- postgres
- redis
volumes:
- .:/drkiq
ports:
- '8000:8000'
env_file:
- .drkiq.env
sidekiq:
build: .
command: bundle exec sidekiq -C config/sidekiq.yml
image: sidekiq:tag
links:
- postgres
- redis
volumes:
- .:/drkiq
env_file:
- .drkiq.env

关于docker - kubernetes kompose up Unsupported env_file key,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51524820/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com