Skip to content

[GCE] Support Managed Instance Groups#842

Closed
supertom wants to merge 1 commit intoapache:trunkfrom
supertom:libcloud_gce-group-instance-support
Closed

[GCE] Support Managed Instance Groups#842
supertom wants to merge 1 commit intoapache:trunkfrom
supertom:libcloud_gce-group-instance-support

Conversation

@supertom
Copy link
Contributor

@supertom supertom commented Jul 20, 2016

[GCE] Support for Managed Instance Groups

Description

This PR aims to add support for Managed Instance Groups (MIGs) on GCE. Basic support for AutoScalers has also been added.

The following methods have been added (with supporting classes).

  • gce.ex_get_instancetemplate(template)
  • gce.ex_list_instancetemplates()
  • gce.ex_get_instancegroupmanager(name, zone)
  • gce.ex_list_instancegroupmanagers()
  • gce.ex_create_instancegroupmanager(name, zone, template, size)
  • gce.ex_destroy_instancegroupmanager(instance_group)
  • gce.ex_instancegroupmanager_resize(instance_group, num_instances)
  • gce.ex_instancegroupmanager_recreate_instances(instance_group, list_of_instances)
  • gce.ex_instancegroupmanager_list_managed_instances(instance_group)
  • gce.ex_get_autoscaler(as_name, as_zone)
  • gce.ex_create_autoscaler(as_name, as_zone, my_instance_group, autoscaler_policy, description)
  • gce.ex_list_autoscalers(as_zone)

(Some) Tests and fixtures have also been added.

Useful Links

Example Usage

print gce.ex_list_autoscalers()
print gce.ex_list_instancetemplates()
print gce.ex_list_instancegroupmanagers()
print gce.ex_instancegroupmanagers_list_managed_instances()

# Create an Instance Group
ig_name = 'my-instance-group-foo7'
ig_zone = 'us-central1-c'
it_name = 'my-instance-template-1'

template = gce.ex_get_instancetemplate(it_name)
instance_group = gce.ex_create_instancegroupmanager(ig_name, ig_zone, template, 5, 'base-foo', "my description")
print instance_group

print gce.ex_instancegroupmanager_resize(instance_group, 4)
print gce.ex_instancegroupmanager_recreate_instances(instance_group)

# add autoscaling to the instance group
autoscaler_policy = {
  "maxNumReplicas": 7,
  "minNumReplicas": 4,
  "coolDownPeriodSec": 35,
  "cpuUtilization": {"utilizationTarget": .66}
}

new_as = gce.ex_create_autoscaler(
  as_name, as_zone, my_instance_group, autoscaler_policy,
  description='My desc for this autoscaler')
print new_as
print gce.ex_list_autoscalers(as_zone)

# Update AutoScaler
updated_as = gce.ex_get_autoscaler(as_name, as_zone)
updated_as.policy['coolDownPeriodSec'] = 71
updated_as.policy['cpuUtilization']['utilizationTarget'] = .14
print gce.ex_update_autoscaler(updated_as)

# Delete the Instance Group.  VMs are also deleted.
deleted = gce.ex_destroy_instancegroupmanager(instance_group)
print deleted # returns True

Status

  • ready_for_review

Checklist (tick everything that applies)

  • Code linting (required, can be done after the PR checks)
  • Documentation
  • Tests
  • ICLA (required for bigger changes)

@tonybaloney
Copy link
Contributor

Good work Tom. Do you have an ICLA signed btw?

:type size: ``str``

:param zone: Zone to wich the Instance Group belongs
:type zone: ``str``
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Consider also allowing GCEZone. Same with other methods.

@erjohnso
Copy link
Contributor

Small nit about allowing other param types, but otherwise LGTM!

@supertom
Copy link
Contributor Author

@tonybaloney I thought I did have an ICLA on file, but I didn't, so thanks for asking. It's now on file with Apache.

@tonybaloney
Copy link
Contributor

That's cool @supertom, I don't have access to check them. I won't ask again!

… Groups in libcloud.

The following methods have been added (with supporting classes).

* gce.ex_get_instancetemplate(template)
* gce.ex_list_instancetemplates()
* gce.ex_get_instancegroupmgr(name, zone)
* gce.ex_list_instancegroupmgrs()
* gce.ex_create_instancegroupmgr(name, zone, template, size)
* gce.ex_destroy_instancegroupmgr(instance_group)

Basic AutoScaler support has also been added.

Tests and fixtures have also been added.  Some documentation, unrelated to this feature, has also been fixed.
@supertom supertom force-pushed the libcloud_gce-group-instance-support branch from cd7d591 to 6df8fe6 Compare August 15, 2016 17:31
@asfgit asfgit closed this in 214677f Aug 17, 2016
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants