scripts/deployment/mig/igm.jinja (72 lines of code) (raw):
{#
Copyright 2019 Google Inc. All rights reserved.
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
http://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.
#}
{% set INSTANCE_TEMPLATE = env["deployment"] + "-it" %}
{% set IGM = env["deployment"] + "-igm" %}
{% set AUTO_SCALER = env["deployment"] + "-as" %}
{% set BACK_END = env["deployment"] + "-bes" %}
{% set HEALTH_CHECK = env["deployment"] + "-hc" %}
{% set FWARD_RULE = env["deployment"] + "-fr" %}
{% set COMPUTE_URL_BASE = 'https://www.googleapis.com/compute/v1/' %}
resources:
- name: {{ INSTANCE_TEMPLATE }}
type: instance-template.jinja
properties:
image: {{ properties['image'] }}
machineType: {{ properties['machineType'] }}
itName: {{ INSTANCE_TEMPLATE }}
value: {{ properties['value'] }}
subnetwork: {{ properties["subnetwork"] }}
network: {{ properties["network"] }}
email: {{ properties["email"] }}
- name: {{ IGM }}
type: compute.v1.regionInstanceGroupManagers
properties:
baseInstanceName: {{ env["deployment"] }}-vm
instanceTemplate: $(ref.{{ INSTANCE_TEMPLATE }}.selfLink)
targetSize: {{ properties["targetSize"] }}
region: {{ properties["region"] }}
- name: {{ AUTO_SCALER }}
type: compute.v1.regionAutoscaler
properties:
region: {{ properties["region"] }}
target: $(ref.{{ IGM }}.selfLink)
autoscalingPolicy:
maxNumReplicas: {{ properties["maxNumReplicas"] }}
cpuUtilization:
utilizationTarget: 0.7
coolDownPeriodSec: 90
- name: {{ BACK_END }}
type: compute.v1.regionBackendService
properties:
protocol: "TCP"
backends: {{ properties["instance-groups"] }}
- name: {{ IGM }}-{{ properties["service"] }}
group: $(ref.{{ IGM }}.instanceGroup)
loadBalancingScheme: INTERNAL
region: {{ properties["region"] }}
healthChecks: [$(ref.{{ HEALTH_CHECK }}.selfLink)]
- name: {{ HEALTH_CHECK }}
type: compute.v1.healthCheck
properties:
type: "TCP"
tcpHealthCheck:
port: 80
- name: {{ FWARD_RULE }}
type: compute.v1.forwardingRule
properties:
ports: [80]
network: {{ properties["network"] }}
subnetwork: {{ properties["subnetwork"] }}
region: {{ properties["region"] }}
backendService: $(ref.{{ BACK_END }}.selfLink)
loadBalancingScheme: INTERNAL