mirror of https://github.com/kubernetes/kops.git
add cluster orientation cluster config
This commit is contained in:
parent
497898328f
commit
faf4da0014
|
|
@ -130,7 +130,11 @@ const (
|
||||||
|
|
||||||
// SpotClusterLabelSpreadNodesBy is the cloud label used on the
|
// SpotClusterLabelSpreadNodesBy is the cloud label used on the
|
||||||
// cluster spec to specify how Ocean will spread the nodes across markets by this value
|
// cluster spec to specify how Ocean will spread the nodes across markets by this value
|
||||||
SpotClusterLabelSpreadNodesBy = "spotinstSpreadNodesBy"
|
SpotClusterLabelSpreadNodesBy = "spotinst.io/strategy-cluster-spread-nodes-by"
|
||||||
|
|
||||||
|
// SpotClusterLabelStrategyClusterOrientationAvailabilityVsCost is the metadata label used on the
|
||||||
|
// instance group to specify how to optimize towards continuity and/or cost-effective infrastructure
|
||||||
|
SpotClusterLabelStrategyClusterOrientationAvailabilityVsCost = "spotinst.io/strategy-cluster-orientation-availability-vs-cost"
|
||||||
)
|
)
|
||||||
|
|
||||||
// SpotInstanceGroupModelBuilder configures SpotInstanceGroup objects
|
// SpotInstanceGroupModelBuilder configures SpotInstanceGroup objects
|
||||||
|
|
@ -381,6 +385,8 @@ func (b *SpotInstanceGroupModelBuilder) buildOcean(c *fi.CloudupModelBuilderCont
|
||||||
switch k {
|
switch k {
|
||||||
case SpotClusterLabelSpreadNodesBy:
|
case SpotClusterLabelSpreadNodesBy:
|
||||||
ocean.SpreadNodesBy = fi.PtrTo(v)
|
ocean.SpreadNodesBy = fi.PtrTo(v)
|
||||||
|
case SpotClusterLabelStrategyClusterOrientationAvailabilityVsCost:
|
||||||
|
ocean.AvailabilityVsCost = fi.PtrTo(string(spotinsttasks.NormalizeClusterOrientation(&v)))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -65,6 +65,7 @@ type Ocean struct {
|
||||||
AutoScalerOpts *AutoScalerOpts
|
AutoScalerOpts *AutoScalerOpts
|
||||||
InstanceMetadataOptions *InstanceMetadataOptions
|
InstanceMetadataOptions *InstanceMetadataOptions
|
||||||
SpreadNodesBy *string
|
SpreadNodesBy *string
|
||||||
|
AvailabilityVsCost *string
|
||||||
}
|
}
|
||||||
|
|
||||||
var (
|
var (
|
||||||
|
|
@ -166,6 +167,9 @@ func (o *Ocean) Find(c *fi.CloudupContext) (*Ocean, error) {
|
||||||
actual.GracePeriod = fi.PtrTo(int64(fi.ValueOf(strategy.GracePeriod)))
|
actual.GracePeriod = fi.PtrTo(int64(fi.ValueOf(strategy.GracePeriod)))
|
||||||
}
|
}
|
||||||
actual.SpreadNodesBy = strategy.SpreadNodesBy
|
actual.SpreadNodesBy = strategy.SpreadNodesBy
|
||||||
|
if strategy.ClusterOrientation != nil && strategy.ClusterOrientation.AvailabilityVsCost != nil {
|
||||||
|
actual.AvailabilityVsCost = fi.PtrTo(fi.ValueOf(strategy.ClusterOrientation.AvailabilityVsCost))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -405,6 +409,10 @@ func (_ *Ocean) create(cloud awsup.AWSCloud, a, e, changes *Ocean) error {
|
||||||
ocean.Strategy.SetGracePeriod(fi.PtrTo(int(*e.GracePeriod)))
|
ocean.Strategy.SetGracePeriod(fi.PtrTo(int(*e.GracePeriod)))
|
||||||
}
|
}
|
||||||
ocean.Strategy.SetSpreadNodesBy(e.SpreadNodesBy)
|
ocean.Strategy.SetSpreadNodesBy(e.SpreadNodesBy)
|
||||||
|
if e.AvailabilityVsCost != nil {
|
||||||
|
orientation := new(aws.ClusterOrientation)
|
||||||
|
ocean.Strategy.SetClusterOrientation(orientation.SetAvailabilityVsCost(fi.PtrTo(*e.AvailabilityVsCost)))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute.
|
// Compute.
|
||||||
|
|
@ -691,6 +699,18 @@ func (_ *Ocean) update(cloud awsup.AWSCloud, a, e, changes *Ocean) error {
|
||||||
changed = true
|
changed = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Availability vs cost.
|
||||||
|
if changes.AvailabilityVsCost != nil {
|
||||||
|
if ocean.Strategy == nil {
|
||||||
|
ocean.Strategy = new(aws.Strategy)
|
||||||
|
}
|
||||||
|
|
||||||
|
orientation := new(aws.ClusterOrientation)
|
||||||
|
ocean.Strategy.SetClusterOrientation(orientation.SetAvailabilityVsCost(fi.PtrTo(*changes.AvailabilityVsCost)))
|
||||||
|
changes.AvailabilityVsCost = nil
|
||||||
|
changed = true
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Compute.
|
// Compute.
|
||||||
|
|
@ -1099,6 +1119,7 @@ type terraformOcean struct {
|
||||||
KeyName *terraformWriter.Literal `cty:"key_name"`
|
KeyName *terraformWriter.Literal `cty:"key_name"`
|
||||||
SecurityGroups []*terraformWriter.Literal `cty:"security_groups"`
|
SecurityGroups []*terraformWriter.Literal `cty:"security_groups"`
|
||||||
SpreadNodesBy *string `cty:"spread_nodes_by"`
|
SpreadNodesBy *string `cty:"spread_nodes_by"`
|
||||||
|
AvailabilityVsCost *string `cty:"availability_vs_cost"`
|
||||||
}
|
}
|
||||||
|
|
||||||
func (_ *Ocean) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *Ocean) error {
|
func (_ *Ocean) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *Ocean) error {
|
||||||
|
|
@ -1114,6 +1135,7 @@ func (_ *Ocean) RenderTerraform(t *terraform.TerraformTarget, a, e, changes *Oce
|
||||||
DrainingTimeout: e.DrainingTimeout,
|
DrainingTimeout: e.DrainingTimeout,
|
||||||
GracePeriod: e.GracePeriod,
|
GracePeriod: e.GracePeriod,
|
||||||
SpreadNodesBy: e.SpreadNodesBy,
|
SpreadNodesBy: e.SpreadNodesBy,
|
||||||
|
AvailabilityVsCost: e.AvailabilityVsCost,
|
||||||
}
|
}
|
||||||
|
|
||||||
// Image.
|
// Image.
|
||||||
|
|
@ -1287,3 +1309,28 @@ func (o *Ocean) buildTags() []*aws.Tag {
|
||||||
|
|
||||||
return tags
|
return tags
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ClusterOrientation string
|
||||||
|
|
||||||
|
const (
|
||||||
|
ClusterOrientationBalanced ClusterOrientation = "balanced"
|
||||||
|
ClusterOrientationCheapest ClusterOrientation = "cheapest"
|
||||||
|
ClusterOrientationCost ClusterOrientation = "costOriented"
|
||||||
|
)
|
||||||
|
|
||||||
|
func NormalizeClusterOrientation(orientation *string) ClusterOrientation {
|
||||||
|
out := ClusterOrientationBalanced
|
||||||
|
|
||||||
|
if orientation == nil {
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
||||||
|
switch *orientation {
|
||||||
|
case "cost":
|
||||||
|
out = ClusterOrientationCost
|
||||||
|
case "cheapest":
|
||||||
|
out = ClusterOrientationCheapest
|
||||||
|
}
|
||||||
|
|
||||||
|
return out
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue