Skip to content

{AKS} aks-preview: align KMS PMK/CMK with 2026-07-02-preview API - #10472

Merged
JaysonTaiMicrosoft merged 1 commit into
Azure:mainfrom
bingosummer:binxi/k2p-refinement
Nov 5, 2026
Merged

JaysonTaiMicrosoft merged 1 commit into
Azure:mainfrom
bingosummer:binxi/k2p-refinement

Conversation

@bingosummer

@bingosummer Bin Xia (bingosummer) commented Oct 14, 2026 •

Copy link
Copy Markdown
Member

🤖 PR Validation — ⚠️ Review suggested

Breaking Changes Suppressions
⚠️ None ️✔️ None
⚠️Azure CLI Extensions Breaking Change Test
⚠️aks-preview
rule cmd_name rule_message suggest_message
⚠️ 1009 - ParaPropRemove aks create cmd aks create update parameter kms_infrastructure_encryption: removed property default=Disabled
⚠️ 1010 - ParaPropUpdate aks create cmd aks create update parameter kms_infrastructure_encryption: updated property choices from ['Disabled', 'Enabled'] to ['Enabled']
⚠️ 1010 - ParaPropUpdate aks update cmd aks update update parameter kms_infrastructure_encryption: updated property choices from ['Disabled', 'Enabled'] to ['Enabled']

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

Related command

az aks create / az aks update (--kms-infrastructure-encryption, --azure-keyvault-kms-key-id)

Description

API version 2026-07-02-preview changed the KMS PMK/CMK contract:

  1. InfrastructureEncryption was extracted into its own definition, and both its Disabled enum value and its default: "Disabled" were removed. Encryption at rest of Kubernetes resource objects using service-managed keys (PMK) can only be turned on — it cannot be turned off once enabled. The same profile also graduated to the stable 2026-07-01 API.
  2. AzureKeyVaultKms.keyId has unchanged schema but new documented semantics: an unversioned key identifier selects the new KMS experience with automatic key version rotation, while a versioned key identifier selects the legacy KMS experience.

This PR aligns the extension with that contract:

  • --kms-infrastructure-encryption now only accepts Enabled, and no longer defaults to Disabled on create. Previously Disabled was accepted on the command line and then silently dropped, so users could believe they had turned PMK off. It now fails fast with an explanatory error.
  • A warning is emitted when a versioned --azure-keyvault-kms-key-id is supplied, since it opts the cluster into the legacy KMS experience.
  • The help for az aks create/update documents the versioned vs unversioned key ID behavior and the irreversibility of PMK.

Note: the vendored SDK already targets 2026-07-02-preview and its InfrastructureEncryption enum already contains only ENABLED, so no SDK regeneration is required.

Tests

  • azext_aks_preview/tests/latest/test_managed_cluster_decorator.py: updated the cases that assumed the old Disabled contract, added assertions that an explicit Disabled now raises InvalidArgumentValueError.

  • azext_aks_preview/tests/latest/test_aks_commands.py: added test_aks_update_kms_cmk_versioned_to_versionless_key_id (with recording), which:

    1. Creates a CMK cluster with a versioned key ID and PMK explicitly Disabled (public Key Vault, no keyVaultResourceId). The create goes through az rest on 2026-06-02-preview, because newer API versions enable PMK by default and the service then rejects versioned key IDs (KeyId must not include a version when PMK is enabled).
    2. Asserts the cluster is Succeeded, KMS enabled with the versioned key, and PMK not enabled.
    3. Updates to the versionless key ID with --azure-keyvault-kms-key-vault-resource-id and --kms-infrastructure-encryption Enabled (the service rejects a versionless key while PMK is disabled: Bad number of segments: 3 (PMK disabled, expected 4)).
    4. Asserts KMS uses the versionless key and PMK is Enabled.

    The cluster identity is granted Key Vault Reader on the vault before create, since the new KMS experience reads the vault by resource ID and a role assignment made just before the update had not propagated in time.

Validation performed:

Command Result
python -m pytest azext_aks_preview/tests/latest/test_managed_cluster_decorator.py azext_aks_preview/tests/latest/test_validators.py -q passed (624 passed, 10 subtests passed)
azdev style aks-preview passed (pylint PASSED, flake8 PASSED)
python scripts/ci/test_index.py -q passed (9 tests, OK, 2 skipped)
AZURE_TEST_RUN_LIVE=true pytest src/aks-preview/azext_aks_preview/tests/latest/test_aks_commands.py -k test_aks_update_kms_cmk_versioned_to_versionless_key_id (live, eastus2euap) passed (1 passed in 920.79s)

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 azdev 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.

Copilot AI balanced review requested due to automatic review settings October 14, 2026 03:39
@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
There may be pipelines that require an authorized user to comment /azp run to run.

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

🟡 Changes recommended

CMK-only public-network updates can reintroduce a vault resource ID that the API contract requires to be empty.

2 open findings
What changed in this PR

Aligns AKS preview KMS options with the 2026-07-02-preview API contract.

Changes:

  • Restricts infrastructure encryption to Enabled.
  • Documents and warns about versioned KMS key IDs.
  • Updates KMS handling and related tests.
File Description
HISTORY.rst Records KMS contract changes.
test_managed_cluster_decorator.py Updates PMK/CMK unit tests.
test_aks_commands.py Adds a live key-ID migration scenario.
managed_cluster_decorator.py Updates PMK/CMK profile handling.
custom.py Removes the create-time disabled default.
_validators.py Warns for versioned key IDs.
_params.py Restricts accepted PMK values.
_help.py Documents KMS semantics and irreversibility.
_consts.py Adds the enabled-value constant.

🧠 Review effort: Balanced


💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@x-engineering-agent

Copy link
Copy Markdown

Hi Bin Xia (@bingosummer),
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 pyproject.toml (or setup.py, if the extension has not migrated yet) as well.

@yonzhan

Copy link
Copy Markdown
Collaborator

Please fix CI issues

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@FumingZhang

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@lzhecheng Zhecheng Li (lzhecheng) left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

FumingZhang
FumingZhang previously approved these changes Oct 19, 2026
@JaysonTaiMicrosoft

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@JaysonTaiMicrosoft

Copy link
Copy Markdown
Contributor

Bin Xia (@bingosummer)

  1. Please sync the branch with main to fix the CI issues
  2. The PR description describes the following

The newly added test_aks_update_kms_cmk_versioned_to_versionless_key_id scenario test was not executed, as it is @live_only() and requires an Azure subscription; it was verified to collect successfully.

Can we get a confirmation that the live_only test has been run successfully?

@JaysonTaiMicrosoft

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@a0x1ab

Copy link
Copy Markdown
Member

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@bingosummer

Copy link
Copy Markdown
Member Author

JaysonTaiMicrosoft

  1. Rebased onto latest main and squashed (head 9adc0e666). The only remaining CI failure is test_aks_approuting_enable_with_keyvault_secrets_provider_addon_and_keyvault_id, which is unrelated to this PR: [Key Vault] az keyvault create: Support new Managed HSM SKUs Standard_B1v2, Standard_B5v2, Standard_B10v2, Standard_B15v2, Standard_B20v2 azure-cli#34234 bumped the Key Vault mgmt API to 2026-05-15, but that test's recording still has 2026-02-01, so playback fails on every aks-preview PR.
  2. Yes, the test has now been run live and it passes:
$ AZURE_TEST_RUN_LIVE=true pytest -v -p no:cacheprovider src/aks-preview/azext_aks_preview/tests/latest/test_aks_commands.py -k test_aks_update_kms_cmk_versioned_to_versionless_key_id
platform linux -- Python 3.12.3, pytest-8.4.2, pluggy-1.6.0
collecting ... collected 394 items / 393 deselected / 1 selected
src/aks-preview/azext_aks_preview/tests/latest/test_aks_commands.py::AzureKubernetesServiceScenarioTest::test_aks_update_kms_cmk_versioned_to_versionless_key_id PASSED [100%]
================ 1 passed, 393 deselected in 920.79s (0:15:20) =================

Getting it to pass live required fixing the test to match the service's actual behavior:

  • Create (on 2026-06-02-preview via az rest) explicitly sets PMK Disabled, because the service rejects a versioned key ID while PMK is enabled. A public Key Vault must not send keyVaultResourceId.
  • Update to the versionless key must enable PMK in the same call, because the service rejects a versionless key while PMK is disabled (Bad number of segments: 3 (PMK disabled, expected 4)). Assertions check PMK state after both create and update.
  • The cluster identity is granted Key Vault Reader before create, so the role assignment has propagated by the time the update reads the vault.

Correction to the description: the test is not @live_only(). The recording is committed, so it replays in CI.

API version 2026-07-02-preview removes "Disabled" from
InfrastructureEncryption: encryption at rest of Kubernetes resource objects
using service-managed keys (PMK) can only be turned on. It also gives the
Azure Key Vault KMS (CMK) key ID new semantics: an unversioned key ID
selects the new KMS experience with automatic key version rotation, while a
versioned key ID selects the legacy experience.

- `--kms-infrastructure-encryption` only accepts "Enabled" and no longer
  defaults to "Disabled" on `az aks create`. Passing any other value raises
  InvalidArgumentValueError.
- Warn when a versioned `--azure-keyvault-kms-key-id` is provided, since it
  selects the legacy KMS experience.
- Document versioned vs unversioned key ID behavior in the help of
  `az aks create/update`, and update HISTORY.rst.
- Update unit tests to expect the rejection of "Disabled".
- Add live test test_aks_update_kms_cmk_versioned_to_versionless_key_id
  (with recording): create a legacy-KMS cluster with a versioned key and
  PMK disabled (via `az rest` on 2026-06-02-preview, since newer API
  versions enable PMK by default and reject versioned keys), then switch
  to an unversioned key with PMK enabled, asserting the PMK state after
  each step.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
Copilot-Session: 6d4f7646-8d74-4894-9245-50b685bb447a
@bingosummer

Copy link
Copy Markdown
Member Author

/azp run

@azure-pipelines

Copy link
Copy Markdown
Commenter does not have sufficient privileges for PR 10472 in repo Azure/azure-cli-extensions

@JaysonTaiMicrosoft

Copy link
Copy Markdown
Contributor

/azp run

@azure-pipelines

Copy link
Copy Markdown
Azure Pipelines:
Successfully started running 2 pipeline(s).

@JaysonTaiMicrosoft
JaysonTaiMicrosoft merged commit 991c47d into Azure:main Nov 5, 2026
24 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

10 participants