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

Disable local accounts for aks aad clusters #4008

Conversation

LochanRn
Copy link
Member

@LochanRn LochanRn commented Sep 18, 2023

What type of PR is this?
/kind feature

What this PR does / why we need it:
Support to disable local accounts for aks aad 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 #2129

Special notes for your reviewer:

As access for admin kubeconfig will be disabled, the user must ensure to add the service principle to the admin group configured for enabling AAD.

  • cherry-pick candidate

TODOs:

  • squashed commits
  • includes documentation
  • adds unit tests

Release note:

Support disabling of local accounts for AKS clusters with Azure Active Directory enabled. Disables the back door to get admin kubeconfig for AAD based clusters. The user must ensure to add the service principle to admin groups in azure AAD for capz to be able to deploy the target cluster..

@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. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Sep 18, 2023
@LochanRn LochanRn force-pushed the support-for-disabling-local-accounts branch from 6405e5a to ba6b705 Compare September 19, 2023 04:35
@codecov
Copy link

codecov bot commented Sep 19, 2023

Codecov Report

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

Comparison is base (b9430aa) 57.61% compared to head (1841617) 57.65%.
Report is 26 commits behind head on main.

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #4008      +/-   ##
==========================================
+ Coverage   57.61%   57.65%   +0.03%     
==========================================
  Files         188      188              
  Lines       19200    19320     +120     
==========================================
+ Hits        11062    11138      +76     
- Misses       7507     7550      +43     
- Partials      631      632       +1     
Files Coverage Δ
api/v1beta1/azuremanagedcontrolplane_types.go 20.00% <ø> (ø)
api/v1beta1/azuremanagedcontrolplane_webhook.go 89.67% <100.00%> (+0.59%) ⬆️
azure/scope/managedcontrolplane.go 25.97% <65.21%> (+3.30%) ⬆️
azure/services/managedclusters/spec.go 52.95% <0.00%> (-0.99%) ⬇️
azure/services/managedclusters/client.go 0.00% <0.00%> (ø)
controllers/azuremanagedcontrolplane_reconciler.go 33.68% <0.00%> (-1.10%) ⬇️
azure/services/managedclusters/managedclusters.go 55.00% <28.00%> (-20.35%) ⬇️

... and 4 files with indirect coverage changes

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

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.

Nice work! Just some small changes

azure/scope/managedcontrolplane.go Outdated Show resolved Hide resolved
azure/scope/managedcontrolplane.go Outdated Show resolved Hide resolved
azure/services/managedclusters/managedclusters.go Outdated Show resolved Hide resolved
azure/services/managedclusters/spec.go Outdated Show resolved Hide resolved
api/v1beta1/azuremanagedcontrolplane_types.go Outdated Show resolved Hide resolved
api/v1beta1/azuremanagedcontrolplane_types.go Show resolved Hide resolved
@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 19, 2023
@LochanRn LochanRn force-pushed the support-for-disabling-local-accounts branch 2 times, most recently from ba887fb to 800b3ea Compare September 20, 2023 03:46
@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 20, 2023
@LochanRn LochanRn force-pushed the support-for-disabling-local-accounts branch 2 times, most recently from 5cf2542 to b7b2ef1 Compare October 3, 2023 20:50
@LochanRn
Copy link
Member Author

LochanRn commented Oct 4, 2023

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

1 similar comment
@LochanRn
Copy link
Member Author

LochanRn commented Oct 4, 2023

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

@k8s-ci-robot k8s-ci-robot added the needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. label Oct 5, 2023
@LochanRn LochanRn force-pushed the support-for-disabling-local-accounts branch from b7b2ef1 to 023875d Compare October 6, 2023 09:58
@k8s-ci-robot k8s-ci-robot added size/XXL Denotes a PR that changes 1000+ lines, ignoring generated files. and removed needs-rebase Indicates a PR cannot be merged because it has merge conflicts with HEAD. size/XL Denotes a PR that changes 500-999 lines, ignoring generated files. labels Oct 6, 2023
@LochanRn LochanRn force-pushed the support-for-disabling-local-accounts branch 2 times, most recently from 12f51a5 to 0abf40e Compare October 6, 2023 18:16
@willie-yao
Copy link
Contributor

PR looks good pending the unit test for ReconcileKubeconfig! Although I don't think it would be blocking the PR for merge.

/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 9, 2023
@LochanRn LochanRn force-pushed the support-for-disabling-local-accounts branch from 71e6f25 to 670e1b2 Compare October 10, 2023 18:31
@Jont828
Copy link
Contributor

Jont828 commented Oct 10, 2023

LGTM aside from pending comments and once tests pass. Great work so far!

@LochanRn
Copy link
Member Author

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

@LochanRn LochanRn force-pushed the support-for-disabling-local-accounts branch 3 times, most recently from 1f8f84c to d94010e Compare October 11, 2023 14:42
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

Thank you @LochanRn!

@nojnhuh FYI this PR might be disruptive for both #4052 and #4069 but it's worth merging as-is and rebasing the two big PRs on top since it's a feature that's been asked for for a while

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

LGTM label has been added.

Git tree hash: 519a076c6a9c1a104262a5bd495484b0403633ca

@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 Oct 11, 2023
@LochanRn LochanRn force-pushed the support-for-disabling-local-accounts branch from d94010e to 951e829 Compare October 11, 2023 15:36
@k8s-ci-robot k8s-ci-robot removed the lgtm "Looks good to me", indicates that a PR is ready to be merged. label Oct 11, 2023
@LochanRn
Copy link
Member Author

@CecileRobertMichon PTAL i added docs !

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.

minor nits

docs/book/src/topics/managedcluster.md Outdated Show resolved Hide resolved
docs/book/src/topics/managedcluster.md Outdated Show resolved Hide resolved
docs/book/src/topics/managedcluster.md Outdated Show resolved Hide resolved
docs/book/src/topics/managedcluster.md Outdated Show resolved Hide resolved
@LochanRn LochanRn force-pushed the support-for-disabling-local-accounts branch from 951e829 to 1841617 Compare October 11, 2023 16:14
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

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

LGTM label has been added.

Git tree hash: c66bb0f3835c52b003dd275b21c18b5be312144b

@k8s-ci-robot k8s-ci-robot merged commit 7fc4734 into kubernetes-sigs:main Oct 11, 2023
11 checks passed
@k8s-ci-robot k8s-ci-robot added this to the v1.12 milestone Oct 11, 2023
Comment on lines +168 to +170
If we disable local accounts for aad clusters we do not have access to admin kubeconfig, hence we need to create
the admin kubeconfig by authenticating with the user credentials and retrieving the token for kubeconfig.
The token is used to create the admin kubeconfig.
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 comment correct or should it be referring to the user kubeconfig instead of the admin one?

Copy link
Member Author

Choose a reason for hiding this comment

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

This comment is correct, if we refer to the user kubeconfig we will need kubelogin to access the cluster.

nojnhuh added a commit to nojnhuh/cluster-api-provider-azure that referenced this pull request Oct 14, 2023
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. 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.

Support disableLocalAccounts for AKS clusters
6 participants