Deploying a Compose-based app to a Kubernetes cluster

You can use MKE to deploy Docker Compose files to Kubernetes clusters. To do so, you need access to a Kubernetes namespace. The example namespace used in this topics is called labs.

Create a Kubernetes app from a Compose file

The following example describes how to use a Compose file to create a simple app named lab-words, deployed onto a cloud infrastructure.

  1. Log in to the MKE web UI.

  2. In the left-side navigation panel, navigate to Kubernetes and click Create.

  3. Leave the Namespace drop-down blank.

  4. Paste the following in the Object YAML editor:

    apiVersion: v1
    kind: Namespace
      name: labs
  5. Click Create.

  6. Navigate to Kubernetes > Namespaces, hover over the labs namespace, and select Set Context.

  7. In the left-side navigation panel, navigate to Shared Resources > Stacks and click Create Stack in the upper right corner.

  8. In the Name field, name the application lab-words.

  9. Under ORCHESTRATOR MODE, select Kubernetes Workloads.

  10. In the Namespace drop-down, select labs.

  11. Click Next.

  12. Under Add Application File, in the docker-compose.yml editor, paste the following:

    version: '3.3'
        image: dockersamples/k8s-wordsmith-web
          - "32768:80"
        image: dockersamples/k8s-wordsmith-api
          replicas: 5
        image: dockersamples/k8s-wordsmith-db
  13. Click Create.

Review the deployment

  1. In the left-side navigation panel, navigate to Kubernetes > Pods.

  2. Verify that there are seven Pods present, all with a status of Running. If any Pods are still Pending, wait until they are Running.

  3. Navigate to Kubernetes > Services and select the web-published service.

  4. Scroll to the Ports section and copy the Node Port information.

  5. Open a new window in your browser.

  6. Enter your cloud instance public IP address followed by the node port information copied earlier: <cloud-instance-ip>:<node-port>. To find the public IP address of an EC2 instance, for example, refer to Amazon EC2 Instance IP Addressing.

  7. Verify that the app displays.


    To display your app, you may need to add a rule in your cloud provider firewall settings to allow inbound traffic on the port specified in the docker-compose.yml file.