This advanced example demonstrates how to build a logbook app that uses node.js for its frontend and MySQL for its backend. The template also creates and connects an HTTP load balancer that load balances across two zones, and an autoscaler to automatically scale the app.
This example assumes you are familiar with Docker containers, as well as Compute Engine resources, particularly HTTP load balancing, autoscaling, managed instance groups, and instance templates.
For more introductory tutorials, refer to the Getting started guide or the Step-by-step guide.
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.
- Familiar with Compute Engine HTTP load balancing.
- Familiar with Docker containers.
Creating your templates
This example launches a deployment with several types of resources. To start, you will create reusable templates that define these resources separately. Later on, you will use these templates in your final configuration.
At the end of this example, you will have a deployment that contains these resources:
- A single Compute Engine instance for the backend MySQL virtual machine.
- An instance template that uses a Docker image.
- Two autoscaled managed instance groups in two different zones, running the frontend node.js service.
- Another two autoscaled managed instance group serving static data.
- A health check and a HTTP load balancer to distributed traffic across the respective managed instance groups.
Creating the backend templates
The backend of this app is a single Compute Engine instance running a MySQL
Docker container. Create a template that defines a Compute Engine instance
that uses a container-optimized image. Name the file container_vm.[py|jinja]: