New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[GCE] Support Managed Instance Groups #842

Closed
wants to merge 1 commit into
base: trunk
from

Conversation

Projects
None yet
3 participants
@supertom
Contributor

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

This comment has been minimized.

Show comment
Hide comment
@tonybaloney

tonybaloney Jul 20, 2016

Contributor

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

Contributor

tonybaloney commented Jul 20, 2016

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

Show outdated Hide outdated libcloud/compute/drivers/gce.py
:type size: ``str``
:param zone: Zone to wich the Instance Group belongs
:type zone: ``str``

This comment has been minimized.

@erjohnso

erjohnso Jul 28, 2016

Member

Consider also allowing GCEZone. Same with other methods.

@erjohnso

erjohnso Jul 28, 2016

Member

Consider also allowing GCEZone. Same with other methods.

@erjohnso

This comment has been minimized.

Show comment
Hide comment
@erjohnso

erjohnso Jul 28, 2016

Member

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

Member

erjohnso commented Jul 28, 2016

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

@supertom

This comment has been minimized.

Show comment
Hide comment
@supertom

supertom Aug 12, 2016

Contributor

@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.

Contributor

supertom commented Aug 12, 2016

@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

This comment has been minimized.

Show comment
Hide comment
@tonybaloney

tonybaloney Aug 12, 2016

Contributor

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

Contributor

tonybaloney commented Aug 12, 2016

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

Prelimary support (create, delete, list and get) for Managed Instance…
… 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.

@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