docs/content/compose/bridge/usage.md

4.1 KiB

title description keywords
Use the default Compose Bridge transformation Learn about and use the Compose Bridge default transformation compose, bridge, kubernetes

{{< include "compose-bridge-early-access.md" >}}

Compose Bridge supplies an out-of-the box transformation for your Compose configuration file. Based on an arbitrary compose.yaml file, Compose Bridge produces:

  • A Namespace so all your resources are isolated and don't conflict with resources from other deployments.
  • A ConfigMap with an entry for each and every config resource in your Compose application.
  • Deployments for application services. This ensures that the specified number of instances of your application are maintained in the Kubernetes cluster.
  • Services for ports exposed by your services, used for service-to-service communication.
  • Services for ports published by your services, with type LoadBalancer so that Docker Desktop will also expose the same port on the host.
  • Network policies to replicate the networking topology defined in your compose.yaml file.
  • PersistentVolumeClaims for your volumes, using hostpath storage class so that Docker Desktop manages volume creation.
  • Secrets with your secret encoded. This is designed for local use in a testing environment.

It also supplies a Kustomize overlay dedicated to Docker Desktop with:

  • Loadbalancer for services which need to expose ports on host.
  • A PersistentVolumeClaim to use the Docker Desktop storage provisioner desktop-storage-provisioner to handle volume provisioning more effectively.
  • A Kustomize file to link all the resources together.

Use the default Compose Bridge transformation

To use the default transformation run the following command:

$ compose-bridge convert

Compose looks for a compose.yaml file inside the current directory and then converts it.

The following output is displayed

$ compose-bridge convert -f compose.yaml 
Kubernetes resource api-deployment.yaml created
Kubernetes resource db-deployment.yaml created
Kubernetes resource web-deployment.yaml created
Kubernetes resource api-expose.yaml created
Kubernetes resource db-expose.yaml created
Kubernetes resource web-expose.yaml created
Kubernetes resource 0-avatars-namespace.yaml created
Kubernetes resource default-network-policy.yaml created
Kubernetes resource private-network-policy.yaml created
Kubernetes resource public-network-policy.yaml created
Kubernetes resource db-db_data-persistentVolumeClaim.yaml created
Kubernetes resource api-service.yaml created
Kubernetes resource web-service.yaml created
Kubernetes resource kustomization.yaml created
Kubernetes resource db-db_data-persistentVolumeClaim.yaml created
Kubernetes resource api-service.yaml created
Kubernetes resource web-service.yaml created
Kubernetes resource kustomization.yaml created

These files are then stored within your project in the /out folder.

The Kubernetes manifests can then be used to run the application on Kubernetes using the standard deployment command kubectl apply -k out/overlays/desktop/.

[!NOTE]

Make sure you have enabled Kubernetes in Docker Desktop before you deploy your Compose Bridge transformations.

If you want to convert a compose.yaml file that is located in another directory, you can run:

$ compose-bridge convert -f <path-to-file>/compose.yaml 

[!TIP]

Run compose-bridge convert --help to see all available flags.

What's next?