-
Notifications
You must be signed in to change notification settings - Fork 3.3k
[AKS] az aks get-credentials: Convert device code mode kubeconfig to Azure CLI token format to bypass conditional access login blocks
#32167
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
Conversation
️✔️AzureCLI-FullTest
|
|
Hi @FumingZhang, |
️✔️AzureCLI-BreakingChangeTest
|
|
The git hooks are available for azure-cli and azure-cli-extensions repos. They could help you run required checks before creating the PR. Please sync the latest code with latest dev branch (for azure-cli) or main branch (for azure-cli-extensions). pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>
|
|
Thank you for your contribution! We will review the pull request and get back to you soon. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR enhances the az aks get-credentials command to automatically convert kubeconfig files that use device code authentication to Azure CLI token format, helping users bypass conditional access login blocks.
- Adds automatic detection of kubeconfig files requiring kubelogin with device code authentication
- Implements automatic conversion using
kubelogin convert-kubeconfig -l azurecliwhen kubelogin is available - Provides helpful guidance when kubelogin is not installed
- Adds test coverage for the get-credentials functionality
Reviewed Changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| src/azure-cli/azure/cli/command_modules/acs/custom.py | Adds kubeconfig conversion logic and helper function to detect device code authentication |
| src/azure-cli/azure/cli/command_modules/acs/tests/latest/test_aks_commands.py | Adds basic test for get-credentials command functionality |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
|
Queued live test to validate the change, test passed!
|
mbifeld
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Related command
az aks get-credentialsDescription
If the returned kubeconfig uses the exec format and requires the kubelogin command to run in device code mode, the command would run
kubelogin convert-kubeconfig -l azureclifor the user. This updates the kubeconfig, allowing the user to access cluster resources directly with the azure-cli token, without needing to log in again as it may be blocked by the conditional access token protection policy.The following demonstrates the expected behavior: dev001 is a standard cluster, so its kubeconfig will not be converted. dev100 is a managed AAD-enabled cluster. Its kubeconfig will be automatically converted if kubelogin is present in the path. If kubelogin is not present, the user will be prompted to install kubelogin and attempt to manually execute the conversion command if blocked by device code login.
Testing Guide
History Notes
[Component Name 1] BREAKING CHANGE:
az command a: Make some customer-facing breaking change[Component Name 2]
az command b: Add some customer-facing featureThis checklist is used to make sure that common guidelines for a pull request are followed.
The PR title and description has followed the guideline in Submitting Pull Requests.
I adhere to the Command Guidelines.
I adhere to the Error Handling Guidelines.