[AKS] aks-preview: add --enable/--disable-control-plane-metrics#9855
[AKS] aks-preview: add --enable/--disable-control-plane-metrics#9855davidkydd wants to merge 1 commit intoAzure:mainfrom
Conversation
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.
|
Validation for Breaking Change Starting...
Thanks for your contribution! |
|
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.
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-metricstoaz aks create/az aks update, and--disable-control-plane-metricstoaz aks update. - Implemented decorator-context validation and wiring to set
azure_monitor_profile.metrics.control_plane.enabledduring create/update. - Bumped extension version to
20.0.0b7and 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. |
| # 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) | ||
| ) | ||
|
|
| 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." | ||
| ) |
| # 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. |
| * 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 | ||
| ++++++ |
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.
az aks createandaz aks update, plus --disable-control-plane-metrics onaz aks update.This checklist is used to make sure that common guidelines for a pull request are followed.
Related command
General Guidelines
azdev style <YOUR_EXT>locally? (pip install azdevrequired)python scripts/ci/test_index.py -qlocally? (pip install wheel==0.30.0required)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.jsonautomatically.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.