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 ClusterClass Support for Managed Clusters #4155

Merged

Conversation

willie-yao
Copy link
Contributor

@willie-yao willie-yao commented Oct 18, 2023

What type of PR is this?
/kind feature

What this PR does / why we need it:
This PR adds ClusterClass support for managed clusters.

Which issue(s) this PR fixes (optional, in fixes #<issue number>(, fixes #<issue_number>, ...) format, will close the issue(s) when PR gets merged):
Fixes #2684

Special notes for your reviewer:

  • cherry-pick candidate

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

Add ClusterClass support for managed clusters

@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 Oct 18, 2023
@k8s-ci-robot k8s-ci-robot added the size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. label Oct 18, 2023
@willie-yao
Copy link
Contributor Author

/test pull-cluster-api-provider-azure-e2e-optional

func (m *AzureManagedControlPlane) validateVersion(_ client.Client) error {
if !kubeSemver.MatchString(m.Spec.Version) {
return errors.New("must be a valid semantic version")
func validateVersion(version string, fldPath *field.Path) field.ErrorList {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored these webhook validation functions to be usable by the template types

}

// validateLastSystemNodePool is used to check if the existing system node pool is the last system node pool.
// If it is a last system node pool it cannot be deleted or mutated to user node pool as AKS expects min 1 system node pool.
func (m *AzureManagedMachinePool) validateLastSystemNodePool(cli client.Client) error {
func validateLastSystemNodePool(cli client.Client, labels map[string]string, namespace string) error {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Refactored these functions for the same purpose as above ^^

@willie-yao willie-yao force-pushed the clusterclass-aks-final branch from 8a22191 to 04c455e Compare October 18, 2023 22:07
@willie-yao willie-yao force-pushed the clusterclass-aks-final branch from 04c455e to 1b5519d Compare October 18, 2023 23:22
@codecov
Copy link

codecov bot commented Oct 18, 2023

Codecov Report

Attention: 187 lines in your changes are missing coverage. Please review.

Comparison is base (55e0559) 59.55% compared to head (224b7dc) 59.73%.
Report is 2 commits behind head on main.

Files Patch % Lines
...v1beta1/azuremanagedmachinepooltemplate_webhook.go 56.73% 85 Missing and 5 partials ⚠️
...1beta1/azuremanagedcontrolplanetemplate_webhook.go 74.61% 43 Missing and 7 partials ⚠️
api/v1beta1/azuremanagedclustertemplate_webhook.go 0.00% 18 Missing ⚠️
api/v1beta1/azuremanagedcontrolplane_webhook.go 93.66% 7 Missing and 2 partials ⚠️
api/v1beta1/azuremanagedmachinepool_webhook.go 95.65% 5 Missing ⚠️
api/v1beta1/azuremanagedcontrolplane_default.go 93.33% 3 Missing and 1 partial ⚠️
...1beta1/azuremanagedcontrolplanetemplate_default.go 88.23% 3 Missing and 1 partial ⚠️
controllers/helpers.go 0.00% 3 Missing and 1 partial ⚠️
azure/defaults.go 0.00% 2 Missing ⚠️
controllers/azuremanagedcontrolplane_controller.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4155      +/-   ##
==========================================
+ Coverage   59.55%   59.73%   +0.17%     
==========================================
  Files         185      192       +7     
  Lines       18782    19303     +521     
==========================================
+ Hits        11186    11531     +345     
- Misses       6981     7142     +161     
- Partials      615      630      +15     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@Jont828
Copy link
Contributor

Jont828 commented Oct 18, 2023

/assign

Copy link
Contributor

@Jont828 Jont828 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! Here's some comments from a first pass. It seems like most of it is template stuff, so I think if we can get all the tests passing, we can consider the templates to be good to go.

api/v1beta1/azuremanagedclustertemplate_types.go Outdated Show resolved Hide resolved
api/v1beta1/azuremanagedclustertemplate_webhook.go Outdated Show resolved Hide resolved
api/v1beta1/azuremanagedclustertemplate_webhook.go Outdated Show resolved Hide resolved
api/v1beta1/azuremanagedcontrolplane_types.go Outdated Show resolved Hide resolved
api/v1beta1/azuremanagedcontrolplanetemplate_types.go Outdated Show resolved Hide resolved
docs/book/src/topics/clusterclass.md Outdated Show resolved Hide resolved
test/e2e/azure_test.go Outdated Show resolved Hide resolved
test/e2e/azure_test.go Outdated Show resolved Hide resolved
test/e2e/config/azure-dev.yaml Outdated Show resolved Hide resolved
@willie-yao
Copy link
Contributor Author

/retest

@jackfrancis
Copy link
Contributor

/assign @nojnhuh

@jackfrancis
Copy link
Contributor

/assign

@willie-yao
Copy link
Contributor Author

Not sure what's going on, but looks like the E2E test is having trouble applying the cluster template. It was working before but I made some updates to the webhoook validation since. Will be debugging this

@willie-yao willie-yao force-pushed the clusterclass-aks-final branch 3 times, most recently from 7f66d45 to 322243d Compare October 19, 2023 20:42
@willie-yao
Copy link
Contributor Author

Not sure what's going on, but looks like the E2E test is having trouble applying the cluster template. It was working before but I made some updates to the webhoook validation since. Will be debugging this

Fixed!

Copy link
Contributor

@nojnhuh nojnhuh left a comment

Choose a reason for hiding this comment

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

Still working through this, but wanted to share what I had so far.

api/v1beta1/azuremanagedclustertemplate_webhook.go Outdated Show resolved Hide resolved
api/v1beta1/azuremanagedcontrolplane_types.go Outdated Show resolved Hide resolved
api/v1beta1/consts.go Outdated Show resolved Hide resolved
api/v1beta1/azuremanagedcontrolplane_webhook.go Outdated Show resolved Hide resolved
api/v1beta1/azuremanagedcontrolplane_webhook.go Outdated Show resolved Hide resolved
api/v1beta1/azuremanagedcontrolplane_webhook_test.go Outdated Show resolved Hide resolved
api/v1beta1/azuremanagedcontrolplanetemplate_default.go Outdated Show resolved Hide resolved
test/e2e/config/azure-dev.yaml Outdated Show resolved Hide resolved
api/v1beta1/types_template.go Outdated Show resolved Hide resolved
api/v1beta1/types_template.go Outdated Show resolved Hide resolved
@willie-yao willie-yao force-pushed the clusterclass-aks-final branch 2 times, most recently from 46c2516 to 20bad8e Compare October 24, 2023 01:31
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 8bb8429606aaa9c36a8f27c4995b47a0d54b3434

@k8s-ci-robot k8s-ci-robot added approved Indicates a PR has been approved by an approver from all required OWNERS files. needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Nov 16, 2023
@willie-yao willie-yao force-pushed the clusterclass-aks-final branch from ce7d6b8 to 224b7dc Compare November 16, 2023 19:02
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Nov 16, 2023
@k8s-ci-robot k8s-ci-robot removed the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Nov 16, 2023
@@ -170,4 +170,6 @@ const (
AzureManagedControlPlaneKind = "AzureManagedControlPlane"
// AzureClusterIdentityKind indicates the kind of an AzureClusterIdentity.
AzureClusterIdentityKind = "AzureClusterIdentity"
// AzureNetworkPluginName is the name of the Azure network plugin.
AzureNetworkPluginName = "azure"
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: can we move this out of that const block, it's not a Kind so doesn't belong with the others

Copy link
Contributor

Choose a reason for hiding this comment

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

can do in follow up

return nil, mcp.validateManagedControlPlaneTemplate(mcpw.Client)
}

return nil, apierrors.NewInvalid(GroupVersion.WithKind("AzureManagedControlPlaneTemplate").GroupKind(), mcp.Name, allErrs)
Copy link
Contributor

Choose a reason for hiding this comment

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

now that we have consts for kinds, would be good to also use constants for these new kinds

Can be a follow up since that other PR just merged

Copy link
Contributor

@CecileRobertMichon CecileRobertMichon left a comment

Choose a reason for hiding this comment

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

/lgtm
/approve
/hold cancel

@willie-yao let's merge this to get it into the release. Can you please open a follow-up PR to include the new kinds as constants following #4233 ?

@k8s-ci-robot k8s-ci-robot added lgtm "Looks good to me", indicates that a PR is ready to be merged. and removed do-not-merge/hold Indicates that a PR should not merge because someone has issued a /hold command. labels Nov 16, 2023
@k8s-ci-robot
Copy link
Contributor

LGTM label has been added.

Git tree hash: 9b2c6cf19c88392c511758bfef11333d9e2f4744

@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: CecileRobertMichon

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

The pull request process is described 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

@willie-yao
Copy link
Contributor Author

let's merge this to get it into the release. Can you please open a follow-up PR to include the new kinds as constants following #4233 ?

Will do, thanks!

@willie-yao
Copy link
Contributor Author

/retest

1 similar comment
@CecileRobertMichon
Copy link
Contributor

/retest

@k8s-ci-robot
Copy link
Contributor

k8s-ci-robot commented Nov 16, 2023

@willie-yao: The following test failed, say /retest to rerun all failed tests or /retest-required to rerun all mandatory failed tests:

Test name Commit Details Required Rerun command
pull-cluster-api-provider-azure-apidiff 224b7dc link false /test pull-cluster-api-provider-azure-apidiff

Full PR test history. Your PR dashboard. Please help us cut down on flakes by linking to an open issue when you hit one in your PR.

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/test-infra repository. I understand the commands that are listed here.

@CecileRobertMichon
Copy link
Contributor

CecileRobertMichon commented Nov 16, 2023

Bypassing test rerun to speed up release as the last main commit is a metadata.yaml only update (#4284) and we have green signal on the current commit already from the previous run: https://prow.k8s.io/view/gs/kubernetes-jenkins/pr-logs/pull/kubernetes-sigs_cluster-api-provider-azure/4155/pull-cluster-api-provider-azure-e2e-aks/1725228064436129792

/override pull-cluster-api-provider-azure-ci-entrypoint
/override pull-cluster-api-provider-azure-e2e
/override pull-cluster-api-provider-azure-e2e-aks

@CecileRobertMichon

This comment was marked as duplicate.

@k8s-ci-robot
Copy link
Contributor

@CecileRobertMichon: Overrode contexts on behalf of CecileRobertMichon: pull-cluster-api-provider-azure-ci-entrypoint

In response to this:

/override pull-cluster-api-provider-azure-ci-entrypoint

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/test-infra repository.

@CecileRobertMichon

This comment was marked as outdated.

@k8s-ci-robot
Copy link
Contributor

@CecileRobertMichon: Overrode contexts on behalf of CecileRobertMichon: pull-cluster-api-provider-azure-e2e, pull-cluster-api-provider-azure-e2e-aks

In response to this:

/override pull-cluster-api-provider-azure-e2e
/override pull-cluster-api-provider-azure-e2e-aks

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/test-infra repository.

@k8s-ci-robot k8s-ci-robot merged commit 005b9f8 into kubernetes-sigs:main Nov 16, 2023
29 of 30 checks passed
@nojnhuh nojnhuh added the area/managedclusters Issues related to managed AKS clusters created through the CAPZ ManagedCluster Type label Feb 14, 2024
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. area/managedclusters Issues related to managed AKS clusters created through the CAPZ ManagedCluster Type 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. lgtm "Looks good to me", indicates that a PR is ready to be merged. release-note Denotes a PR that will be considered when it comes time to generate release notes. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files.
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Add support for ClusterClass and managed clusters
7 participants