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

Azure active directory support for managedclusters #1560

Merged
merged 1 commit into from
Aug 12, 2021

Conversation

LochanRn
Copy link
Member

@LochanRn LochanRn commented Jul 26, 2021

What type of PR is this?
/kind feature

What this PR does / why we need it:
Adds Azure active directory support for user authentication in 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 #1407

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:

Spec aadProfile contains a Legacy Spec for legacy AAD support and Managed Spec for new/managed AAD support. 

@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. labels Jul 26, 2021
@k8s-ci-robot
Copy link
Contributor

Hi @LochanRn. 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 needs-ok-to-test Indicates a PR that requires an org member to verify it is safe to test. cncf-cla: yes Indicates the PR's author has signed the CNCF CLA. size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Jul 26, 2021
@k8s-ci-robot k8s-ci-robot requested review from devigned and shysank July 26, 2021 13:48
@k8s-ci-robot k8s-ci-robot added the sig/cluster-lifecycle Categorizes an issue or PR as relevant to SIG Cluster Lifecycle. label Jul 26, 2021
@@ -197,6 +197,31 @@ spec:
---
```

### AKS AAD

Azure Kubernetes Service can be configured to use Azure Active Directory for user authentication.
Copy link
Contributor

Choose a reason for hiding this comment

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

can you please add a link to the AKS AAD documentation here? https://docs.microsoft.com/en-us/azure/aks/managed-aad

Copy link
Member Author

Choose a reason for hiding this comment

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

sure 👍

@CecileRobertMichon
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 Jul 26, 2021
@LochanRn LochanRn force-pushed the aks-aad branch 4 times, most recently from d60aff0 to c2f7843 Compare July 27, 2021 22:19
@LochanRn
Copy link
Member Author

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

@LochanRn
Copy link
Member Author

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

@LochanRn
Copy link
Member Author

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

1 similar comment
@LochanRn
Copy link
Member Author

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

@LochanRn
Copy link
Member Author

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

}
}

if existingMC.AadProfile != nil {
Copy link
Contributor

Choose a reason for hiding this comment

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

is there any normalization happening here? if no, you can simply compare the raw structs.

Copy link
Contributor

Choose a reason for hiding this comment

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

ah, is tenant ID immutable?

Copy link
Member Author

Choose a reason for hiding this comment

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

yeah amcp spec is normalized to aadProfile and version.

description: AadProfile is Azure Active Directory configuration to
integrate with AKS for aad authentication.
properties:
legacyAadProfile:
Copy link
Contributor

Choose a reason for hiding this comment

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

I would almost be tempted to reject this for creates inside the reconciler? I would be okay allowing this for adoption scenarios, but we shouldn't be encouraging it for new clusters.

That is a bit aggressive of a constraint, but I also explicitly didn't support Basic LB or VMAS.

What do you think?

Copy link
Member Author

Choose a reason for hiding this comment

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

It is a good point even I agree with that. I will make changes accordingly.

type LegacyAAD struct {
// ClientAppID - The client AAD application ID.
// +kubebuilder:validation:Required
ClientAppID *string `json:"clientAppID"`
Copy link
Contributor

Choose a reason for hiding this comment

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

any reason these are pointers if they are required, non-omitempty?

Copy link
Member Author

@LochanRn LochanRn Aug 6, 2021

Choose a reason for hiding this comment

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

In the begining I was validating it a bit differently, so I needed it. I will change this to normal strings.

Copy link
Member Author

Choose a reason for hiding this comment

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

I did not have legacyaad and managedaad, all the fields where under one spec AADProfile. So for validation purpose i took them all as a pointer, but this was very tedious and not very clean. Latter I iterated to have legacy and managed as two separate specs. When I iterated i did not change it. But will change it now.


// AdminGroupObjectIDs - AAD group object IDs that will have admin role of the cluster.
// +kubebuilder:validation:Required
AdminGroupObjectIDs *[]string `json:"adminGroupObjectIDs"`
Copy link
Contributor

Choose a reason for hiding this comment

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

nit: pointer to a slice is awkward

Copy link
Contributor

Choose a reason for hiding this comment

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

(vs a raw slice)

Copy link
Member Author

Choose a reason for hiding this comment

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

ack

}

if new.ManagedAAD == nil {
if !reflect.DeepEqual(new.LegacyAAD, old.LegacyAAD) {
Copy link
Contributor

Choose a reason for hiding this comment

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

prefer not to use reflection....but I guess it's fine here since all members are simple types anyway..

}

func (r *AzureManagedControlPlane) validateLegacyAadProfile() bool {
return r.Spec.AADProfile.LegacyAAD != nil
Copy link
Contributor

Choose a reason for hiding this comment

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

is this missing some additional validation?

Copy link
Member Author

Choose a reason for hiding this comment

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

Nope I guess I can remove the function here and directly do a check above. But this would be required only during an update now. Support during creation will be removed.

@alexeldeib
Copy link
Contributor

minor comments, looks pretty clean on a first pass. nice work!

@k8s-ci-robot k8s-ci-robot added needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. labels Aug 7, 2021
@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Aug 9, 2021
@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 9, 2021
@k8s-ci-robot k8s-ci-robot added size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. and removed size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. labels Aug 9, 2021
@LochanRn
Copy link
Member Author

LochanRn commented Aug 9, 2021

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

@alexeldeib
Copy link
Contributor

/lgtm

on a roll! nice work :)

this might be a good one to cover in e2e? we can open an issue perhaps, I supposed it's a bit involved.

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

/lgtm

on a roll! nice work :)

this might be a good one to cover in e2e? we can open an issue perhaps, I supposed it's a bit involved.

yes you are right !! We need to cover this in e2e :)

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.

/approve

@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

@k8s-ci-robot k8s-ci-robot added the approved Indicates a PR has been approved by an approver from all required OWNERS files. label Aug 12, 2021
@k8s-ci-robot k8s-ci-robot merged commit 3a1557d into kubernetes-sigs:master Aug 12, 2021
@LochanRn LochanRn deleted the aks-aad branch August 21, 2022 06:06
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/XL Denotes a PR that changes 500-999 lines, ignoring generated files.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add AAD Support for AKS
4 participants