Skip to content

[AKS] az aks bastion: Add new option --kubeconfig-path to allow users to specify an existing kubeconfig file#9509

Merged
yanzhudd merged 9 commits intoAzure:mainfrom
FumingZhang:fuming/aks-bastion-0109
Jan 16, 2026
Merged

[AKS] az aks bastion: Add new option --kubeconfig-path to allow users to specify an existing kubeconfig file#9509
yanzhudd merged 9 commits intoAzure:mainfrom
FumingZhang:fuming/aks-bastion-0109

Conversation

@FumingZhang
Copy link
Copy Markdown
Member

@FumingZhang FumingZhang commented Jan 9, 2026


This checklist is used to make sure that common guidelines for a pull request are followed.

Related command

az aks bastion

When you specify a value for the new --kubeconfig-path option:

  • The command will notify the user that "The server URL for cluster 'xxx' in your kubeconfig has been updated to point to the bastion tunnel. Once the bastion tunnel is closed, this cluster configuration will stop working. To restore connectivity, rerun this command to automatically update the server URL and create a new tunnel."
    Screenshot 2026-01-09 154423

  • The command will fail if the provided kubeconfig does not have a cluster with a name that exactly matches the one specified in the command.
    Screenshot 2026-01-09 153535

If you do not specify the new option, the command will behave as before: it will download the kubeconfig to a temporary path, which will be deleted once the command exits.
Screenshot 2026-01-09 153641

General Guidelines

  • Have you run azdev style <YOUR_EXT> locally? (pip install azdev required)
  • Have you run python scripts/ci/test_index.py -q locally? (pip install wheel==0.30.0 required)
  • My extension version conforms to the Extension version schema

For new extensions:

About Extension Publish

There is a pipeline to automatically build, upload and publish extension wheels.
Once your pull request is merged into main branch, a new pull request will be created to update src/index.json automatically.
You only need to update the version information in file setup.py and historical information in file HISTORY.rst in your PR but do not modify src/index.json.

@azure-client-tools-bot-prd
Copy link
Copy Markdown

azure-client-tools-bot-prd bot commented Jan 9, 2026

⚠️Azure CLI Extensions Breaking Change Test
⚠️aks-preview
rule cmd_name rule_message suggest_message
⚠️ 1006 - ParaAdd aks bastion cmd aks bastion added parameter kubeconfig_path

@azure-client-tools-bot-prd
Copy link
Copy Markdown

Hi @FumingZhang,
Please write the description of changes which can be perceived by customers into HISTORY.rst.
If you want to release a new extension version, please update the version in setup.py as well.

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented Jan 9, 2026

Thank you for your contribution! We will review the pull request and get back to you soon.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 9, 2026

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).
After that please run the following commands to enable git hooks:

pip install azdev --upgrade
azdev setup -c <your azure-cli repo path> -r <your azure-cli-extensions repo path>

@FumingZhang
Copy link
Copy Markdown
Member Author

FumingZhang commented Jan 9, 2026

Queued live test to validate the change, test passed!

  • test_aks_bastion

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 9, 2026

CodeGen Tools Feedback Collection

Thank you for using our CodeGen tool. We value your feedback, and we would like to know how we can improve our product. Please take a few minutes to fill our codegen survey

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Jan 9, 2026

@yonzhan yonzhan removed the Network label Jan 9, 2026
@github-actions github-actions bot added the release-version-block Updates do not qualify release version rules. NOTE: please do not edit it manually. label Jan 15, 2026
@FumingZhang FumingZhang force-pushed the fuming/aks-bastion-0109 branch from 5796c46 to 4c3fcca Compare January 15, 2026 05:41
@github-actions github-actions bot removed the release-version-block Updates do not qualify release version rules. NOTE: please do not edit it manually. label Jan 15, 2026
@FumingZhang FumingZhang marked this pull request as ready for review January 15, 2026 06:11
Copilot AI review requested due to automatic review settings January 15, 2026 06:11
Copy link
Copy Markdown
Contributor

Copilot AI left a 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 adds a --kubeconfig-path option to the az aks bastion command, enabling users to specify an existing kubeconfig file instead of downloading credentials to a temporary location. When specified, the command modifies the existing kubeconfig to point to the bastion tunnel and warns users that the configuration will stop working once the tunnel is closed.

Changes:

  • Added --kubeconfig-path parameter to allow specifying an existing kubeconfig file
  • Enhanced kubeconfig modification logic to support both new and existing kubeconfig files with cluster name matching
  • Improved process cleanup for bastion tunnel to properly terminate child processes on both Windows and Unix systems
  • Fixed subnet address prefix in test to use Azure Bastion-compliant CIDR range

Reviewed changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
setup.py Version bumped to 19.0.0b20 for the new feature
HISTORY.rst Added release notes documenting the new --kubeconfig-path option
_params.py Registered the new kubeconfig_path parameter
_help.py Added documentation and examples for the new parameter
custom.py Modified aks_bastion function to handle existing kubeconfig files and improved cleanup logic
bastion.py Enhanced aks_bastion_set_kubeconfig with cluster name matching, improved process termination with new _aks_bastion_kill_process_tree helper
test_aks_commands.py Fixed subnet address prefix from /16 to /26 for Azure Bastion compliance

Comment thread src/aks-preview/azext_aks_preview/bastion/bastion.py
Comment thread src/aks-preview/azext_aks_preview/bastion/bastion.py
Comment thread src/aks-preview/azext_aks_preview/_help.py
Comment thread src/aks-preview/azext_aks_preview/custom.py Outdated
mbifeld
mbifeld previously approved these changes Jan 15, 2026
Copy link
Copy Markdown
Member

@mbifeld mbifeld left a comment

Choose a reason for hiding this comment

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

LGTM

Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@yanzhudd yanzhudd merged commit b3bb9fe into Azure:main Jan 16, 2026
24 checks passed
@azclibot
Copy link
Copy Markdown
Collaborator

[Release] Update index.json for extension [ aks-preview-19.0.0b20 ] : https://dev.azure.com/msazure/One/_build/results?buildId=149578247&view=results

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

AKS Auto-Assign Auto assign by bot

Projects

None yet

Development

Successfully merging this pull request may close these issues.

8 participants