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
Create a Kubernetes app from a Compose file¶
The following example describes how to use a Compose file to create a simple
lab-words, deployed onto a cloud infrastructure.
Log in to the MKE web UI.
In the left-side navigation panel, navigate to Kubernetes and click Create.
Leave the Namespace drop-down blank.
Paste the following in the Object YAML editor:
apiVersion: v1 kind: Namespace metadata: name: labs
Navigate to Kubernetes > Namespaces, hover over the labs namespace, and select Set Context.
In the left-side navigation panel, navigate to Shared Resources > Stacks and click Create Stack in the upper right corner.
In the Name field, name the application
Under ORCHESTRATOR MODE, select Kubernetes Workloads.
In the Namespace drop-down, select labs.
Under Add Application File, in the docker-compose.yml editor, paste the following:
version: '3.3' services: web: image: dockersamples/k8s-wordsmith-web ports: - "32768:80" words: image: dockersamples/k8s-wordsmith-api deploy: replicas: 5 db: image: dockersamples/k8s-wordsmith-db
Review the deployment¶
In the left-side navigation panel, navigate to Kubernetes > Pods.
Verify that there are seven Pods present, all with a status of Running. If any Pods are still Pending, wait until they are Running.
Navigate to Kubernetes > Services and select the web-published service.
Scroll to the Ports section and copy the Node Port information.
Open a new window in your browser.
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.
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