In this tutorial, you deploy an example logbook app that uses Node.js for its frontend and MySQL for its backend. At the end of the tutorial, your deployment has the following resources:
If you are new to Deployment Manager, see the Quickstart or the Step-by-Step Guide tutorials.
Before you begin
- If you want to use the command-line examples in this guide, install the `gcloud` command-line tool.
- If you want to use the API examples in this guide, set up API access.
- Read an overview of Compute Engine network load balancing.
- Read an overview of Docker containers.
Creating your resource templates
This example launches a deployment that contains a variety of Google Cloud resources. To start, you create templates that define these resources separately. Later, you call these templates in your final configuration. Your deployment contains these resources:
- A Compute Engine instance that hosts a MySQL database for the app.
- An instance template for frontend instances, which uses a Docker image for the Node.js app.
- A managed instance group, which uses the instance template to create two frontend instances.
- An autoscaler, which starts or stops additional frontend instances based on incoming traffic.
- A health check, which checks whether the frontend instances are available to do work.
- A network load balancer with a forwarding rule.
- A target pool for the managed instance group.
Creating the template for the MySQL backend
The backend of this app is a single Compute Engine instance running
a MySQL Docker container. The container_vm.py template defines a
Compute Engine instance that can run Docker containers. To ensure that the
template follows the correct structure and contains all of the required
properties, you also need a schema file.
Copy the template below, or download it from the GitHub repository:
Download the schema file for the template.
The template has some undefined properties, such as containerImage, which are
defined in later templates.
When you use container images on Compute Engine instances, you also need to
provide a manifest file that describes which container image to use. Create a
helper method called container_helper.py to dynamically define the container
manifest: