Kompose是一个将docker-compose配置转换成Kubernetes manifests的工具,官方网站为http://kompose.io/。
# Linux$ curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v0.5.0/kompose-linux-amd64 -o kompose# macOS$ curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v0.5.0/kompose-darwin-amd64 -o kompose# Windows$ curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v0.5.0/kompose-windows-amd64.exe -o kompose.exe# 放到PATH中$ chmod +x kompose$ sudo mv ./kompose /usr/local/bin/kompose
docker-compose.yaml
version: "2"services:redis-master:image: gcr.io/google_containers/redis:e2eports:- "6379"redis-slave:image: gcr.io/google_samples/gb-redisslave:v1ports:- "6379"environment:- GET_HOSTS_FROM=dnsfrontend:image: gcr.io/google-samples/gb-frontend:v4ports:- "80:80"environment:- GET_HOSTS_FROM=dnslabels:kompose.service.type: LoadBalancer
$ kompose upWe 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 Successfully created Service: redisINFO Successfully created Service: webINFO Successfully created Deployment: redisINFO Successfully created Deployment: webYour application has been deployed to Kubernetes. You can run 'kubectl get deployment,svc,pods,pvc' for details.
$ kompose convertINFO file "frontend-service.yaml" createdINFO file "redis-master-service.yaml" createdINFO file "redis-slave-service.yaml" createdINFO file "frontend-deployment.yaml" createdINFO file "redis-master-deployment.yaml" createdINFO file "redis-slave-deployment.yaml" created