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

Add support for Spot VMs #1313

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

jwmay2012
Copy link
Contributor

What type of PR is this?
/kind feature

What this PR does / why we need it:
Adds support for GCP Spot VMs, which are distinct from preemptible vms. Spot VMs are newer.
https://cloud.google.com/compute/docs/instances/spot
They no longer have a mandatory 24 hr limit.

Special notes for your reviewer:

Modeled PR after the addition of preemptible vms.

Documentation that specifies details on provisioningModel, SPOT and STANDARD--
https://registry.terraform.io/providers/hashicorp/google/latest/docs/resources/compute_instance#provisioning_model
https://cloud.google.com/compute/docs/instances/create-use-spot#create

Relevant docs about field logic--

"provisioningModel": "SPOT" in the Compute Engine API

---------------

If the output includes the provisioningModel field set to SPOT, the VM is a Spot VM.

Otherwise, if the output includes the provisioningModel field set to standard or if the output omits the provisioningModel field:
- If the output includes the preemptible field set to true, the VM is a preemptible VM.
- Otherwise, the VM is a standard VM.

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests
    No tests exist for preemptible vms. This change seems pretty simple and straight forward and doesn't cause any changes unless the new field is used.

Release note:

Add support for Spot VMs. `GCPMachineTemplate.Spec.ProvisioningModel = "Spot"`

@k8s-ci-robot k8s-ci-robot added release-note Denotes a PR that will be considered when it comes time to generate release notes. kind/feature Categorizes issue or PR as related to a new feature. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. labels Sep 18, 2024
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is NOT APPROVED

This pull-request has been approved by: jwmay2012
Once this PR has been reviewed and has the lgtm label, please assign cpanato for approval. For more information see the Kubernetes Code Review Process.

The full list of commands accepted by this bot can be found here.

Needs approval from an approver in each of these files:

Approvers can indicate their approval by writing /approve in a comment
Approvers can cancel approval by writing /approve cancel in a comment

@k8s-ci-robot k8s-ci-robot added the needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. label Sep 18, 2024
@k8s-ci-robot
Copy link
Contributor

Hi @jwmay2012. Thanks for your PR.

I'm waiting for a kubernetes-sigs member to verify that this patch is reasonable to test. If it is, they should reply with /ok-to-test on its own line. Until that is done, I will not automatically test new commits in this PR, but the usual testing commands by org members will still work. Regular contributors should join the org to skip this step.

Once the patch is verified, the new status will be reflected by the ok-to-test label.

I understand the commands that are listed here.

Instructions for interacting with me using PR comments are available here. If you have questions or suggestions related to my behavior, please file an issue against the kubernetes-sigs/prow repository.

@k8s-ci-robot k8s-ci-robot added the size/M Denotes a PR that changes 30-99 lines, ignoring generated files. label Sep 18, 2024
Copy link

netlify bot commented Sep 18, 2024

Deploy Preview for kubernetes-sigs-cluster-api-gcp ready!

Name Link
🔨 Latest commit 1cd1566
🔍 Latest deploy log https://app.netlify.com/sites/kubernetes-sigs-cluster-api-gcp/deploys/66f2e835ed68190008bd9183
😎 Deploy Preview https://deploy-preview-1313--kubernetes-sigs-cluster-api-gcp.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify site configuration.

@salasberryfin
Copy link
Contributor

salasberryfin commented Sep 24, 2024

/ok-to-test

Thanks for working on this @jwmay2012!

@k8s-ci-robot k8s-ci-robot added ok-to-test Indicates a non-member PR verified by an org member that is safe to test. and removed needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. labels Sep 24, 2024
@@ -402,6 +402,16 @@ func (m *MachineScope) InstanceSpec(log logr.Logger) *compute.Instance {
Preemptible: m.GCPMachine.Spec.Preemptible,
},
}
if m.GCPMachine.Spec.ProvisioningModel != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

Should we also explicitly set the ProvisioningModel to Standard when not null or is it implicitly set by GCP?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I do believe GCP defaults to STANDARD. All documentation seems to be focused around specifying SPOT and otherwise ignoring the field.

I also figured it was lower risk to maintain the existing behavior when the field is not set, allowing the GCP default to continue to be used.

@salasberryfin
Copy link
Contributor

The CAPG book contains a section on using Preemptible VMs (book source files can be found here). Perhaps it makes sense to also document Spot VMs and what happens with each combination of Preemptible + ProvisioningModel, as you specified on type definition. What do you think?

@jwmay2012
Copy link
Contributor Author

The CAPG book contains a section on using Preemptible VMs (book source files can be found here). Perhaps it makes sense to also document Spot VMs and what happens with each combination of Preemptible + ProvisioningModel, as you specified on type definition. What do you think?

Makes sense. I'll add the specifics of Preemptible + ProvisioningModel to the docs I've already made. I believe Preemptible gets ignored and ProvisioiningModel overrides. This is implicit in the documentation, but I'll confirm first.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. kind/feature Categorizes issue or PR as related to a new feature. ok-to-test Indicates a non-member PR verified by an org member that is safe to test. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/M Denotes a PR that changes 30-99 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants