[go: up one dir, main page]

{ const container = $el; // The div with overflow const item = document.getElementById('sidebar-current-page') if (item) { const containerTop = container.scrollTop; const containerBottom = containerTop + container.clientHeight; const itemTop = item.offsetTop - container.offsetTop; const itemBottom = itemTop + item.offsetHeight; // Scroll only if the item is out of view if (itemBottom > containerBottom - 200) { container.scrollTop = itemTop - (container.clientHeight / 2 - item.offsetHeight / 2); } } })" class="bg-background-toc dark:bg-background-toc fixed top-0 z-40 hidden h-screen w-full flex-none overflow-x-hidden overflow-y-auto md:sticky md:top-16 md:z-auto md:block md:h-[calc(100vh-64px)] md:w-[320px]" :class="{ 'hidden': ! $store.showSidebar }">
Contact support

Use the default Compose Bridge transformation

Requires: Docker Desktop 4.43.0 and later

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:

$ docker compose bridge convert

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

When successful, Compose Bridge generates Kubernetes manifests and logs output similar to the following:

$ docker 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/.

Important

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:

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

To see all available flags, run:

$ docker compose bridge convert --help
Tip

You can convert and deploy your Compose project to a Kubernetes cluster from the Compose file viewer.

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.

What's next?