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

Support APIServerAccessProfile in AzureManagedControlPlane #1640

Merged

Conversation

richardchen331
Copy link
Contributor

@richardchen331 richardchen331 commented Aug 21, 2021

What type of PR is this?
/kind feature

What this PR does / why we need it:
Adds APIServerAccessProfile support in AzureManagedControlPlane.

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 #1605

Special notes for your reviewer:

Please confirm that if this PR changes any image versions, then that's the sole change this PR makes.

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

Allow specifying APIServerAccessProfile in AzureManagedControlPlane.

@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 Aug 21, 2021
@k8s-ci-robot
Copy link
Contributor

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

@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 Aug 21, 2021
@k8s-ci-robot k8s-ci-robot added area/provider/azure Issues or PRs related to azure provider sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/L Denotes a PR that changes 100-499 lines, ignoring generated files. labels Aug 21, 2021
@mboersma
Copy link
Contributor

/ok-to-test

@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 Aug 23, 2021
@richardchen331
Copy link
Contributor Author

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

@CecileRobertMichon
Copy link
Contributor

/assign @alexeldeib @LochanRn @nprokopic

@LochanRn
Copy link
Member

lgtm
@alexeldeib @nprokopic ManagedClusterAPIServerAccessProfile also provides config to create private clusters I was thinking adding those set of features will also be great WDYT ?

@LochanRn
Copy link
Member

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 27, 2021
@LochanRn
Copy link
Member

@richardchen331 Great Job !!

WDYT about adding spec for private clusters ?

@richardchen331
Copy link
Contributor Author

Thanks @mboersma @LochanRn ! Sure, let me add spec for private clusters as well.

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Aug 31, 2021
AuthorizedIPRanges []string `json:"authorizedIPRanges,omitempty"`
// EnablePrivateCluster - Whether to create the cluster as a private cluster or not.
// +optional
EnablePrivateCluster bool `json:"enablePrivateCluster,omitempty"`
Copy link
Contributor

Choose a reason for hiding this comment

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

If this field is optional, I believe a bool pointer *bool would be better. Same for EnablePrivateClusterPublicFQDN. WDYT?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@nprokopic Thanks for your feedback! I'm pretty new to golang and cluster api, and my (limited) understanding of using a pointer is that we could differentiate between a zero value and a not specified value, but then we have to deal with nil. For EnablePrivateCluster, I think explicitly passing in a zero value (false) is equivalent to not passing it (both tells Azure to not enable private cluster). Therefore I'm not aware of the benefit of using a pointer.

Could you help explain a bit more why a bool pointer is better? I think I must have missed something and I'd love to learn :) Thank you!

Copy link
Contributor

Choose a reason for hiding this comment

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

It is part of the k8s API conventions:

Therefore, we ask that pointers always be used with optional fields that do not have a built-in nil value.

https://github.com/kubernetes/community/blob/master/contributors/devel/sig-architecture/api-conventions.md#optional-vs-required

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Got it, thanks for the reference! I'll change the fields to use pointers.

Copy link
Contributor

Choose a reason for hiding this comment

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

It is part of the k8s API conventions

I vaguely remembered something like that, and that we had a similar discussion for some other CAPZ type some time ago, just couldn't find it.

Thanks Cecile for referencing this.

@LochanRn
Copy link
Member

LochanRn commented Sep 2, 2021

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


// setDefaultAPIServerAccessProfile sets the default APIServerAccessProfile for an AzureManagedControlPlane.
func (r *AzureManagedControlPlane) setDefaultAPIServerAccessProfile() {
if r.Spec.APIServerAccessProfile == nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: Is this required? Wouldn't just leaving nil also work?

@CecileRobertMichon are there some other examples of setting default values like this?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

You are right, I don't think this is required. (I was thinking setting it so there will be less working in validation webhook, but i don't think this is a good idea, since it's not good for unit test)

@richardchen331
Copy link
Contributor Author

/retest

@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 15, 2021
@LochanRn
Copy link
Member

@richardchen331 can you please also update the managedclusters documentation about APIServerAccessProfile.

@alexeldeib over all this PR looks fine to me now. Over to you for a final review.

@richardchen331
Copy link
Contributor Author

richardchen331 commented Sep 15, 2021

@richardchen331 can you please also update the managedclusters documentation about APIServerAccessProfile.

@alexeldeib over all this PR looks fine to me now. Over to you for a final review.

Sure. I'll rebase and update the documentation after the other open PR (#1680) is merged since they modify similar set of files :)

@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 21, 2021
@richardchen331
Copy link
Contributor Author

@alexeldeib I just rebased this PR and also added documentation. Could you help take a final look? Thanks!

@richardchen331
Copy link
Contributor Author

/retest

3 similar comments
@richardchen331
Copy link
Contributor Author

/retest

@richardchen331
Copy link
Contributor Author

/retest

@richardchen331
Copy link
Contributor Author

/retest

// PrivateDNSZone - Private dns zone mode for private cluster.
PrivateDNSZone *string
// EnablePrivateClusterPublicFQDN - Whether to create additional public FQDN for private cluster or not.
EnablePrivateClusterPublicFQDN *bool
Copy link
Contributor

Choose a reason for hiding this comment

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

I believe this will default to true on AKS side if private cluster is enabled. should we let that happen, or default it inside CAPZ?

it would only mean that a user who explicitly sets it would trigger a no-op reconcile, and a user who wants to change it will be able to.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks for the feedback! I would slightly prefer letting AKS to handle the default. My rationales are:

  1. This is true for other fields as well (e.g. managedOutboundIPs, sku tier)
  2. We need to add some logic when choosing the default values (e.g. set EnablePrivateClusterPublicFQDN to true when EnablePrivateCluster is true)
  3. Given 1,2, this will add some extra complexity to the CAPZ code
    The downside is that there will be some unnecessary no-op reconciles, but i feel that's probably fine?

I'm open to change it if you feel strongly about it :)

Copy link
Contributor

@alexeldeib alexeldeib Sep 29, 2021

Choose a reason for hiding this comment

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

Fine w me, I asked because I know this defaulting to true has surprised some folks in the past

Copy link
Contributor

Choose a reason for hiding this comment

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

But that’s really an aks issue

@alexeldeib
Copy link
Contributor

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

probably related to the failures we've been discussing. I chatted a bit with @LochanRn about watch issues unrelated to the AKS backend issue, we still have some debugging to do

@alexeldeib
Copy link
Contributor

/approve
/lgtm

(adding both since this was already approved)

one minor comment but not a blocker

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Sep 29, 2021
@k8s-ci-robot
Copy link
Contributor

[APPROVALNOTIFIER] This PR is APPROVED

This pull-request has been approved by: alexeldeib

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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Sep 29, 2021
@richardchen331
Copy link
Contributor Author

/retest

@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 1, 2021
@richardchen331
Copy link
Contributor Author

/retest

@alexeldeib
Copy link
Contributor

/lgtm

@k8s-ci-robot k8s-ci-robot added the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 1, 2021
@k8s-ci-robot k8s-ci-robot merged commit df75af2 into kubernetes-sigs:main Oct 1, 2021
@k8s-ci-robot k8s-ci-robot added this to the v0.5 milestone Oct 1, 2021
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/provider/azure Issues or PRs related to azure provider 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. 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. sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. size/L Denotes a PR that changes 100-499 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Allow user to specify APIServerAccessProfile
7 participants