Skip to content

Minimal MachinePool support#1506

Merged
k8s-ci-robot merged 4 commits into
kubernetes-sigs:mainfrom
justinsb:machinepool
Jan 30, 2026
Merged

Minimal MachinePool support#1506
k8s-ci-robot merged 4 commits into
kubernetes-sigs:mainfrom
justinsb:machinepool

Conversation

@justinsb

@justinsb justinsb commented Aug 16, 2025

Copy link
Copy Markdown
Contributor
  • Initial spike: GCPMachinePool

  • GCPMachinePool: generated code/manifests

This continues the work started by @BrennenMM7 in #901 . I also combined in the support from cluster-api-provider-aws to see what we want to borrow from that, and will whittle the code we don't need from cluster-api-provider-aws away.


NONE

@k8s-ci-robot k8s-ci-robot added do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Aug 16, 2025
@netlify

netlify Bot commented Aug 16, 2025

Copy link
Copy Markdown

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

Name Link
🔨 Latest commit 793ea56
🔍 Latest deploy log https://app.netlify.com/projects/kubernetes-sigs-cluster-api-gcp/deploys/6968f932d172cd0008735d9f
😎 Deploy Preview https://deploy-preview-1506--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 project configuration.

@k8s-ci-robot k8s-ci-robot added the cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. label Aug 16, 2025
@k8s-ci-robot k8s-ci-robot requested review from cpanato and dims August 16, 2025 14:33
@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 16, 2025
@justinsb

Copy link
Copy Markdown
Contributor Author

This PR is WIP while I whittle down the unneeded code from cluster-api-provider-aws and generally make this reviewable. But I am uploading as this is a checkpoint that works (in a limited way!)

@justinsb justinsb force-pushed the machinepool branch 5 times, most recently from 428790f to 5906e99 Compare August 16, 2025 19:42
@justinsb justinsb changed the title WIP: Minimal MachinePool support Minimal MachinePool support Aug 23, 2025
@k8s-ci-robot k8s-ci-robot removed the do-not-merge/work-in-progress Indicates that a PR should not merge because it is a work in progress. label Aug 23, 2025
@justinsb

Copy link
Copy Markdown
Contributor Author

Removing the WIP. I will still try to whittle down the code by extracting helpers etc, but it's already approaching the reviewable ballpark!

@justinsb

Copy link
Copy Markdown
Contributor Author

So the linter is blowing up on the TODO comments. How do we want to track next steps in code? If we don't want to do // TODO because golangci, maybe we do // TASK?

@k8s-ci-robot k8s-ci-robot added release-note-none Denotes a PR that doesn't merit a release note. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed do-not-merge/release-note-label-needed Indicates that a PR should not merge because it's missing one of the release note labels. labels Aug 23, 2025
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 29, 2025
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 6, 2025
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Sep 6, 2025
@justinsb

Copy link
Copy Markdown
Contributor Author

Could we get this reviewed / approved?

@damdo

damdo commented Dec 22, 2025

Copy link
Copy Markdown
Member

Hey @justinsb I'm OOO but will prio this the first days of Jan as soon as I am back.
Thanks!

@salasberryfin salasberryfin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

/hold
/lgtm

Thanks @justinsb. I hold it so @damdo and @chrischdi can have time for a final review.

We should have a follow-up PR with a new section in the provider's book on how to use MachinePools. I'll create a separate issue.

Comment thread cloud/scope/machinepool.go
Comment thread exp/controllers/gcpmachinepool_controller.go
Comment thread exp/api/v1beta1/conditions_consts.go Outdated
@k8s-ci-robot k8s-ci-robot added do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. lgtm "Looks good to me", indicates that a PR is ready to be merged. labels Dec 23, 2025
Comment thread exp/controllers/gcpmachinepool_controller.go Outdated
Comment thread exp/controllers/gcpmachinepool_controller.go Outdated
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Dec 23, 2025

@damdo damdo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks a lot Justin!
This is looking good, left a couple of comments but it looks like we are already in great shape! TY

return nil, fmt.Errorf("creating instanceGroupManager %v: %w", selfLink, err)
}

actual, err = s.instanceGroupManagers.Get(ctx, igmKey)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are you going to add the comment here or elsewhere? TY

Comment thread exp/api/v1beta1/gcpmachinepool_types.go Outdated
Comment thread exp/api/v1beta1/gcpmachinepool_types.go Outdated
Comment on lines +49 to +83
// ValidateCreate implements webhook.Validator so a webhook will be registered for the type.
func (*gcpMachinePoolWebhook) ValidateCreate(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
r, ok := obj.(*GCPMachinePool)
if !ok {
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a GCPMachinePool but got a %T", obj))
}

gcpMachinePoolLog.Info("Validating GCPMachinePool create", "name", r.Name)

return nil, nil
}

// ValidateUpdate implements webhook.Validator so a webhook will be registered for the type.
func (*gcpMachinePoolWebhook) ValidateUpdate(_ context.Context, _, newObj runtime.Object) (admission.Warnings, error) {
r, ok := newObj.(*GCPMachinePool)
if !ok {
return nil, fmt.Errorf("expected a GCPMachinePool object but got %T", r)
}

gcpMachinePoolLog.Info("Validating GCPMachinePool update", "name", r.Name)

return nil, nil
}

// ValidateDelete implements webhook.Validator so a webhook will be registered for the type.
func (*gcpMachinePoolWebhook) ValidateDelete(_ context.Context, obj runtime.Object) (admission.Warnings, error) {
r, ok := obj.(*GCPMachinePool)
if !ok {
return nil, apierrors.NewBadRequest(fmt.Sprintf("expected a GCPMachinePool but got a %T", obj))
}

gcpMachinePoolLog.Info("Validating GCPMachinePool delete", "name", r.Name)

return nil, nil
}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Are we planning to add in the validation logic at a later stage?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I will add a few TODOs. I think we probably want to share logic with the machine validation. Does that work?

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Sounds good thanks!

Comment thread exp/controllers/gcpmachinepool_controller.go Outdated
Comment thread exp/controllers/gcpmachinepool_controller.go
// Requeue so that we can keep the spec.providerIDList and status in sync with the MIG.
// This is important for scaling up and down, as the CAPI MachinePool controller relies on
// the providerIDList to determine which machines belong to the MachinePool.
return ctrl.Result{RequeueAfter: 1 * time.Minute}, nil

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How are other providers that have implemented MachinePools doing this?

Comment thread cloud/scope/machine_test.go
justinsb and others added 4 commits January 15, 2026 14:26
Co-authored-by: Christian Schlotter <christi.schlotter@gmail.com>

Co-authored-by: Carlos Salas <salash66@gmail.com>
In order for nodes to be associated to the MachinePool, we need to populate the
spec.providerIDList field.  This field is known to the MachinePool controller.

Co-authored-by: Christian Schlotter <christi.schlotter@gmail.com>
@justinsb

Copy link
Copy Markdown
Contributor Author

So I think this looks pretty good (IMO) as a way to introduce the feature. I'm happy to split out InstanceNetworkInterfaceAliasIPRangesSpec into its own PR if we want more confidence that this is additive.

I think cleanup/deletion is tricky, but I think that machinepool has some logic to ensure that the gcpmachinepool is deleted first:
https://github.com/kubernetes-sigs/cluster-api/blob/main/internal/controllers/machinepool/machinepool_controller.go#L305-L340

So it looks like we are OK here, though I agree it's not the most obvious logic.

@salasberryfin salasberryfin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Thanks @justinsb.

Overall this looks good to me as a first iteration of machine pools. I'll wait for others to resolve their comments but we're good to go in my opinion.

We should also create issues for all of the follow-up improvements, additions, etc. to keep track of what needs further refinement.

@damdo damdo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Thanks @justinsb

/approve
/lgtm

Thanks @justinsb
I think we are good here!

@justinsb

Copy link
Copy Markdown
Contributor Author

Awesome thank you all! I opened issues for the follow ups that I identified (though I have likely missed some, and I'm sure we'll find more)

@salasberryfin I think you have a hold on this PR (which is why it is not merging) - is it OK to remove now?

@salasberryfin salasberryfin left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Sure, thanks @justinsb!

/lgtm
/unhold

@k8s-ci-robot k8s-ci-robot removed the do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. label Jan 30, 2026
@k8s-ci-robot

Copy link
Copy Markdown
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: damdo, justinsb, salasberryfin

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

The pull request process is described here

Details Needs approval from an approver in each of these files:
  • OWNERS [damdo,justinsb,salasberryfin]

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 merged commit 6801574 into kubernetes-sigs:main Jan 30, 2026
16 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

approved Indicates a PR has been approved by an approver from all required OWNERS files. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note-none Denotes a PR that doesn't merit a release note. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants