我有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:4001
或10.0.0.180:4001
進行測試,我發現它一直在等待。
我不知道我是否設置了錯誤或錯過了一些步驟。請幫幫我。
感謝
你運行'kubectl得到部署,SVC,豆莢,pvc'作爲建議的最後一行,爲了看所有部署,服務,吊艙,批量聲明都處於就緒狀態? –
另外,這樣我們可以提出更好的問題:這是您與kubernetes的第一次接觸,以前只有碼頭工作者的經歷,或者您是否熟悉kubernetes,但是遇到這種情況有困難? –