Skip to content
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

[aws] Spot Instances support #481

Merged
merged 2 commits into from
Aug 4, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions pkg/apis/machine/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -683,6 +683,7 @@ type AWSMachineClassSpec struct {
Monitoring bool
NetworkInterfaces []AWSNetworkInterfaceSpec
Tags map[string]string
SpotPrice *string
SecretRef *corev1.SecretReference

// TODO add more here
Expand Down
1 change: 1 addition & 0 deletions pkg/apis/machine/v1alpha1/aws_machineclass_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,6 +77,7 @@ type AWSMachineClassSpec struct {
Monitoring bool `json:"monitoring,omitempty"`
NetworkInterfaces []AWSNetworkInterfaceSpec `json:"networkInterfaces,omitempty"`
Tags map[string]string `json:"tags,omitempty"`
SpotPrice *string `json:"spotPrice,omitempty"`
SecretRef *corev1.SecretReference `json:"secretRef,omitempty"`

// TODO add more here
Expand Down
2 changes: 2 additions & 0 deletions pkg/apis/machine/v1alpha1/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/apis/machine/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

5 changes: 5 additions & 0 deletions pkg/apis/machine/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 13 additions & 0 deletions pkg/driver/driver_aws.go
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,19 @@ func (d *AWSDriver) Create() (string, string, error) {
TagSpecifications: []*ec2.TagSpecification{tagInstance, tagVolume},
}

if d.AWSMachineClass.Spec.SpotPrice != nil {
inputConfig.InstanceMarketOptions = &ec2.InstanceMarketOptionsRequest{
MarketType: aws.String(ec2.MarketTypeSpot),
SpotOptions: &ec2.SpotMarketOptions{
SpotInstanceType: aws.String(ec2.SpotInstanceTypeOneTime),
},
}

if *d.AWSMachineClass.Spec.SpotPrice != "" {
inputConfig.InstanceMarketOptions.SpotOptions.MaxPrice = d.AWSMachineClass.Spec.SpotPrice
}
}

runResult, err := svc.RunInstances(&inputConfig)
if err != nil {
metrics.APIFailedRequestCount.With(prometheus.Labels{"provider": "aws", "service": "ecs"}).Inc()
Expand Down
6 changes: 6 additions & 0 deletions pkg/openapi/openapi_generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.