简体   繁体   English

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

[英]Cannot use kompose for converting from docker-compose to kubernetes

I have project with docker-compose setup ready. 我有准备好docker-compose安装程序的项目。 Now I want to move to kubernetes. 现在我想转到kubernetes。 I use Kompose tool for converting from docker-compose to kubernetes. 我使用Kompose工具从docker-compose转换为kubernetes。

For example, here is my sample docker-compose.yml file 例如,这是我的示例docker-compose.yml文件

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

I have run successfully by using command: docker-compose up . 我已经使用命令docker-compose up成功运行docker-compose up Now, I use kompose for converting to kubernetes by using command: 现在,我使用kompose通过使用命令转换为kubernetes:

kompose convert

Then I run by using: 然后,我使用以下命令运行:

kompose up

Here is command line result information: 这是命令行结果信息:

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.

But when I try to test by going to localhost:4001 or 10.0.0.180:4001 , I see that it's waiting forever. 但是,当我尝试通过localhost:400110.0.0.180:4001进行测试时,我看到它一直在等待。

I don't know if I have setup something wrong or miss some steps. 我不知道我是否设置错误或错过了一些步骤。 Please help me. 请帮我。

Thanks 谢谢

Your docker-compose file contains build key which means you have source code/Dockerfile present for app service, As of now, 您的docker-compose文件包含build密钥,这意味着您拥有用于app服务的源代码/ Dockerfile,到目前为止,

NAME READY STATUS RESTARTS AGE po/app-2119952459-b4jtb 0/1 ErrImagePull 0 24s

Status is ErrImagePull as cluster is not able to find any image, so along with build key, provide image key as well, for ex. 状态为ErrImagePull因为群集无法找到任何图像,因此,除了build密钥外,还要提供image密钥,例如。 app: container_name: hades-app build: context: . dockerfile: Dockerfile image: <username>/<imagename>:<tag>

Because, now kompose has feature of local build and push support, So kompose will build your image, push to dockerhub and then your cluster can pull image from there while deploying. 因为,现在kompose具有本地构建和推送支持功能,因此kompose将构建您的映像,推送到dockerhub,然后您的集群可以在部署时从那里拉映像。

commands can be like, 命令可以像

kompose up --build=local

I hope this makes sense 我希望这是有道理的

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

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