参考
インストール
1 2 3 4 |
curl -L https://github.com/kubernetes/kompose/releases/download/v1.19.0 /kompose-linux-amd64 -o kompose chmod +x kompose sudo mv ./kompose /usr/local/bin/kompose |
サンプルファイル
1 2 |
wget https://raw.githubusercontent.com/kubernetes/kompose/master/examples/ docker-compose-v3.yaml -O docker-compose.yaml |
docker-compose.yaml
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 |
<span class="na">version</span><span class="pi">:</span> <span class="s2">"</span><span class="s">3"</span> <span class="na">services</span><span class="pi">:</span> <span class="na">redis-master</span><span class="pi">:</span> <span class="na">image</span><span class="pi">:</span> <span class="s">k8s.gcr.io/redis:e2e</span> <span class="na">ports</span><span class="pi">:</span> <span class="pi">-</span> <span class="s2">"</span><span class="s">6379"</span> <span class="na">redis-slave</span><span class="pi">:</span> <span class="na">image</span><span class="pi">:</span> <span class="s">gcr.io/google_samples/gb-redisslave:v1</span> <span class="na">ports</span><span class="pi">:</span> <span class="pi">-</span> <span class="s2">"</span><span class="s">6379"</span> <span class="na">environment</span><span class="pi">:</span> <span class="pi">-</span> <span class="s">GET_HOSTS_FROM=dns</span> <span class="na">frontend</span><span class="pi">:</span> <span class="na">image</span><span class="pi">:</span> <span class="s">gcr.io/google-samples/gb-frontend:v4</span> <span class="na">ports</span><span class="pi">:</span> <span class="pi">-</span> <span class="s2">"</span><span class="s">80:80"</span> <span class="na">environment</span><span class="pi">:</span> <span class="pi">-</span> <span class="s">GET_HOSTS_FROM=dns</span> <span class="na">labels</span><span class="pi">:</span> <span class="s">kompose.service.type</span><span class="pi">:</span> <span class="s">LoadBalancer</span> |
変換
1 |
kompose convert |
出力
1 2 3 4 5 6 |
INFO Kubernetes file "frontend-service.yaml" created INFO Kubernetes file "redis-master-service.yaml" created INFO Kubernetes file "redis-slave-service.yaml" created INFO Kubernetes file "frontend-deployment.yaml" created INFO Kubernetes file "redis-master-deployment.yaml" created INFO Kubernetes file "redis-slave-deployment.yaml" created |
Warningなど出た場合は手動で変換してあげれば良い