Kompose
Kompose是一个将docker-compose配置转换成Kubernetes manifests的工具,官方网站为http://kompose.io/

Kompose安装

1
# Linux
2
$ curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v0.5.0/kompose-linux-amd64 -o kompose
3
4
# macOS
5
$ curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v0.5.0/kompose-darwin-amd64 -o kompose
6
7
# Windows
8
$ curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v0.5.0/kompose-windows-amd64.exe -o kompose.exe
9
10
# 放到PATH中
11
$ chmod +x kompose
12
$ sudo mv ./kompose /usr/local/bin/kompose
Copied!

Kompose使用

docker-compose.yaml
1
version: "2"
2
3
services:
4
5
redis-master:
6
image: gcr.io/google_containers/redis:e2e
7
ports:
8
- "6379"
9
10
redis-slave:
11
image: gcr.io/google_samples/gb-redisslave:v1
12
ports:
13
- "6379"
14
environment:
15
- GET_HOSTS_FROM=dns
16
17
frontend:
18
image: gcr.io/google-samples/gb-frontend:v4
19
ports:
20
- "80:80"
21
environment:
22
- GET_HOSTS_FROM=dns
23
labels:
24
kompose.service.type: LoadBalancer
Copied!

kompose up

1
$ kompose up
2
We are going to create Kubernetes Deployments, Services and PersistentVolumeClaims for your Dockerized application.
3
If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.
4
5
INFO Successfully created Service: redis
6
INFO Successfully created Service: web
7
INFO Successfully created Deployment: redis
8
INFO Successfully created Deployment: web
9
10
Your application has been deployed to Kubernetes. You can run 'kubectl get deployment,svc,pods,pvc' for details.
Copied!

kompose convert

1
$ kompose convert
2
INFO file "frontend-service.yaml" created
3
INFO file "redis-master-service.yaml" created
4
INFO file "redis-slave-service.yaml" created
5
INFO file "frontend-deployment.yaml" created
6
INFO file "redis-master-deployment.yaml" created
7
INFO file "redis-slave-deployment.yaml" created
Copied!
最近更新 2yr ago