deployment/terraform-module-knfsd/autoscaler.tf (34 lines of code) (raw):
/**
* Copyright 2020 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
# Autoscaler that scales up the Knfsd cluster depending on the number of NFS Connections
resource "google_compute_autoscaler" "knfsd-autoscaler" {
// Count is used here to determine if the autoscaler policy should be created
// If var.ENABLE_KNFSD_AUTOSCALING is true then we want 1 autoscaler rule, else 0
count = var.ENABLE_KNFSD_AUTOSCALING ? 1 : 0
name = "${var.PROXY_BASENAME}-autoscaler"
zone = var.ZONE
target = google_compute_instance_group_manager.proxy-group.id
autoscaling_policy {
max_replicas = var.KNFSD_AUTOSCALING_MAX_INSTANCES
min_replicas = var.KNFSD_AUTOSCALING_MIN_INSTANCES
cooldown_period = 165
mode = "ONLY_UP"
metric {
name = "custom.googleapis.com/knfsd/nfs_connections"
target = var.KNFSD_AUTOSCALING_NFS_CONNECTIONS_THRESHOLD
type = "GAUGE"
}
}
}