From c3058b8b085bf4ced7a8a7fd6f7c36305855bbc2 Mon Sep 17 00:00:00 2001 From: James Rasell Date: Fri, 26 Feb 2021 17:21:09 +0100 Subject: [PATCH] docs: add Nomad Autoscaler GPC MIG target plugin detail. (#10090) Co-authored-by: Luiz Aoqui --- .../docs/autoscaling/plugins/target.mdx | 82 ++++++++++++++++++- 1 file changed, 81 insertions(+), 1 deletion(-) diff --git a/website/content/docs/autoscaling/plugins/target.mdx b/website/content/docs/autoscaling/plugins/target.mdx index 083856669..4c22bfea0 100644 --- a/website/content/docs/autoscaling/plugins/target.mdx +++ b/website/content/docs/autoscaling/plugins/target.mdx @@ -17,6 +17,7 @@ Below is a list of plugins you can use with the Nomad Autoscaler: - [Dynamic Application Sizing Nomad Task][das_task_target] - [AWS AutoScaling Group][aws_asg_target] - [Azure Virtual Machine Scale Set][azure_vmss_target] +- [Google Cloud Platform Managed Instance Groups][gcp_mig_target] ## Nomad Task Group Target @@ -248,7 +249,7 @@ in the Autoscaler configuration file: target "azure-vmss" { driver = "azure-vmss" config = { - subscription_id = "ee0886ab-5cc2-4583-a3f0-c4bfd044ee82" + subscription_id = "ee0886ab-5cc2-4583-a3f0-c4bfd044ee82" } } ``` @@ -334,6 +335,80 @@ Alternatively, you can set a [client meta tag][client_meta_tag_docs] called This can be retrieved programatically via the [Azure Instance Metadata service][azure_instance_metadata]. +## Google Cloud Platform Managed Instance Groups Target + +The GCP MIG target plugin allows for the scaling of the Nomad cluster clients +via manipulating [Google Cloud Platform Managed Instance Groups][gcp_migs]. The +plugin supports both regional and zonal groups. + +### Agent Configuration Options + +The plugin uses the official Google Cloud Golang SDK. This means it supports the +common ways of [providing credentials to Google Cloud][gcp_credentials]. It is +recommended, if possible to use the [Vault GCP Secrets engine][vault_gcp_backend] +for supplying access credentials to the plugin. Credentials should be injected +into the configuration via a template rather than as environment variables. This +ensures the credentials are passed only to the plugin, rather than being available +for all plugins and the agent process. + +```hcl +target "gcp-mig" { + driver = "gcp-mig" + config = { + credentials = "local/creds.json" + } +} +``` + +- `credentials` `(string: "")` - This is specified as the path to a Google Cloud +credentials file, typically for a service account. + +When using a Nomad cluster with ACLs enabled, the plugin will require an ACL token +which provides the following permissions: + +```hcl +node { + policy = "write" +} +``` + +### Policy Configuration Options + +```hcl +check "hashistack-allocated-cpu" { + ... + target "gcp-mig" { + project = "hashistack-demo" + region = "us-west1" + mig_name = "nomad-client-hashistack" + node_class = "hashistack" + node_drain_deadline = "5m" + node_purge = "true" + } + ... +``` + +- `project` `(string: )` - The [Google Cloud Platform project ID][gcp_projects] + within which the managed instance group is running. + +- `region` `(string: "")` - The GCP region where the Managed Instance Group resides. + Providing this parameter indicates the MIG is regional. Conflicts with `zone`. + +- `zone` `(string: "")` - The GCP zone where the Managed Instance Group resides. + Providing this parameter indicates the MIG is zonal. Conflicts with `region`. + +- `mig_name` `(string: )` - The name of the GCP Managed Instance Group + to interact with when performing scaling actions. + +- `node_class` `(string: )` - The Nomad [client node class][nomad_node_class] + identifier used to group nodes into a pool of resource. + +- `node_drain_deadline` `(duration: "15m")` The Nomad [drain deadline][nomad_node_drain_deadline] + to use when performing node draining actions. + +- `node_purge` `(bool: "false")` A boolean flag to determine whether Nomad clients should + be [purged][nomad_node_purge] when performing scale in actions. + [nomad_node_class]: /docs/configuration/client#node_class [nomad_node_drain_deadline]: /api-docs/nodes#deadline [nomad_scaling_stanza]: /docs/job-specification/scaling @@ -360,3 +435,8 @@ This can be retrieved programatically via the [client_meta_tag]: /docs/autoscaling/plugins/target#client-meta-tag [azure_instance_metadata]: https://docs.microsoft.com/en-us/azure/virtual-machines/windows/instance-metadata-service [das_task_target]: /docs/autoscaling/plugins/target#dynamic-application-sizing-nomad-task-target +[gcp_migs]: https://cloud.google.com/compute/docs/instance-groups/ +[vault_gcp_backend]: https://www.vaultproject.io/docs/secrets/gcp +[gcp_credentials]: https://cloud.google.com/docs/authentication/production#providing_credentials_to_your_application +[gcp_projects]: https://cloud.google.com/resource-manager/docs/creating-managing-projects +[gcp_mig_target]: /docs/autoscaling/plugins/target#google-cloud-platform-managed-instance-groups-target