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

Implement control plane template #88

Merged
merged 1 commit into from
May 9, 2024

Conversation

anmazzotti
Copy link
Contributor

This should be part of #62
The main focus of this PR is to enable Cluster Classes.

The KThreesControlPlaneTemplateSpec was introduced for this very reason.
Changes to the existing KThreesControlPlaneMachineTemplate are also required for the correct reconciliation of the Cluster topology.

Still in draft as I'm testing if everything still works.
I am not sure whether this will introduce backward compatibility, probably yes since the API changed, however I am not sure how else this could be implemented differently.

@richardcase
Copy link
Collaborator

As you mention this change really needs to be done as part of a API version bump to v1beta2 as the change is API breaking.

@richardcase
Copy link
Collaborator

@zawachte - i'll start work on a PR to bump the API version so that we can start work on v1beta1 (will also create the 0.1 release branch)

@anmazzotti
Copy link
Contributor Author

PR is ready for review.
I did implement the new v1beta2 version, added conversion and the webhooks (for conversion, validation is empty).

I bumped the GOLANGCI_LINT_VER to solve an issue with the depguard linter I'm having. Didn't really help but the bump should not harm.
Same for CONTROLLER_GEN_VER.

Also note that I tweaked the generated manifests. For example when generating the bootstrap manifests, we now only include the bootstrap subfolder: paths=./bootstrap/...
The reason for this is to avoid generating overlapping manifests. This is fine in the current version, but it was conflicting with the creation of the webhooks (generating the same webhook for the same resource on both controllers).

I also tested this patch locally by:

  1. Provisioning a v1beta1 k3s cluster from this cluster template and the resources are correctly converted to v1beta2 as expected.

  2. Provisioning a v1beta2 k3s cluster from a cluster class and it works as expected thanks to the addition of the KThreesControlPlaneTemplate as required by CAPI.

@anmazzotti anmazzotti marked this pull request as ready for review January 11, 2024 09:37
@richardcase
Copy link
Collaborator

Thanks @anmazzotti . I will start reviewing.

Copy link
Collaborator

@richardcase richardcase left a comment

Choose a reason for hiding this comment

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

Thanks for this @anmazzotti . A few minor comments, nothing major. Let me know if i need to clarify anything.

It would have been easier for reviewers if the introduction of the v1beta2 api version was in a separate PR to the introduction of the control plane template.

Also, before we merge will you be able to squash your commits so they tell a store. Perhaps into 2 commits: 1 for the API version bump and 1 for the control plane template.

bootstrap/api/v1beta1/conversion.go Show resolved Hide resolved
bootstrap/api/v1beta1/conversion.go Show resolved Hide resolved
@@ -0,0 +1,71 @@
/*
Copyright 2020 The Kubernetes Authors.
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit: as its a new file maybe 2024 would be better?

bootstrap/api/v1beta2/conversion.go Show resolved Hide resolved

// KThreesConfigTemplateSpec defines the desired state of KThreesConfigTemplate.
type KThreesConfigTemplateSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
Copy link
Collaborator

Choose a reason for hiding this comment

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

We can probably remove this autogenerated comment

controlplane/api/v1beta1/conversion.go Show resolved Hide resolved
controlplane/api/v1beta1/conversion.go Show resolved Hide resolved
g.Expect(AddToScheme(scheme)).To(Succeed())
g.Expect(cabp3v1.AddToScheme(scheme)).To(Succeed())

t.Run("for KThreesConfig", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
Copy link
Collaborator

Choose a reason for hiding this comment

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

nit:

Suggested change
t.Run("for KThreesConfig", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{
t.Run("for KThreesControlPlane", utilconversion.FuzzTestFunc(utilconversion.FuzzTestFuncInput{

@@ -0,0 +1,130 @@
/*
Copyright 2020 The Kubernetes Authors.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Suggested change
Copyright 2020 The Kubernetes Authors.
Copyright 2024 The Kubernetes Authors.

controlplane/api/v1beta2/conversion.go Show resolved Hide resolved
@anmazzotti
Copy link
Contributor Author

It would have been easier for reviewers if the introduction of the v1beta2 api version was in a separate PR to the introduction of the control plane template.

I did not see this PR coming, sorry for that and thank you for the review.
I'll also squash as you recommended.

@zawachte
Copy link
Collaborator

zawachte commented Feb 3, 2024

@anmazzotti what is the status here? Are you waiting for my review?

@anmazzotti
Copy link
Contributor Author

@anmazzotti what is the status here? Are you waiting for my review?

Affirmative.

@anmazzotti
Copy link
Contributor Author

Also please do not release after this is merged. I have a follow up PR to remove the DisableExternalCloudProvider flag I introduced earlier. I found out it doesn't make sense, so I'll remove in the new version v1beta2

@anmazzotti anmazzotti force-pushed the implement-control-plane-template branch from 29d8ae4 to 9badbb7 Compare February 8, 2024 12:21
Copy link
Collaborator

@richardcase richardcase left a comment

Choose a reason for hiding this comment

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

This is looking good @anmazzotti. Great work.

Just a couple of things:

  • Could you confirm what manual testing you have done with the new control plane template?
  • Could you squash the commits so they tell a story?

@anmazzotti
Copy link
Contributor Author

This is looking good @anmazzotti. Great work.

Just a couple of things:

* Could you confirm what manual testing you have done with the new control plane template?

* Could you squash the commits so they tell a story?

Thank you.
Yes I did manual test using the Elemental provider and it works.
I will also start working on deprecating the DisableExternalCloudProvider flag as soon as this is merged and I will do a full round of testing for that as well, so we are confident before the next release.

I'll squash two commits to highlight the new version being added and the KThreesControlPlaneTemplate addition too. I think those two are the most important features for this PR, rest is scaffolding.

@richardcase
Copy link
Collaborator

I'll squash two commits to highlight the new version being added and the KThreesControlPlaneTemplate addition too. I think those two are the most important features for this PR, rest is scaffolding.

Sounds good to me 👍

@anmazzotti anmazzotti force-pushed the implement-control-plane-template branch from 9badbb7 to 4fe6c8a Compare February 16, 2024 08:56
@mogliang
Copy link
Collaborator

I see there are thousands of new files in vendor folder, do we need check in this folder?

@anmazzotti anmazzotti force-pushed the implement-control-plane-template branch from 4fe6c8a to b2841f1 Compare March 27, 2024 08:47
@anmazzotti anmazzotti force-pushed the implement-control-plane-template branch from b74ef2d to 5b87294 Compare April 16, 2024 14:10
mogliang
mogliang previously approved these changes May 8, 2024
Copy link
Collaborator

@mogliang mogliang left a comment

Choose a reason for hiding this comment

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

LGTM

@mogliang
Copy link
Collaborator

mogliang commented May 8, 2024

@anmazzotti would you please resolve conflicts?

Copy link
Collaborator

@richardcase richardcase left a comment

Choose a reason for hiding this comment

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

@anmazzotti - would you be able to squash the commits so they tell a story?

Apart from squashing the commits i think this is good to go from my side.

bootstrap/api/v1beta2/kthreesconfig_types.go Outdated Show resolved Hide resolved
bootstrap/api/v1beta2/kthreesconfig_types.go Show resolved Hide resolved
bootstrap/api/v1beta2/kthreesconfig_types.go Show resolved Hide resolved
@anmazzotti anmazzotti force-pushed the implement-control-plane-template branch from 1db1973 to 1e126bb Compare May 8, 2024 09:21
@mogliang mogliang merged commit 7d52020 into k3s-io:main May 9, 2024
5 checks passed
@mogliang
Copy link
Collaborator

mogliang commented May 9, 2024

@anmazzotti would you mind adding a e2e test case to cover clusterclass?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants