Skip to content

Commit

Permalink
Ansible Autoscaler (#2089)
Browse files Browse the repository at this point in the history
Merged PR #2089.
  • Loading branch information
rambleraptor authored and modular-magician committed Jul 24, 2019
1 parent 84691cd commit e157ca5
Show file tree
Hide file tree
Showing 4 changed files with 142 additions and 7 deletions.
28 changes: 22 additions & 6 deletions products/compute/ansible.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
--- !ruby/object:Provider::Ansible::Config
# This is where custom code would be defined eventually.
datasources: !ruby/object:Overrides::ResourceOverrides
Autoscaler: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
BackendBucketSignedUrlKey: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
BackendServiceSignedUrlKey: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
ManagedSslCertificate: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
RegionAutoscaler: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
# Readonly resources.
DiskType: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
Expand All @@ -37,8 +37,6 @@ datasources: !ruby/object:Overrides::ResourceOverrides
exclude: true
NodeTemplate: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
RegionAutoscaler: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
RegionBackendService: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
Region: !ruby/object:Overrides::Ansible::ResourceOverride
Expand All @@ -52,6 +50,26 @@ datasources: !ruby/object:Overrides::ResourceOverrides
Zone: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
overrides: !ruby/object:Overrides::ResourceOverrides
Autoscaler: !ruby/object:Overrides::Ansible::ResourceOverride
properties:
autoscalingPolicy.minNumReplicas: !ruby/object:Overrides::Ansible::PropertyOverride
aliases: ['minReplicas']
autoscalingPolicy.maxNumReplicas: !ruby/object:Overrides::Ansible::PropertyOverride
aliases: ['maxReplicas']
autoscalingPolicy.coolDownPeriodSec: !ruby/object:Overrides::Ansible::PropertyOverride
aliases: ['cooldownPeriod']
autoscalingPolicy.cpuUtilization.utilizationTarget: !ruby/object:Overrides::Ansible::PropertyOverride
aliases: ['target']
autoscalingPolicy.customMetricUtilizations: !ruby/object:Overrides::Ansible::PropertyOverride
aliases: ['metric']
autoscalingPolicy.customMetricUtilizations.metric: !ruby/object:Overrides::Ansible::PropertyOverride
aliases: ['name']
autoscalingPolicy.customMetricUtilizations.utilizationTarget: !ruby/object:Overrides::Ansible::PropertyOverride
aliases: ['target']
autoscalingPolicy.customMetricUtilizations.utilizationTargetType: !ruby/object:Overrides::Ansible::PropertyOverride
aliases: ['type']
autoscalingPolicy.loadBalancingUtilization.utilizationTarget: !ruby/object:Overrides::Ansible::PropertyOverride
aliases: ['target']
BackendService: !ruby/object:Overrides::Ansible::ResourceOverride
properties:
timeoutSec: !ruby/object:Overrides::Ansible::PropertyOverride
Expand Down Expand Up @@ -234,8 +252,6 @@ overrides: !ruby/object:Overrides::ResourceOverrides
TargetVpnGateway: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: false
# Not yet implemented.
Autoscaler: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
BackendBucketSignedUrlKey: !ruby/object:Overrides::Ansible::ResourceOverride
exclude: true
BackendServiceSignedUrlKey: !ruby/object:Overrides::Ansible::ResourceOverride
Expand Down
40 changes: 40 additions & 0 deletions products/compute/ansible_version_added.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,8 @@
:facts:
:Address:
:version_added: '2.7'
:Autoscaler:
:version_added: '2.9'
:BackendBucket:
:version_added: '2.7'
:BackendService:
Expand Down Expand Up @@ -83,6 +85,44 @@
:version_added: '2.7'
:region:
:version_added: '2.6'
:Autoscaler:
:version_added: '2.9'
:name:
:version_added: '2.9'
:description:
:version_added: '2.9'
:autoscalingPolicy:
:version_added: '2.9'
:minNumReplicas:
:version_added: '2.9'
:maxNumReplicas:
:version_added: '2.9'
:coolDownPeriodSec:
:version_added: '2.9'
:cpuUtilization:
:version_added: '2.9'
:utilizationTarget:
:version_added: '2.9'
:customMetricUtilizations:
:version_added: '2.9'
:metric:
:version_added: '2.9'
:singleInstanceAssignment:
:version_added: '2.9'
:utilizationTarget:
:version_added: '2.9'
:utilizationTargetType:
:version_added: '2.9'
:filter:
:version_added: '2.9'
:loadBalancingUtilization:
:version_added: '2.9'
:utilizationTarget:
:version_added: '2.9'
:target:
:version_added: '2.9'
:zone:
:version_added: '2.9'
:BackendBucket:
:version_added: '2.6'
:bucketName:
Expand Down
79 changes: 79 additions & 0 deletions products/compute/examples/ansible/autoscaler.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
# Copyright 2017 Google Inc.
# 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.
--- !ruby/object:Provider::Ansible::Example
task: !ruby/object:Provider::Ansible::Task
name: gcp_compute_autoscaler
code:
name: <%= ctx[:name] %>
zone: 'us-central1-a'
target: "{{ igm }}"
autoscaling_policy:
max_num_replicas: 5
min_num_replicas: 1
cool_down_period_sec: 60
cpu_utilization:
utilization_target: 0.5
project: <%= ctx[:project] %>
auth_kind: <%= ctx[:auth_kind] %>
service_account_file: <%= ctx[:service_account_file] %>
dependencies:
- !ruby/object:Provider::Ansible::Task
name: gcp_compute_network
register: network
code:
name: <%= dependency_name('network', 'instanceTemplate') %>
project: <%= ctx[:project] %>
auth_kind: <%= ctx[:auth_kind] %>
service_account_file: <%= ctx[:service_account_file] %>
- !ruby/object:Provider::Ansible::Task
name: gcp_compute_address
register: address
code:
name: <%= dependency_name('address', 'instanceTemplate') %>
region: 'us-central1'
project: <%= ctx[:project] %>
auth_kind: <%= ctx[:auth_kind] %>
service_account_file: <%= ctx[:service_account_file] %>
- !ruby/object:Provider::Ansible::Task
name: gcp_compute_instance_template
register: instancetemplate
code:
name: <%= ctx[:name] %>
properties:
disks:
- auto_delete: true
boot: true
initialize_params:
source_image: 'projects/ubuntu-os-cloud/global/images/family/ubuntu-1604-lts'
machine_type: n1-standard-1
network_interfaces:
- network: "{{ network }}"
access_configs:
- name: 'test-config'
type: 'ONE_TO_ONE_NAT'
nat_ip: "{{ address }}"
project: <%= ctx[:project] %>
auth_kind: <%= ctx[:auth_kind] %>
service_account_file: <%= ctx[:service_account_file] %>
- !ruby/object:Provider::Ansible::Task
name: gcp_compute_instance_group_manager
register: igm
code:
name: <%= ctx[:name] %>
base_instance_name: 'test1-child'
instance_template: "{{ instancetemplate }}"
target_size: 3
zone: 'us-central1-a'
project: <%= ctx[:project] %>
auth_kind: <%= ctx[:auth_kind] %>
service_account_file: <%= ctx[:service_account_file] %>

0 comments on commit e157ca5

Please sign in to comment.