首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >无法使用kompose从docker-compose转换为kubernetes

无法使用kompose从docker-compose转换为kubernetes
EN

Stack Overflow用户
提问于 2017-08-02 01:48:14
回答 1查看 1.1K关注 0票数 1

我有一个项目与码头-组成安装准备。现在我想转到kubernetes。我使用Kompose工具将docker-compose转换为kubernetes。

例如,下面是我的示例docker-compose.yml文件

代码语言:javascript
复制
version: '3'
volumes:
  database_hades_volume:
    external: true
services:
  db:
    image: postgres:latest
    container_name: hades-db
    ports:
      - "5432:5432"
    environment:
      POSTGRES_DB: hades_dev
      POSTGRES_PASSWORD: 1234
    volumes:
    - database_hades_volume:/var/lib/postgresql/data/
    tty: true
    stdin_open: true
  redis:
    container_name: hades-redis
    image: redis:latest
    ports:
      - "6379:6379"
  app:
    container_name: hades-app
    build:
      context: .
      dockerfile: Dockerfile
    ports:
      - "4001:4001"
    volumes:
      - ".:/webapp"
    env_file:
      - ./.env.docker_compose-dev
    depends_on:
      - db
      - redis

我已经使用以下命令成功运行:docker-compose up。现在,我使用kompose通过以下命令转换为kubernetes:

代码语言:javascript
复制
kompose convert

然后,我使用以下命令运行:

代码语言:javascript
复制
kompose up

以下是命令行结果信息:

代码语言:javascript
复制
INFO We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.

INFO Deploying application in "default" namespace
INFO Successfully created Service: app
INFO Successfully created Service: db
INFO Successfully created Service: redis
INFO Successfully created Deployment: app
INFO Successfully created PersistentVolumeClaim: app-claim0 of size 100Mi. If your cluster has dynamic storage provisioning, you don't have to do anything. Otherwise you have to create PersistentVolume to make PVC work
INFO Successfully created Deployment: db
INFO Successfully created PersistentVolumeClaim: database-hades-volume of size 100Mi. If your cluster has dynamic storage provisioning, you don't have to do anything. Otherwise you have to create PersistentVolume to make PVC work
INFO Successfully created Deployment: redis

Your application has been deployed to Kubernetes. You can run 'kubectl get deployment,svc,pods,pvc' for details.

但是,当我尝试通过localhost:400110.0.0.180:4001进行测试时,我发现它永远都在等待。

我不知道我是不是设置错了什么或者错过了什么步骤。请帮帮我。

谢谢

EN

回答 1

Stack Overflow用户

发布于 2017-08-11 13:28:37

您的docker-compose文件包含build密钥,这意味着您有用于app服务的源代码/docker文件,

代码语言:javascript
复制
NAME                        READY     STATUS              RESTARTS   AGE
po/app-2119952459-b4jtb     0/1       ErrImagePull        0          24s

状态是ErrImagePull,因为集群找不到任何镜像,所以除了build密钥之外,还要提供image密钥,例如。

代码语言:javascript
复制
app:
  container_name: hades-app
  build:
    context: .
    dockerfile: Dockerfile
  image: <username>/<imagename>:<tag>

因为,现在kompose具有本地构建和推送支持的功能,所以kompose将构建您的镜像,推送到dockerhub,然后您的集群可以在部署时从那里拉取镜像。

命令可以是这样的,

代码语言:javascript
复制
kompose up --build=local

我希望这是有意义的

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/45444585

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档