2017-08-01 44 views
0

我有docker-compose setup準備好的項目。現在我想轉移到kubernetes。我使用Kompose工具將docker-compose轉換爲kubernetes。不能使用kompose從docker-compose轉換成kubernetes

例如,這裏是我的樣本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 

我以命令成功運行:docker-compose up。現在,我用kompose通過使用命令轉換爲kubernetes:

kompose convert 

然後我運行使用:

kompose up 

下面是命令行的結果信息:

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進行測試,我發現它一直在等待。

我不知道我是否設置了錯誤或錯過了一些步驟。請幫幫我。

感謝

+0

你運行'kubectl得到部署,SVC,豆莢,pvc'作爲建議的最後一行,爲了看所有部署,服務,吊艙,批量聲明都處於就緒狀態? –

+0

另外,這樣我們可以提出更好的問題:這是您與kubernetes的第一次接觸,以前只有碼頭工作者的經歷,或者您是否熟悉kubernetes,但是遇到這種情況有困難? –

回答

0

你的搬運工,撰寫文件包含build關鍵,這意味着你擁有源代碼/ Dockerfile禮物app服務, 截至目前,

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

狀態爲ErrImagePull作爲集羣無法找到任何圖像,所以隨着build密鑰,還提供image密鑰,以及 爲前。 app: container_name: hades-app build: context: . dockerfile: Dockerfile image: <username>/<imagename>:<tag>

因爲,現在kompose具有本地構建的功能,推動支持, 所以kompose將建立你的形象,推到dockerhub然後羣集可以從那裏,同時部署拉形象。

命令可以像,

kompose up --build=local

我希望這是有道理的