Skip to content

Commit 7e3ab99

Browse files
authored
Engdocs 3051 (#23568)
<!--Delete sections as needed --> ## Description Freshens Compose Bridge content Adds model runner support ## Related issues or tickets <!-- Related issues, pull requests, or Jira tickets --> ## Reviews <!-- Notes for reviewers here --> <!-- List applicable reviews (optionally @tag reviewers) --> - [ ] Technical review - [ ] Editorial review - [ ] Product review
1 parent af67ce7 commit 7e3ab99

File tree

4 files changed

+221
-64
lines changed

4 files changed

+221
-64
lines changed

content/manuals/compose/bridge/_index.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,22 +8,31 @@ weight: 50
88

99
{{< summary-bar feature_name="Compose bridge" >}}
1010

11-
Compose Bridge converts your Docker Compose configuration into platform-specific formats—primarily Kubernetes manifests. The default transformation generates Kubernetes manifests and a Kustomize overlay which are designed for deployment on Docker Desktop with Kubernetes enabled.
11+
Compose Bridge converts your Docker Compose configuration into platform-specific deployment formats such as Kubernetes manifests. By default, it geneterates:
1212

13-
It's a flexible tool that lets you either take advantage of the [default transformation](usage.md) or [create a custom transformation](customize.md) to suit specific project needs and requirements.
13+
- Kubernetes manifests
14+
- A Kustomize overlay
1415

15-
Compose Bridge significantly simplifies the transition from Docker Compose to Kubernetes, making it easier for you to leverage the power of Kubernetes while maintaining the simplicity and efficiency of Docker Compose.
16+
These outputs are ready for deployment on Docker Desktop with [Kubernetes enabled](/manuals/desktop/settings-and-maintenance/settings.md#kubernetes).
17+
18+
Compose Bridge helps you bridge the gap between Compose and Kubernetes, making it easier to adopt Kubernetes while keeping the simplicity and efficiency of Compose.
19+
20+
It's a flexible tool that lets you either take advantage of the [default transformation](usage.md) or [create a custom transformation](customize.md) to suit specific project needs and requirements.
1621

1722
## How it works
1823

19-
Compose Bridge uses transformations to let you convert a Compose model into another form.
24+
Compose Bridge uses transformations to convert a Compose model into another form.
2025

2126
A transformation is packaged as a Docker image that receives the fully resolved Compose model as `/in/compose.yaml` and can produce any target format file under `/out`.
2227

2328
Compose Bridge provides its own transformation for Kubernetes using Go templates, so that it is easy to extend for customization by replacing or appending your own templates.
2429

2530
For more detailed information on how these transformations work and how you can customize them for your projects, see [Customize](customize.md).
2631

32+
Compose Bridge also supports applications that use LLMs via Docker Model Runner.
33+
34+
For more details, see [Use Model Runner](use-model-runner.md).
35+
2736
## What's next?
2837

2938
- [Use Compose Bridge](usage.md)

content/manuals/compose/bridge/customize.md

Lines changed: 53 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,13 @@ linkTitle: Customize
44
weight: 20
55
description: Learn how to customize Compose Bridge transformations using Go templates and Compose extensions
66
keywords: docker compose bridge, customize compose bridge, compose bridge templates, compose to kubernetes, compose bridge transformation, go templates docker
7-
87
---
98

109
{{< summary-bar feature_name="Compose bridge" >}}
1110

12-
This page explains how Compose Bridge utilizes templating to efficiently translate Docker Compose files into Kubernetes manifests. It also explains how you can customize these templates for your specific requirements and needs, or how you can build your own transformation.
11+
You can customize how Compose Bridge converts your Docker Compose files into platform-specific formats.
12+
13+
This page explains how Compose Bridge uses templating to generate Kubernetes manifests and how you can customize these templates for your specific requirements and needs, or how you can build your own transformation.
1314

1415
## How it works
1516

@@ -19,7 +20,7 @@ A transformation is packaged as a Docker image that receives the fully-resolved
1920

2021
Compose Bridge includes a default Kubernetes transformation using Go templates, which you can customize by replacing or extending templates.
2122

22-
### Syntax
23+
### Template syntax
2324

2425
Compose Bridge makes use of templates to transform a Compose configuration file into Kubernetes manifests. Templates are plain text files that use the [Go templating syntax](https://pkg.go.dev/text/template). This enables the insertion of logic and data, making the templates dynamic and adaptable according to the Compose model.
2526

@@ -43,9 +44,11 @@ key: value
4344
{{ end }}
4445
```
4546

46-
### Input
47+
### Input model
4748

48-
You can generate the input model by running `docker compose config`. This canonical YAML output serves as the input for Compose Bridge transformations. Within the templates, data from the `compose.yaml` is accessed using dot notation, allowing you to navigate through nested data structures. For example, to access the deployment mode of a service, you would use `service.deploy.mode`:
49+
You can generate the input model by running `docker compose config`.
50+
51+
This canonical YAML output serves as the input for Compose Bridge transformations. Within the templates, data from the `compose.yaml` is accessed using dot notation, allowing you to navigate through nested data structures. For example, to access the deployment mode of a service, you would use `service.deploy.mode`:
4952

5053
```yaml
5154
# iterate over a yaml sequence
@@ -57,22 +60,24 @@ kind: DaemonSet
5760
{{ end }}
5861
```
5962

60-
You can check the [Compose Specification JSON schema](https://github.com/compose-spec/compose-go/blob/main/schema/compose-spec.json) to have a full overview of the Compose model. This schema outlines all possible configurations and their data types in the Compose model.
63+
You can check the [Compose Specification JSON schema](https://github.com/compose-spec/compose-go/blob/main/schema/compose-spec.json) for a full overview of the Compose model. This schema outlines all possible configurations and their data types in the Compose model.
6164

62-
### Helpers
65+
### Helper functions
6366

6467
As part of the Go templating syntax, Compose Bridge offers a set of YAML helper functions designed to manipulate data within the templates efficiently:
6568

66-
- `seconds`: Converts a [duration](/reference/compose-file/extension.md#specifying-durations) into an integer
67-
- `uppercase`: Converts a string into upper case characters
68-
- `title`: Converts a string by capitalizing the first letter of each word
69-
- `safe`: Converts a string into a safe identifier, replacing all characters (except lowercase a-z) with `-`
70-
- `truncate`: Removes the N first elements from a list
71-
- `join`: Groups elements from a list into a single string, using a separator
72-
- `base64`: Encodes a string as base64 used in Kubernetes for encoding secrets
73-
- `map`: Transforms a value according to mappings expressed as `"value -> newValue"` strings
74-
- `indent`: Writes string content indented by N spaces
75-
- `helmValue`: Writes the string content as a template value in the final file
69+
| Function | Description |
70+
| ----------- | ----------------------------------------------------------------------------------------------------------- |
71+
| `seconds` | Converts a [duration](/reference/compose-file/extension.md#specifying-durations) into an integer (seconds). |
72+
| `uppercase` | Converts a string to uppercase. |
73+
| `title` | Capitalizes the first letter of each word. |
74+
| `safe` | Converts a string into a safe identifier (replaces non-lowercase characters with `-`). |
75+
| `truncate` | Removes the first N elements from a list. |
76+
| `join` | Joins list elements into a single string with a separator. |
77+
| `base64` | Encodes a string as base64 (used for Kubernetes secrets). |
78+
| `map` | Maps values using `“value -> newValue”` syntax. |
79+
| `indent` | Indents string content by N spaces. |
80+
| `helmValue` | Outputs a Helm-style template value. |
7681

7782
In the following example, the template checks if a healthcheck interval is specified for a service, applies the `seconds` function to convert this interval into seconds and assigns the value to the `periodSeconds` attribute.
7883

@@ -82,7 +87,7 @@ In the following example, the template checks if a healthcheck interval is speci
8287
{{ end }}
8388
```
8489

85-
## Customization
90+
## Customize the default templates
8691

8792
As Kubernetes is a versatile platform, there are many ways
8893
to map Compose concepts into Kubernetes resource definitions. Compose
@@ -91,29 +96,51 @@ decisions and preferences, with varying level of flexibility and effort.
9196

9297
### Modify the default templates
9398

94-
You can extract templates used by the default transformation `docker/compose-bridge-kubernetes`,
95-
by running `docker compose bridge transformations create --from docker/compose-bridge-kubernetes my-template`
96-
and adjusting the templates to match your needs.
99+
You can extract templates used by the default transformation `docker/compose-bridge-kubernetes`:
100+
101+
```console
102+
$ docker compose bridge transformations create --from docker/compose-bridge-kubernetes my-template
103+
```
104+
105+
The templates are extracted into a directory named after your template name, in this case `my-template`. It includes:
106+
107+
- A Dockerfile that lets you create your own image to distribute your template
108+
- A directory containing the templating files
109+
110+
Edit, [add](#add-your-own-templates), or remove templates as needed.
97111

98-
The templates are extracted into a directory named after your template name, in this case `my-template`.
99-
It includes a Dockerfile that lets you create your own image to distribute your template, as well as a directory containing the templating files.
100-
You are free to edit the existing files, delete them, or [add new ones](#add-your-own-templates) to subsequently generate Kubernetes manifests that meet your needs.
101112
You can then use the generated Dockerfile to package your changes into a new transformation image, which you can then use with Compose Bridge:
102113

103114
```console
104115
$ docker build --tag mycompany/transform --push .
105116
```
106117

107-
You can then use your transformation as a replacement:
118+
Use your transformation as a replacement:
108119

109120
```console
110121
$ docker compose bridge convert --transformations mycompany/transform
111122
```
112123

124+
#### Model Runner templates
125+
126+
The default transformation also includes templates for applications that use LLMs:
127+
128+
- `model-runner-deployment.tmpl`
129+
- `model-runner-service.tmpl`
130+
- `model-runner-pvc.tmpl`
131+
- `/overlays/model-runner/kustomization.yaml`
132+
- `/overlays/desktop/deployment.tmpl`
133+
134+
These templates can be extended or replaced to change how Docker Model Runner is deployed or configured.
135+
136+
For more details, see [Use Model Runner](use-model-runner.md).
137+
113138
### Add your own templates
114139

115140
For resources that are not managed by Compose Bridge's default transformation,
116-
you can build your own templates. The `compose.yaml` model may not offer all
141+
you can build your own templates.
142+
143+
The `compose.yaml` model may not offer all
117144
the configuration attributes required to populate the target manifest. If this is the case, you can
118145
then rely on Compose custom extensions to better describe the
119146
application, and offer an agnostic transformation.

content/manuals/compose/bridge/usage.md

Lines changed: 64 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,9 @@ keywords: docker compose bridge, compose kubernetes transform, kubernetes from c
88

99
{{< summary-bar feature_name="Compose bridge" >}}
1010

11-
Compose Bridge supplies an out-of-the-box transformation for your Compose configuration file. Based on an arbitrary `compose.yaml` file, Compose Bridge produces:
11+
Compose Bridge includes a built-in transformation that automatically converts your Compose configuration into a set of Kubernetes manifests.
12+
13+
Based on your `compose.yaml` file, it produces:
1214

1315
- A [Namespace](https://kubernetes.io/docs/concepts/overview/working-with-objects/namespaces/) so all your resources are isolated and don't conflict with resources from other deployments.
1416
- A [ConfigMap](https://kubernetes.io/docs/concepts/configuration/configmap/) with an entry for each and every [config](/reference/compose-file/configs.md) resource in your Compose application.
@@ -22,61 +24,74 @@ Compose Bridge supplies an out-of-the-box transformation for your Compose config
2224
It also supplies a Kustomize overlay dedicated to Docker Desktop with:
2325
- `Loadbalancer` for services which need to expose ports on host.
2426
- A `PersistentVolumeClaim` to use the Docker Desktop storage provisioner `desktop-storage-provisioner` to handle volume provisioning more effectively.
25-
- A Kustomize file to link all the resources together.
27+
- A `Kustomization.yaml` file to link all the resources together.
28+
29+
If your Compose file defines a `models` section for a service, Compose Bridge automatically configures your deployment so your service can locate and use its models via Docker Model Runner.
30+
31+
For each declared model, the transformation injects two environment variables:
32+
33+
- `<MODELNAME>_URL`: The endpoint for Docker Model Runner serving that model
34+
- `<MODELNAME>_MODEL`: The model’s name or identifier
35+
36+
You can optionally customize these variable names using `endpoint_var` and `model_var`.
37+
38+
The default transformation generates two different overlays - one for Docker Desktop whilst using a local instance of Docker Model Runner, and a `model-runner` overlay with all the relevant Kubernetes resources to deploy Docker Model Runner in a pod.
39+
40+
| Environment | Endpoint |
41+
| -------------- | ----------------------------------------------- |
42+
| Docker Desktop | `http://host.docker.internal:12434/engines/v1/` |
43+
| Kubernetes | `http://model-runner/engines/v1/` |
44+
45+
46+
For more details, see [Use Model Runner](use-model-runner.md).
2647

2748
## Use the default Compose Bridge transformation
2849

29-
To use the default transformation run the following command:
50+
To convert your Compose file using the default transformation:
3051

3152
```console
3253
$ docker compose bridge convert
3354
```
3455

35-
Compose looks for a `compose.yaml` file inside the current directory and then converts it.
56+
Compose looks for a `compose.yaml` file inside the current directory and generates Kubernetes manifests.
3657

37-
When successful, Compose Bridge generates Kubernetes manifests and logs output similar to the following:
58+
Example output:
3859

3960
```console
40-
$ docker compose bridge convert -f compose.yaml
41-
Kubernetes resource api-deployment.yaml created
42-
Kubernetes resource db-deployment.yaml created
43-
Kubernetes resource web-deployment.yaml created
44-
Kubernetes resource api-expose.yaml created
45-
Kubernetes resource db-expose.yaml created
46-
Kubernetes resource web-expose.yaml created
47-
Kubernetes resource 0-avatars-namespace.yaml created
61+
$ docker compose -f compose.yaml bridge convert
62+
Kubernetes resource backend-deployment.yaml created
63+
Kubernetes resource frontend-deployment.yaml created
64+
Kubernetes resource backend-expose.yaml created
65+
Kubernetes resource frontend-expose.yaml created
66+
Kubernetes resource 0-my-project-namespace.yaml created
4867
Kubernetes resource default-network-policy.yaml created
49-
Kubernetes resource private-network-policy.yaml created
50-
Kubernetes resource public-network-policy.yaml created
51-
Kubernetes resource db-db_data-persistentVolumeClaim.yaml created
52-
Kubernetes resource api-service.yaml created
53-
Kubernetes resource web-service.yaml created
68+
Kubernetes resource backend-service.yaml created
69+
Kubernetes resource frontend-service.yaml created
5470
Kubernetes resource kustomization.yaml created
55-
Kubernetes resource db-db_data-persistentVolumeClaim.yaml created
56-
Kubernetes resource api-service.yaml created
57-
Kubernetes resource web-service.yaml created
71+
Kubernetes resource backend-deployment.yaml created
72+
Kubernetes resource frontend-deployment.yaml created
73+
Kubernetes resource backend-service.yaml created
74+
Kubernetes resource frontend-service.yaml created
75+
Kubernetes resource kustomization.yaml created
76+
Kubernetes resource model-runner-configmap.yaml created
77+
Kubernetes resource model-runner-deployment.yaml created
78+
Kubernetes resource model-runner-service.yaml created
79+
Kubernetes resource model-runner-volume-claim.yaml created
5880
Kubernetes resource kustomization.yaml created
5981
```
6082

61-
These files are then stored within your project in the `/out` folder.
83+
All generated files are stored in the `/out` directory in your project.
6284

63-
The Kubernetes manifests can then be used to run the application on Kubernetes using
64-
the standard deployment command `kubectl apply -k out/overlays/desktop/`.
85+
## Deploy the generated manifests
6586

6687
> [!IMPORTANT]
6788
>
68-
> Make sure you have enabled Kubernetes in Docker Desktop before you deploy your Compose Bridge transformations.
89+
> Before you deploy your Compose Bridge transformations, make sure you have [enabled Kubernetes](/manuals/desktop/settings-and-maintenance/settings.md#kubernetes) in Docker Desktop.
6990
70-
If you want to convert a `compose.yaml` file that is located in another directory, you can run:
91+
Once the manifests are generated, deploy them to your local Kubernetes cluster:
7192

7293
```console
73-
$ docker compose bridge convert -f <path-to-file>/compose.yaml
74-
```
75-
76-
To see all available flags, run:
77-
78-
```console
79-
$ docker compose bridge convert --help
94+
$ kubectl apply -k out/overlays/desktop/
8095
```
8196

8297
> [!TIP]
@@ -85,6 +100,21 @@ $ docker compose bridge convert --help
85100
>
86101
> Make sure you are signed in to your Docker account, navigate to your container in the **Containers** view, and in the top-right corner select **View configurations** and then **Convert and Deploy to Kubernetes**.
87102
103+
## Additional commands
104+
105+
Convert a `compose.yaml` file located in another directory:
106+
107+
```console
108+
$ docker compose -f <path-to-file>/compose.yaml bridge convert
109+
```
110+
111+
To see all available flags, run:
112+
113+
```console
114+
$ docker compose bridge convert --help
115+
```
116+
88117
## What's next?
89118

90-
- [Explore how you can customize Compose Bridge](customize.md)
119+
- [Explore how you can customize Compose Bridge](customize.md)
120+
- [Use Model Runner](use-model-runner.md).

0 commit comments

Comments
 (0)