mirror of https://github.com/kubernetes/kops.git
feat(spot/elastigroup): configure subnets without zones
This commit is contained in:
parent
b571223d8d
commit
22a07ff7a2
|
|
@ -178,6 +178,7 @@ func (b *InstanceGroupModelBuilder) buildElastigroup(c *fi.ModelBuilderContext,
|
||||||
group := &spotinsttasks.Elastigroup{
|
group := &spotinsttasks.Elastigroup{
|
||||||
Lifecycle: b.Lifecycle,
|
Lifecycle: b.Lifecycle,
|
||||||
Name: fi.String(b.AutoscalingGroupName(ig)),
|
Name: fi.String(b.AutoscalingGroupName(ig)),
|
||||||
|
Region: fi.String(b.Region),
|
||||||
ImageID: fi.String(ig.Spec.Image),
|
ImageID: fi.String(ig.Spec.Image),
|
||||||
OnDemandInstanceType: fi.String(strings.Split(ig.Spec.MachineType, ",")[0]),
|
OnDemandInstanceType: fi.String(strings.Split(ig.Spec.MachineType, ",")[0]),
|
||||||
SpotInstanceTypes: strings.Split(ig.Spec.MachineType, ","),
|
SpotInstanceTypes: strings.Split(ig.Spec.MachineType, ","),
|
||||||
|
|
|
||||||
|
|
@ -47,6 +47,7 @@ type Elastigroup struct {
|
||||||
Lifecycle *fi.Lifecycle
|
Lifecycle *fi.Lifecycle
|
||||||
|
|
||||||
ID *string
|
ID *string
|
||||||
|
Region *string
|
||||||
MinSize *int64
|
MinSize *int64
|
||||||
MaxSize *int64
|
MaxSize *int64
|
||||||
SpotPercentage *float64
|
SpotPercentage *float64
|
||||||
|
|
@ -186,6 +187,7 @@ func (e *Elastigroup) Find(c *fi.Context) (*Elastigroup, error) {
|
||||||
actual := &Elastigroup{}
|
actual := &Elastigroup{}
|
||||||
actual.ID = group.ID
|
actual.ID = group.ID
|
||||||
actual.Name = group.Name
|
actual.Name = group.Name
|
||||||
|
actual.Region = group.Region
|
||||||
|
|
||||||
// Capacity.
|
// Capacity.
|
||||||
{
|
{
|
||||||
|
|
@ -218,11 +220,9 @@ func (e *Elastigroup) Find(c *fi.Context) (*Elastigroup, error) {
|
||||||
|
|
||||||
// Subnets.
|
// Subnets.
|
||||||
{
|
{
|
||||||
for _, zone := range compute.AvailabilityZones {
|
for _, subnetID := range compute.SubnetIDs {
|
||||||
if zone.SubnetID != nil {
|
actual.Subnets = append(actual.Subnets,
|
||||||
actual.Subnets = append(actual.Subnets,
|
&awstasks.Subnet{ID: fi.String(subnetID)})
|
||||||
&awstasks.Subnet{ID: zone.SubnetID})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if subnetSlicesEqualIgnoreOrder(actual.Subnets, e.Subnets) {
|
if subnetSlicesEqualIgnoreOrder(actual.Subnets, e.Subnets) {
|
||||||
actual.Subnets = e.Subnets
|
actual.Subnets = e.Subnets
|
||||||
|
|
@ -494,6 +494,7 @@ func (_ *Elastigroup) create(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e
|
||||||
{
|
{
|
||||||
group.SetName(e.Name)
|
group.SetName(e.Name)
|
||||||
group.SetDescription(e.Name)
|
group.SetDescription(e.Name)
|
||||||
|
group.SetRegion(e.Region)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Capacity.
|
// Capacity.
|
||||||
|
|
@ -525,16 +526,13 @@ func (_ *Elastigroup) create(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e
|
||||||
group.Compute.InstanceTypes.SetSpot(e.SpotInstanceTypes)
|
group.Compute.InstanceTypes.SetSpot(e.SpotInstanceTypes)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Availability zones.
|
// Subnets.
|
||||||
{
|
{
|
||||||
zones := make([]*aws.AvailabilityZone, len(e.Subnets))
|
subnets := make([]string, len(e.Subnets))
|
||||||
for i, subnet := range e.Subnets {
|
for i, subnet := range e.Subnets {
|
||||||
zone := new(aws.AvailabilityZone)
|
subnets[i] = fi.StringValue(subnet.ID)
|
||||||
zone.SetName(subnet.AvailabilityZone)
|
|
||||||
zone.SetSubnetId(subnet.ID)
|
|
||||||
zones[i] = zone
|
|
||||||
}
|
}
|
||||||
group.Compute.SetAvailabilityZones(zones)
|
group.Compute.SetSubnetIDs(subnets)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Launch Specification.
|
// Launch Specification.
|
||||||
|
|
@ -796,6 +794,13 @@ func (_ *Elastigroup) update(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e
|
||||||
group := new(aws.Group)
|
group := new(aws.Group)
|
||||||
group.SetId(actual.ID)
|
group.SetId(actual.ID)
|
||||||
|
|
||||||
|
// Region.
|
||||||
|
if changes.Region != nil {
|
||||||
|
group.SetRegion(e.Region)
|
||||||
|
changes.Region = nil
|
||||||
|
changed = true
|
||||||
|
}
|
||||||
|
|
||||||
// Strategy.
|
// Strategy.
|
||||||
{
|
{
|
||||||
// Spot percentage.
|
// Spot percentage.
|
||||||
|
|
@ -902,22 +907,19 @@ func (_ *Elastigroup) update(cloud awsup.AWSCloud, a, e, changes *Elastigroup) e
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Availability zones.
|
// Subnets.
|
||||||
{
|
{
|
||||||
if changes.Subnets != nil {
|
if changes.Subnets != nil {
|
||||||
if group.Compute == nil {
|
if group.Compute == nil {
|
||||||
group.Compute = new(aws.Compute)
|
group.Compute = new(aws.Compute)
|
||||||
}
|
}
|
||||||
|
|
||||||
zones := make([]*aws.AvailabilityZone, len(e.Subnets))
|
subnets := make([]string, len(e.Subnets))
|
||||||
for i, subnet := range e.Subnets {
|
for i, subnet := range e.Subnets {
|
||||||
zone := new(aws.AvailabilityZone)
|
subnets[i] = fi.StringValue(subnet.ID)
|
||||||
zone.SetName(subnet.AvailabilityZone)
|
|
||||||
zone.SetSubnetId(subnet.ID)
|
|
||||||
zones[i] = zone
|
|
||||||
}
|
}
|
||||||
|
|
||||||
group.Compute.SetAvailabilityZones(zones)
|
group.Compute.SetSubnetIDs(subnets)
|
||||||
changes.Subnets = nil
|
changes.Subnets = nil
|
||||||
changed = true
|
changed = true
|
||||||
}
|
}
|
||||||
|
|
@ -1442,7 +1444,7 @@ func (_ *Elastigroup) RenderTerraform(t *terraform.TerraformTarget, a, e, change
|
||||||
Name: e.Name,
|
Name: e.Name,
|
||||||
Description: e.Name,
|
Description: e.Name,
|
||||||
Product: e.Product,
|
Product: e.Product,
|
||||||
Region: fi.String(cloud.Region()),
|
Region: e.Region,
|
||||||
|
|
||||||
DesiredCapacity: e.MinSize,
|
DesiredCapacity: e.MinSize,
|
||||||
MinSize: e.MinSize,
|
MinSize: e.MinSize,
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue