Skip to content

Commit 8ff1959

Browse files
cdragechenopis
authored andcommitted
Update Kompose documentation
Updates the page with new installation details as well as some updated fixes (spelling errors, outdated information, etc.)
1 parent 62d4745 commit 8ff1959

File tree

1 file changed

+97
-96
lines changed

1 file changed

+97
-96
lines changed

docs/tools/kompose/user-guide.md

Lines changed: 97 additions & 96 deletions
Original file line numberDiff line numberDiff line change
@@ -14,45 +14,50 @@ redirect_from:
1414

1515
`kompose` is a tool to help users who are familiar with `docker-compose` move to **Kubernetes**. `kompose` takes a Docker Compose file and translates it into Kubernetes resources.
1616

17+
More information about Kompose can be found on the official [http://kompose.io](http://kompose.io/) site.
18+
1719
`kompose` is a convenience tool to go from local Docker development to managing your application with Kubernetes. Transformation of the Docker Compose format to Kubernetes resources manifest may not be exact, but it helps tremendously when first deploying an application on Kubernetes.
1820

1921
## Use Case
2022

2123
If you have a Docker Compose `docker-compose.yml` or a Docker Distributed Application Bundle `docker-compose-bundle.dab` file, you can convert it into Kubernetes deployments and services like this:
2224

2325
```console
24-
$ kompose --bundle docker-compose-bundle.dab convert
25-
WARN[0000]: Unsupported key networks - ignoring
26-
file "redis-svc.yaml" created
27-
file "web-svc.yaml" created
28-
file "web-deployment.yaml" created
29-
file "redis-deployment.yaml" created
30-
3126
$ kompose -f docker-compose.yml convert
32-
WARN[0000]: Unsupported key networks - ignoring
27+
WARN: Unsupported key networks - ignoring
3328
file "redis-svc.yaml" created
3429
file "web-svc.yaml" created
3530
file "web-deployment.yaml" created
3631
file "redis-deployment.yaml" created
3732
```
3833

39-
## Installation
34+
## Installation
4035

41-
Grab the latest [release](https://github.com/kubernetes-incubator/kompose/releases) for your OS, untar and extract the binary.
36+
We have multiple ways to install Kompose. Our prefered method is downloading the binary from the latest GitHub release.
4237

43-
### Linux
38+
### GitHub release
39+
40+
Kompose is released via GitHub on a three-week cycle, you can see all current releases on the [GitHub release page](https://github.com/kubernetes-incubator/kompose/releases).
41+
42+
The current release we use is `0.5.0`.
4443

4544
```sh
46-
wget https://github.com/kubernetes-incubator/kompose/releases/download/v0.1.2/kompose_linux-amd64.tar.gz
47-
tar -xvf kompose_linux-amd64.tar.gz --strip 1
48-
sudo mv kompose /usr/local/bin
45+
# Linux
46+
curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v0.5.0/kompose-linux-amd64 -o kompose
47+
48+
# macOS
49+
curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v0.5.0/kompose-darwin-amd64 -o kompose
50+
51+
# Windows
52+
curl -L https://github.com/kubernetes-incubator/kompose/releases/download/v0.5.0/kompose-windows-amd64.exe -o kompose.exe
4953
```
5054

51-
Kompose has support for two providers: OpenShift and Kubernetes.
52-
You can choose targeted provider either using global option `--provider`, or by setting environment variable `PROVIDER`.
53-
By setting environment variable `PROVIDER` you can permanently switch to OpenShift provider without need to always specify `--provider openshift` option.
54-
If no provider is specified Kubernetes is default provider.
55+
Make the binary executable and move it to your PATH (e.g. `/usr/local/bin`)
5556

57+
```sh
58+
chmod +x kompose
59+
sudo mv ./kompose /usr/local/bin/kompose
60+
```
5661

5762
## Kompose convert
5863

@@ -67,7 +72,7 @@ $ cd examples/
6772
$ ls
6873
docker-compose.yml docker-compose-bundle.dab docker-gitlab.yml docker-voting.yml
6974

70-
$ kompose -f docker-gitlab.yml convert
75+
$ kompose -f docker-gitlab.yml convert
7176
file "redisio-svc.yaml" created
7277
file "gitlab-svc.yaml" created
7378
file "postgresql-svc.yaml" created
@@ -84,8 +89,8 @@ You can try with a Docker Compose version 2 like this:
8489

8590
```console
8691
$ kompose --file docker-voting.yml convert
87-
WARN[0000]: Unsupported key networks - ignoring
88-
WARN[0000]: Unsupported key build - ignoring
92+
WARN Unsupported key networks - ignoring
93+
WARN Unsupported key build - ignoring
8994
file "worker-svc.yaml" created
9095
file "db-svc.yaml" created
9196
file "redis-svc.yaml" created
@@ -131,7 +136,7 @@ Using `--bundle, --dab` to specify a DAB file as below:
131136

132137
```console
133138
$ kompose --bundle docker-compose-bundle.dab convert
134-
WARN[0000]: Unsupported key networks - ignoring
139+
WARN: Unsupported key networks - ignoring
135140
file "redis-svc.yaml" created
136141
file "web-svc.yaml" created
137142
file "web-deployment.yaml" created
@@ -142,44 +147,44 @@ file "redis-deployment.yaml" created
142147

143148
```console
144149
$ kompose --provider openshift --file docker-voting.yml convert
145-
WARN[0000] [worker] Service cannot be created because of missing port.
146-
INFO[0000] file "vote-service.yaml" created
147-
INFO[0000] file "db-service.yaml" created
148-
INFO[0000] file "redis-service.yaml" created
149-
INFO[0000] file "result-service.yaml" created
150-
INFO[0000] file "vote-deploymentconfig.yaml" created
151-
INFO[0000] file "vote-imagestream.yaml" created
152-
INFO[0000] file "worker-deploymentconfig.yaml" created
153-
INFO[0000] file "worker-imagestream.yaml" created
154-
INFO[0000] file "db-deploymentconfig.yaml" created
155-
INFO[0000] file "db-imagestream.yaml" created
156-
INFO[0000] file "redis-deploymentconfig.yaml" created
157-
INFO[0000] file "redis-imagestream.yaml" created
158-
INFO[0000] file "result-deploymentconfig.yaml" created
159-
INFO[0000] file "result-imagestream.yaml" created
150+
WARN [worker] Service cannot be created because of missing port.
151+
INFO file "vote-service.yaml" created
152+
INFO file "db-service.yaml" created
153+
INFO file "redis-service.yaml" created
154+
INFO file "result-service.yaml" created
155+
INFO file "vote-deploymentconfig.yaml" created
156+
INFO file "vote-imagestream.yaml" created
157+
INFO file "worker-deploymentconfig.yaml" created
158+
INFO file "worker-imagestream.yaml" created
159+
INFO file "db-deploymentconfig.yaml" created
160+
INFO file "db-imagestream.yaml" created
161+
INFO file "redis-deploymentconfig.yaml" created
162+
INFO file "redis-imagestream.yaml" created
163+
INFO file "result-deploymentconfig.yaml" created
164+
INFO file "result-imagestream.yaml" created
160165
```
161166

162167
In similar way you can convert DAB files to OpenShift.
163-
```console$
168+
```console
164169
$ kompose --bundle docker-compose-bundle.dab --provider openshift convert
165-
WARN[0000]: Unsupported key networks - ignoring
166-
INFO[0000] file "redis-svc.yaml" created
167-
INFO[0000] file "web-svc.yaml" created
168-
INFO[0000] file "web-deploymentconfig.yaml" created
169-
INFO[0000] file "web-imagestream.yaml" created
170-
INFO[0000] file "redis-deploymentconfig.yaml" created
171-
INFO[0000] file "redis-imagestream.yaml" created
170+
WARN: Unsupported key networks - ignoring
171+
INFO file "redis-svc.yaml" created
172+
INFO file "web-svc.yaml" created
173+
INFO file "web-deploymentconfig.yaml" created
174+
INFO file "web-imagestream.yaml" created
175+
INFO file "redis-deploymentconfig.yaml" created
176+
INFO file "redis-imagestream.yaml" created
172177
```
173178

174179
It also supports creating buildconfig for build directive in a service. By default, it uses the remote repo for the current git branch as the source repo, and the current branch as the source branch for the build. You can specify a different source repo and branch using ``--build-repo`` and ``--build-branch`` options respectively.
175180

176181
```console
177-
kompose --provider openshift --file buildconfig/docker-compose.yml convert
178-
WARN[0000] [foo] Service cannot be created because of missing port.
179-
INFO[0000] Buildconfig using [email protected]:rtnpro/kompose.git::master as source.
180-
INFO[0000] file "foo-deploymentconfig.yaml" created
181-
INFO[0000] file "foo-imagestream.yaml" created
182-
INFO[0000] file "foo-buildconfig.yaml" created
182+
$ kompose --provider openshift --file buildconfig/docker-compose.yml convert
183+
WARN [foo] Service cannot be created because of missing port.
184+
INFO Buildconfig using [email protected]:rtnpro/kompose.git::master as source.
185+
INFO file "foo-deploymentconfig.yaml" created
186+
INFO file "foo-imagestream.yaml" created
187+
INFO file "foo-buildconfig.yaml" created
183188
```
184189

185190
**Note**: If you are manually pushing the Openshift artifacts using ``oc create -f``, you need to ensure that you push the imagestream artifact before the buildconfig artifact, to workaround this Openshift issue: https://github.com/openshift/origin/issues/4518 .
@@ -195,12 +200,12 @@ $ kompose --file ./examples/docker-guestbook.yml up
195200
We are going to create Kubernetes deployments and services for your Dockerized application.
196201
If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.
197202

198-
INFO[0000] Successfully created service: redis-master
199-
INFO[0000] Successfully created service: redis-slave
200-
INFO[0000] Successfully created service: frontend
201-
INFO[0001] Successfully created deployment: redis-master
202-
INFO[0001] Successfully created deployment: redis-slave
203-
INFO[0001] Successfully created deployment: frontend
203+
INFO Successfully created service: redis-master
204+
INFO Successfully created service: redis-slave
205+
INFO Successfully created service: frontend
206+
INFO Successfully created deployment: redis-master
207+
INFO Successfully created deployment: redis-slave
208+
INFO Successfully created deployment: frontend
204209

205210
Your application has been deployed to Kubernetes. You can run 'kubectl get deployment,svc,pods' for details.
206211

@@ -222,7 +227,6 @@ po/redis-master-1432129712-63jn8 1/1 Running 0 4m
222227
po/redis-slave-2504961300-nve7b 1/1 Running 0 4m
223228
```
224229
Note:
225-
226230
- You must have a running Kubernetes cluster with a pre-configured kubectl context.
227231
- Only deployments and services are generated and deployed to Kubernetes. If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.
228232

@@ -232,15 +236,15 @@ $kompose --file ./examples/docker-guestbook.yml --provider openshift up
232236
We are going to create OpenShift DeploymentConfigs and Services for your Dockerized application.
233237
If you need different kind of resources, use the 'kompose convert' and 'oc create -f' commands instead.
234238

235-
INFO[0000] Successfully created service: redis-slave
236-
INFO[0000] Successfully created service: frontend
237-
INFO[0000] Successfully created service: redis-master
238-
INFO[0000] Successfully created deployment: redis-slave
239-
INFO[0000] Successfully created ImageStream: redis-slave
240-
INFO[0000] Successfully created deployment: frontend
241-
INFO[0000] Successfully created ImageStream: frontend
242-
INFO[0000] Successfully created deployment: redis-master
243-
INFO[0000] Successfully created ImageStream: redis-master
239+
INFO Successfully created service: redis-slave
240+
INFO Successfully created service: frontend
241+
INFO Successfully created service: redis-master
242+
INFO Successfully created deployment: redis-slave
243+
INFO Successfully created ImageStream: redis-slave
244+
INFO Successfully created deployment: frontend
245+
INFO Successfully created ImageStream: frontend
246+
INFO Successfully created deployment: redis-master
247+
INFO Successfully created ImageStream: redis-master
244248

245249
Your application has been deployed to OpenShift. You can run 'oc get dc,svc,is' for details.
246250

@@ -260,7 +264,6 @@ is/redis-slave 172.30.12.200:5000/fff/redis-slave v1
260264
```
261265

262266
Note:
263-
264267
- You must have a running OpenShift cluster with a pre-configured `oc` context (`oc login`)
265268

266269
## Kompose down
@@ -269,12 +272,12 @@ Once you have deployed "composed" application to Kubernetes, `kompose down` will
269272

270273
```console
271274
$ kompose --file docker-guestbook.yml down
272-
INFO[0000] Successfully deleted service: redis-master
273-
INFO[0004] Successfully deleted deployment: redis-master
274-
INFO[0004] Successfully deleted service: redis-slave
275-
INFO[0008] Successfully deleted deployment: redis-slave
276-
INFO[0009] Successfully deleted service: frontend
277-
INFO[0013] Successfully deleted deployment: frontend
275+
INFO Successfully deleted service: redis-master
276+
INFO Successfully deleted deployment: redis-master
277+
INFO Successfully deleted service: redis-slave
278+
INFO Successfully deleted deployment: redis-slave
279+
INFO Successfully deleted service: frontend
280+
INFO Successfully deleted deployment: frontend
278281
```
279282
Note:
280283
- You must have a running Kubernetes cluster with a pre-configured kubectl context.
@@ -284,16 +287,16 @@ Note:
284287
The default `kompose` transformation will generate Kubernetes [Deployments](http://kubernetes.io/docs/user-guide/deployments/) and [Services](http://kubernetes.io/docs/user-guide/services/), in yaml format. You have alternative option to generate json with `-j`. Also, you can alternatively generate [Replication Controllers](http://kubernetes.io/docs/user-guide/replication-controller/) objects, [Deamon Sets](http://kubernetes.io/docs/admin/daemons/), or [Helm](https://github.com/helm/helm) charts.
285288

286289
```console
287-
$ kompose convert
288-
file "redis-svc.yaml" created
289-
file "web-svc.yaml" created
290-
file "redis-deployment.yaml" created
291-
file "web-deployment.yaml" created
290+
$ kompose convert -j
291+
file "redis-svc.json" created
292+
file "web-svc.json" created
293+
file "redis-deployment.json" created
294+
file "web-deployment.json" created
292295
```
293296
The `*-deployment.json` files contain the Deployment objects.
294297

295298
```console
296-
$ kompose convert --rc
299+
$ kompose convert --rc
297300
file "redis-svc.yaml" created
298301
file "web-svc.yaml" created
299302
file "redis-rc.yaml" created
@@ -303,7 +306,7 @@ file "web-rc.yaml" created
303306
The `*-rc.yaml` files contain the Replication Controller objects. If you want to specify replicas (default is 1), use `--replicas` flag: `$ kompose convert --rc --replicas 3`
304307

305308
```console
306-
$ kompose convert --ds
309+
$ kompose convert --ds
307310
file "redis-svc.yaml" created
308311
file "web-svc.yaml" created
309312
file "redis-daemonset.yaml" created
@@ -315,7 +318,7 @@ The `*-daemonset.yaml` files contain the Daemon Set objects
315318
If you want to generate a Chart to be used with [Helm](https://github.com/kubernetes/helm) simply do:
316319

317320
```console
318-
$ kompose convert -c
321+
$ kompose convert -c
319322
file "web-svc.yaml" created
320323
file "redis-svc.yaml" created
321324
file "web-deployment.yaml" created
@@ -337,11 +340,7 @@ The chart structure is aimed at providing a skeleton for building your Helm char
337340

338341
## Unsupported docker-compose configuration options
339342

340-
Currently `kompose` does not support the following Docker Compose options.
341-
342-
```
343-
"build", "cgroup_parent", "devices", "depends_on", "dns", "dns_search", "domainname", "env_file", "extends", "external_links", "extra_hosts", "hostname", "ipc", "logging", "mac_address", "mem_limit", "memswap_limit", "network_mode", "networks", "pid", "security_opt", "shm_size", "stop_signal", "volume_driver", "uts", "read_only", "stdin_open", "tty", "user", "ulimits", "dockerfile", "net"
344-
```
343+
Currently `kompose` does not support some Docker Compose options, which are listed on the [conversion](http://kompose.io/conversion/) document.
345344

346345
For example:
347346

@@ -356,9 +355,9 @@ nginx:
356355
container_name: foobar
357356

358357
$ kompose -f nginx.yml convert
359-
WARN[0000] Unsupported key build - ignoring
360-
WARN[0000] Unsupported key cap_add - ignoring
361-
WARN[0000] Unsupported key dockerfile - ignoring
358+
WARN Unsupported key build - ignoring
359+
WARN Unsupported key cap_add - ignoring
360+
WARN Unsupported key dockerfile - ignoring
362361
```
363362

364363
## Labels
@@ -427,13 +426,15 @@ If you want to create normal pods without controllers you can use `restart` cons
427426

428427
**Note**: controller object could be `deployment` or `replicationcontroller`, etc.
429428

430-
For e.g. `mariadb` service will become pod down here.
431-
432429
```yaml
433-
version: "2"
430+
version: '2'
434431
435432
services:
436-
mariadb:
437-
image: centos/mariadb
438-
restart: "no"
433+
pival:
434+
image: perl
435+
command: ["perl", "-Mbignum=bpi", "-wle", "print bpi(2000)"]
436+
restart: "on-failure"
439437
```
438+
439+
#### Warning about DeploymentConfig
440+
If the Docker Compose file has a volume specified for a service, the Deployment (Kubernetes) or DeploymentConfig (OpenShift) strategy is changed to "Recreate" instead of "RollingUpdate" (default). This is done to avoid multiple instances of a service from accessing a volume at the same time.

0 commit comments

Comments
 (0)