Skip to content

[AKS] aks-preview: add --enable/--disable-control-plane-metrics#9855

Open
davidkydd wants to merge 1 commit intoAzure:mainfrom
davidkydd:dakydd/ccpmetricsga-20260202preview
Open

[AKS] aks-preview: add --enable/--disable-control-plane-metrics#9855
davidkydd wants to merge 1 commit intoAzure:mainfrom
davidkydd:dakydd/ccpmetricsga-20260202preview

Conversation

@davidkydd
Copy link
Copy Markdown

Surface the new first-class API property
azureMonitorProfile.metrics.controlPlane.enabled (API version 2026-02-02-preview) so users can opt in/out of Azure Monitor managed Prometheus control plane metrics (kube-apiserver, etcd, etc.) without relying on the AFEC-gated preview.

  • Add --enable-control-plane-metrics on az aks create and az aks update, plus --disable-control-plane-metrics on az aks update.
  • Validate that --enable-control-plane-metrics requires Azure Monitor metrics to be enabled (either already on the cluster or via --enable-azure-monitor-metrics in the same command), and that enable and disable cannot be combined.
  • Wire the flags into the create (set_up_azure_monitor_profile) and update (update_azure_monitor_profile) decorator paths.
  • Bump extension to 20.0.0b7 and add HISTORY entry.

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

Related command

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.

Surface the new first-class API property
azureMonitorProfile.metrics.controlPlane.enabled (API version
2026-02-02-preview) so users can opt in/out of Azure Monitor managed
Prometheus control plane metrics (kube-apiserver, etcd, etc.) without
relying on the AFEC-gated preview.

- Add --enable-control-plane-metrics on `az aks create` and `az aks
  update`, plus --disable-control-plane-metrics on `az aks update`.
- Validate that --enable-control-plane-metrics requires Azure Monitor
  metrics to be enabled (either already on the cluster or via
  --enable-azure-monitor-metrics in the same command), and that enable
  and disable cannot be combined.
- Wire the flags into the create (set_up_azure_monitor_profile) and
  update (update_azure_monitor_profile) decorator paths.
- Bump extension to 20.0.0b7 and add HISTORY entry.
Copilot AI review requested due to automatic review settings May 7, 2026 08:29
@davidkydd davidkydd requested a review from FumingZhang as a code owner May 7, 2026 08:29
@azure-client-tools-bot-prd
Copy link
Copy Markdown

Validation for Breaking Change Starting...

Thanks for your contribution!

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented May 7, 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>

@yonzhan
Copy link
Copy Markdown
Collaborator

yonzhan commented May 7, 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 May 7, 2026

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 updates the aks-preview extension to surface the new azureMonitorProfile.metrics.controlPlane.enabled API property (2026-02-02-preview) by adding CLI flags to enable/disable Azure Monitor managed Prometheus control plane metrics collection for AKS clusters.

Changes:

  • Added --enable-control-plane-metrics to az aks create / az aks update, and --disable-control-plane-metrics to az aks update.
  • Implemented decorator-context validation and wiring to set azure_monitor_profile.metrics.control_plane.enabled during create/update.
  • Bumped extension version to 20.0.0b7 and added release notes entry.

Reviewed changes

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

Show a summary per file
File Description
src/aks-preview/setup.py Bumps extension version to 20.0.0b7.
src/aks-preview/HISTORY.rst Adds release notes entry for the new flags.
src/aks-preview/azext_aks_preview/managed_cluster_decorator.py Adds new context getters/validation and wires control plane metrics into create/update Azure Monitor profile flows.
src/aks-preview/azext_aks_preview/custom.py Adds new parameters to aks_create / aks_update function signatures so they flow into raw parameters.
src/aks-preview/azext_aks_preview/_params.py Registers the new CLI arguments for aks create and aks update.
src/aks-preview/azext_aks_preview/_help.py Documents the new CLI flags in command help.

Comment on lines +4719 to +4724
# Enable control plane metrics if requested.
if self.context.get_enable_control_plane_metrics():
mc.azure_monitor_profile.metrics.control_plane = (
self.models.ManagedClusterAzureMonitorProfileMetricsControlPlane(enabled=True)
)

Comment on lines +2642 to +2656
if enable_control_plane_metrics:
# Must have Azure Monitor metrics enabled (either already or in this command).
already_enabled = (
self.mc and
self.mc.azure_monitor_profile and
self.mc.azure_monitor_profile.metrics and
self.mc.azure_monitor_profile.metrics.enabled
)
enabling_now = self._get_enable_azure_monitor_metrics(False)
if not already_enabled and not enabling_now:
raise RequiredArgumentMissingError(
"--enable-control-plane-metrics requires Azure Monitor metrics to be enabled. "
"Specify --enable-azure-monitor-metrics or run on a cluster that already has "
"Azure Monitor metrics enabled."
)
Comment on lines +7011 to +7033
# Handle enable / disable of control plane metrics independently of the parent metrics flag,
# so users can toggle control plane metrics on a cluster that already has metrics enabled.
if self.context.get_enable_control_plane_metrics():
if mc.azure_monitor_profile is None:
mc.azure_monitor_profile = self.models.ManagedClusterAzureMonitorProfile() # pylint: disable=no-member
if mc.azure_monitor_profile.metrics is None:
# Should not normally happen — validation requires metrics to be enabled — but guard
# against partially-populated profiles to avoid AttributeError.
mc.azure_monitor_profile.metrics = (
self.models.ManagedClusterAzureMonitorProfileMetrics(enabled=True) # pylint: disable=no-member
)
mc.azure_monitor_profile.metrics.control_plane = (
self.models.ManagedClusterAzureMonitorProfileMetricsControlPlane(enabled=True) # pylint: disable=no-member
)

if self.context.get_disable_control_plane_metrics():
if (
mc.azure_monitor_profile and
mc.azure_monitor_profile.metrics
):
mc.azure_monitor_profile.metrics.control_plane = (
self.models.ManagedClusterAzureMonitorProfileMetricsControlPlane(enabled=False) # pylint: disable=no-member
)
short-summary: Enable Azure Monitor Metrics Profile
- name: --enable-control-plane-metrics
type: bool
short-summary: Enable collection of Azure Monitor managed Prometheus control plane metrics for managed cluster components (kube-apiserver, etcd, etc). Requires --enable-azure-monitor-metrics. See aka.ms/aks/controlplane-metrics.
short-summary: Enable Azure Monitor Metrics Profile
- name: --enable-control-plane-metrics
type: bool
short-summary: Enable collection of Azure Monitor managed Prometheus control plane metrics for managed cluster components (kube-apiserver, etcd, etc). Requires --enable-azure-monitor-metrics. See aka.ms/aks/controlplane-metrics.
Comment on lines 14 to +18
* Update the minimum required cli core version to `2.76.0` (actually since `20.0.0b3`).
* `az aks upgrade`: Add `--k8s-support-plan` and `--tier` flag support to allow cluster support plan and tier configuration during cluster upgrade.

20.0.0b7
++++++
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.

5 participants