This template:
- Creates a Compute Instance with an HAProxy installed
- Configures HAProxy to load-balance traffic between one or more of the provided instance groups
- Install gcloud
- Create a GCP project, set up billing, enable requisite APIs
- Grant compute.viewer role to
Compute Engine default service account.
Alternatively, create a new service account with the above role, and add it to
the template's
resources.properties.serviceAccountEmail
property. - Create one or more instanceGroups
to be load-balanced, and add them to
resources.properties.instances.groups
collection.
See the properties
section in the schema file(s):
- Clone the Deployment Manager Samples repository:
git clone https://github.com/GoogleCloudPlatform/cloud-foundation-toolkit
- Go to the dm directory:
cd dm
- Copy the example DM config to be used as a model for the deployment; in this case, examples/haproxy.yaml:
cp templates/haproxy/examples/haproxy.yaml my_haproxy.yaml
- Change the values in the config file to match your specific GCP setup (for properties, refer to the schema files listed above):
vim my_haproxy.yaml # <== change values to match your GCP setup
- Create your deployment (replace <YOUR_DEPLOYMENT_NAME> with the relevant deployment name):
gcloud deployment-manager deployments create <YOUR_DEPLOYMENT_NAME> \
--config my_haproxy.yaml
- In case you need to delete your deployment:
gcloud deployment-manager deployments delete <YOUR_DEPLOYMENT_NAME>