Skip to content

Commit c5e01f0

Browse files
committed
Update documentation to reflect build/push and v3 changes
Adds a user guide on how to use the build/push functionality of Docker images to the user guide. Adds v3 documentation as well as cleans up the user guide as well. I also do minor changes such as removing `$ ` in the CLI examples, as it's easier to copy and paste without the `$ ` there (when double clicking). I've also changed the `console` yaml indicitors to `sh` since it doesn't matter / it's aliased, see: https://github.com/github/linguist/blob/master/lib/linguist/languages.yml
1 parent f823a22 commit c5e01f0

File tree

1 file changed

+84
-54
lines changed

1 file changed

+84
-54
lines changed

docs/user-guide.md

Lines changed: 84 additions & 54 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,30 @@
11
# User Guide
22

3-
- [Usage](#user-guide)
4-
* [Kompose convert](#kompose-convert)
5-
* [Kompose up](#kompose-up)
6-
* [Kompose down](#kompose-down)
7-
- [Alternate formats](#alternate-formats)
8-
- [Unsupported docker-compose configuration options](#unsupported-docker-compose-configuration-options)
9-
3+
- CLI
4+
- [`kompose convert`](#kompose-convert)
5+
- [`kompose up`](#kompose-up)
6+
- [`kompose down`](#kompose-down)
7+
- Documentation
8+
- [Build and Pushing Docker Images](#build-and-pushing-docker-images)
9+
- [Alternative Conversions](#alternative-conversions)
10+
- [Labels](#labels)
11+
- [Restart](#restart)
12+
- [Docker Compose Versions](#docker-compose-versions)
1013

1114
Kompose has support for two providers: OpenShift and Kubernetes.
1215
You can choose targeted provider either using global option `--provider`, or by setting environment variable `PROVIDER`.
1316
By setting environment variable `PROVIDER` you can permanently switch to OpenShift provider without need to always specify `--provider openshift` option.
1417
If no provider is specified Kubernetes is default provider.
1518

1619

17-
## Kompose convert
20+
## `kompose convert`
1821

1922
Currently Kompose supports to transform either Docker Compose file (both of v1 and v2) and [experimental Distributed Application Bundles](https://blog.docker.com/2016/06/docker-app-bundle/) into Kubernetes and OpenShift objects.
2023
There is a couple of sample files in the `examples/` directory for testing.
21-
You will convert the compose or dab file to Kubernetes or OpenShift objects with `kompose convert`.
24+
You will convert the compose or dab file to Kubernetes or OpenShift objects with `$ kompose convert`.
2225

2326
### Kubernetes
24-
```console
27+
```sh
2528
$ cd examples/
2629

2730
$ ls
@@ -42,7 +45,7 @@ gitlab-svc.yaml postgresql-svc.yaml redisio-deployment.yaml red
4245

4346
You can try with a Docker Compose version 2 like this:
4447

45-
```console
48+
```sh
4649
$ kompose --file docker-voting.yml convert
4750
WARN Unsupported key networks - ignoring
4851
WARN Unsupported key build - ignoring
@@ -64,7 +67,7 @@ db-svc.yaml docker-compose-bundle.dab docker-voting.yml redis-svc.yaml
6467

6568
You can also provide multiple docker-compose files at the same time:
6669

67-
```console
70+
```sh
6871
$ kompose -f docker-compose.yml -f docker-guestbook.yml convert
6972
INFO Kubernetes file "frontend-service.yaml" created
7073
INFO Kubernetes file "mlbparks-service.yaml" created
@@ -78,7 +81,7 @@ INFO Kubernetes file "mongodb-claim0-persistentvolumeclaim.yaml" created
7881
INFO Kubernetes file "redis-master-deployment.yaml" created
7982
INFO Kubernetes file "redis-slave-deployment.yaml" created
8083

81-
$ ls
84+
ls
8285
mlbparks-deployment.yaml mongodb-service.yaml redis-slave-service.jsonmlbparks-service.yaml
8386
frontend-deployment.yaml mongodb-claim0-persistentvolumeclaim.yaml redis-master-service.yaml
8487
frontend-service.yaml mongodb-deployment.yaml redis-slave-deployment.yaml
@@ -89,7 +92,7 @@ When multiple docker-compose files are provided the configuration is merged. Any
8992

9093
Using `--bundle, --dab` to specify a DAB file as below:
9194

92-
```console
95+
```sh
9396
$ kompose --bundle docker-compose-bundle.dab convert
9497
WARN: Unsupported key networks - ignoring
9598
INFO Kubernetes file "redis-svc.yaml" created
@@ -100,7 +103,7 @@ INFO Kubernetes file "redis-deployment.yaml" created
100103

101104
### OpenShift
102105

103-
```console
106+
```sh
104107
$ kompose --provider openshift --file docker-voting.yml convert
105108
WARN [worker] Service cannot be created because of missing port.
106109
INFO OpenShift file "vote-service.yaml" created
@@ -120,7 +123,7 @@ INFO OpenShift file "result-imagestream.yaml" created
120123
```
121124

122125
In similar way you can convert DAB files to OpenShift.
123-
```console
126+
```sh
124127
$ kompose --bundle docker-compose-bundle.dab --provider openshift convert
125128
WARN: Unsupported key networks - ignoring
126129
INFO OpenShift file "redis-svc.yaml" created
@@ -133,7 +136,7 @@ INFO OpenShift file "redis-imagestream.yaml" created
133136

134137
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.
135138

136-
```console
139+
```sh
137140
$ kompose --provider openshift --file buildconfig/docker-compose.yml convert
138141
WARN [foo] Service cannot be created because of missing port.
139142
INFO OpenShift Buildconfig using git@github.com:rtnpro/kompose.git::master as source.
@@ -144,13 +147,13 @@ INFO OpenShift file "foo-buildconfig.yaml" created
144147

145148
**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 .
146149

147-
## Kompose up
150+
## `kompose up`
148151

149152
Kompose supports a straightforward way to deploy your "composed" application to Kubernetes or OpenShift via `kompose up`.
150153

151154

152155
### Kubernetes
153-
```console
156+
```sh
154157
$ kompose --file ./examples/docker-guestbook.yml up
155158
We are going to create Kubernetes deployments and services for your Dockerized application.
156159
If you need different kind of resources, use the 'kompose convert' and 'kubectl create -f' commands instead.
@@ -186,8 +189,8 @@ Note:
186189
- 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.
187190

188191
### OpenShift
189-
```console
190-
$kompose --file ./examples/docker-guestbook.yml --provider openshift up
192+
```sh
193+
$ kompose --file ./examples/docker-guestbook.yml --provider openshift up
191194
We are going to create OpenShift DeploymentConfigs and Services for your Dockerized application.
192195
If you need different kind of resources, use the 'kompose convert' and 'oc create -f' commands instead.
193196

@@ -221,11 +224,11 @@ is/redis-slave 172.30.12.200:5000/fff/redis-slave v1
221224
Note:
222225
- You must have a running OpenShift cluster with a pre-configured `oc` context (`oc login`)
223226

224-
## Kompose down
227+
## `kompose down`
225228

226-
Once you have deployed "composed" application to Kubernetes, `kompose down` will help you to take the application out by deleting its deployments and services. If you need to remove other resources, use the 'kubectl' command.
229+
Once you have deployed "composed" application to Kubernetes, `$ kompose down` will help you to take the application out by deleting its deployments and services. If you need to remove other resources, use the 'kubectl' command.
227230

228-
```console
231+
```sh
229232
$ kompose --file docker-guestbook.yml down
230233
INFO Successfully deleted service: redis-master
231234
INFO Successfully deleted deployment: redis-master
@@ -237,11 +240,55 @@ INFO Successfully deleted deployment: frontend
237240
Note:
238241
- You must have a running Kubernetes cluster with a pre-configured kubectl context.
239242

240-
## Alternate formats
243+
## Building and Pushing Docker Images
244+
245+
Kompose supports both building and pushing Docker images. When using the `build` key within your Docker Compose file, your image will automatically be built and pushed.
246+
247+
Using an [example Docker Compose file](https://raw.githubusercontent.com/kubernetes-incubator/kompose/master/examples/buildconfig/docker-compose.yml):
248+
249+
```yaml
250+
version: "2"
251+
252+
services:
253+
foo:
254+
build: "./build"
255+
image: docker.io/foo/bar
256+
```
257+
258+
Using `kompose up` with a `build` key:
259+
260+
```sh
261+
$ kompose up
262+
INFO Build key detected. Attempting to build and push image 'docker.io/foo/bar'
263+
INFO Building image 'docker.io/foo/bar' from directory 'build'
264+
INFO Image 'docker.io/foo/bar' from directory 'build' built successfully
265+
INFO Pushing image 'foo/bar:latest' to registry 'docker.io'
266+
INFO Attempting authentication credentials 'https://index.docker.io/v1/
267+
INFO Successfully pushed image 'foo/bar:latest' to registry 'docker.io'
268+
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.
269+
270+
INFO Deploying application in "default" namespace
271+
INFO Successfully created Service: foo
272+
INFO Successfully created Deployment: foo
273+
274+
Your application has been deployed to Kubernetes. You can run 'kubectl get deployment,svc,pods,pvc' for details.
275+
```
276+
277+
In order to disable the functionality, or choose to use BuildConfig generation (with OpenShift) `--build (local|build-config|none)` can be passed.
278+
279+
```sh
280+
# Disable building/pushing Docker images
281+
$ kompose up --build none
282+
283+
# Generate Build Config artifacts for OpenShift
284+
$ kompose up --provider openshift --build build-config
285+
```
286+
287+
## Alternative Conversions
241288

242289
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.
243290

244-
```console
291+
```sh
245292
$ kompose convert -j
246293
INFO Kubernetes file "redis-svc.json" created
247294
INFO Kubernetes file "web-svc.json" created
@@ -250,7 +297,7 @@ INFO Kubernetes file "web-deployment.json" created
250297
```
251298
The `*-deployment.json` files contain the Deployment objects.
252299

253-
```console
300+
```sh
254301
$ kompose convert --replication-controller
255302
INFO Kubernetes file "redis-svc.yaml" created
256303
INFO Kubernetes file "web-svc.yaml" created
@@ -260,7 +307,7 @@ INFO Kubernetes file "web-replicationcontroller.yaml" created
260307

261308
The `*-replicationcontroller.yaml` files contain the Replication Controller objects. If you want to specify replicas (default is 1), use `--replicas` flag: `$ kompose convert --replication-controller --replicas 3`
262309

263-
```console
310+
```sh
264311
$ kompose convert --daemon-set
265312
INFO Kubernetes file "redis-svc.yaml" created
266313
INFO Kubernetes file "web-svc.yaml" created
@@ -272,15 +319,15 @@ The `*-daemonset.yaml` files contain the Daemon Set objects
272319

273320
If you want to generate a Chart to be used with [Helm](https://github.com/kubernetes/helm) simply do:
274321

275-
```console
322+
```sh
276323
$ kompose convert -c
277324
INFO Kubernetes file "web-svc.yaml" created
278325
INFO Kubernetes file "redis-svc.yaml" created
279326
INFO Kubernetes file "web-deployment.yaml" created
280327
INFO Kubernetes file "redis-deployment.yaml" created
281328
chart created in "./docker-compose/"
282329
283-
$ tree docker-compose/
330+
tree docker-compose/
284331
docker-compose
285332
├── Chart.yaml
286333
├── README.md
@@ -293,28 +340,6 @@ docker-compose
293340

294341
The chart structure is aimed at providing a skeleton for building your Helm charts.
295342

296-
## Unsupported docker-compose configuration options
297-
298-
Currently `kompose` does not support some Docker Compose options, which are listed on the [conversion](/docs/conversion.md) document.
299-
300-
For example:
301-
302-
```console
303-
$ cat nginx.yml
304-
nginx:
305-
image: nginx
306-
dockerfile: foobar
307-
build: ./foobar
308-
cap_add:
309-
- ALL
310-
container_name: foobar
311-
312-
$ kompose -f nginx.yml convert
313-
WARN Unsupported key build - ignoring
314-
WARN Unsupported key cap_add - ignoring
315-
WARN Unsupported key dockerfile - ignoring
316-
```
317-
318343
## Labels
319344

320345
`kompose` supports Kompose-specific labels within the `docker-compose.yml` file in order to explicitly define a service's behavior upon conversion.
@@ -394,11 +419,16 @@ services:
394419
restart: "on-failure"
395420
```
396421

397-
398422
#### Warning about Deployment Config's
399423

400424
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.
401425

402426
If the Docker Compose file has service name with `_` in it (eg.`web_service`), then it will be replaced by `-` and the service name will be renamed accordingly (eg.`web-service`). Kompose does this because "Kubernetes" doesn't allow `_` in object name.
403427

404-
Please note that changing service name might break some `docker-compose` files.
428+
Please note that changing service name might break some `docker-compose` files.
429+
430+
## Docker Compose Versions
431+
432+
Kompose supports Docker Compose versions: 1, 2 and 3. We have limited support on versions 2.1 and 3.2 due to their experimental nature.
433+
434+
A full list on compatibility between all three versions is listed in our [conversion document](/docs/conversion.md) including a list of all incompatible Docker Compose keys.

0 commit comments

Comments
 (0)