Skip to content

k8s-node-tagger: add azure cloud provider scaffold - #70

Merged
winmillwill merged 2 commits into
mainfrom
wm/azure-cloud-provider
Aug 21, 2026
Merged

k8s-node-tagger: add azure cloud provider scaffold#70
winmillwill merged 2 commits into
mainfrom
wm/azure-cloud-provider

Conversation

@winmillwill

@winmillwill winmillwill commented Jul 29, 2026

Copy link
Copy Markdown
Contributor

Context

The binary previously hard-rejected anything but aws/gcp. This PR adds a real Azure cloud provider.

What's implemented

Area Status
azure.go azureVMResource, parseAzureProviderID (standalone-VM + VMSS-instance IDs), azureComputeClient backed by armcompute/v8 (VirtualMachinesClient + VirtualMachineScaleSetVMsClient), newAzureComputeClient via azidentity.NewDefaultAzureCredential (workload-identity-friendly)
controller.go AzureComputeClient field, azure case in SetupCloudProvider, syncAzureTags mirroring syncGCPLabels (parse → fetch → merge preserving unmanaged tags → sanitize → skip-if-unchanged → replace)
main.go -cloud accepts azure; flag help updated
README.md azure documented as a supported -cloud value
controller_test.go mockAzureClient with TestReconcileAzure (7 cases), TestParseAzureProviderID (8 cases), sanitization tests
Azure SDK deps armcompute/v8 v8.2.0, azidentity v1.14.0, azcore v1.22.0

Design decisions (resolves the original open questions)

  1. Azure SDK package: armcompute/v8 (ARM API), mirroring how the AWS provider uses the EC2 SDK directly and GCP uses the compute API.
  2. Azure resource tagged: VM tags on Microsoft.Compute/virtualMachines (standalone) and Microsoft.Compute/virtualMachineScaleSets/<vmss>/virtualMachines/<instance> (VMSS, the AKS default). Tags are read from / written to the k8s node's spec.ProviderID.
  3. IMDS vs. ARM API: ARM API, authenticated with the ambient Azure credential (azidentity.NewDefaultAzureCredential, which honors workload identity when run in-cluster with a UAMI federated credential). parseAzureProviderID handles the azure:///subscriptions/<sub>/resourceGroups/<rg>/providers/Microsoft.Compute/... provider ID format that the AKS cloud provider emits.

Scaffold Azure cloud provider support modeled on the existing aws and gcp
providers, unblocking the ick azure provider overlay
(planetscale/infra-config-kubernetes#9519).

What's scaffolded (compiles, lint-clean, tests pass):
- azure.go: azureComputeClient interface + stub implementation, and a
  parseAzureProviderID stub.
- controller.go: AzureComputeClient field on NodeLabelController, an "azure"
  case in SetupCloudProvider that wires the stub client, and an "azure" case
  in Reconcile dispatching to syncAzureTags (implemented against the
  interface, so it will work once the stub is replaced with a real SDK
  client).
- main.go: accept "azure" in the -cloud validation and update the flag help
  text.
- README.md: document azure as a supported -cloud value.

What's TODO (left for the finishing agent):
- Choose the Azure SDK package (armcompute vs. instance metadata service)
  and implement azureComputeClient behind the interface.
- Implement parseAzureProviderID for the real Azure provider ID format.
- Confirm which Azure node attributes to tag and the RBAC the UAMI needs.

This is a stub: the azure provider is selectable end-to-end but every Azure
compute call returns "not yet implemented".
Replace the not-yet-implemented stub with a real azure provider modeled on
aws.go and gcp.go.

azure.go adds azureVMResource, parseAzureProviderID (handles standalone-VM and
VMSS-instance IDs), azureComputeClient using armcompute/v8
(VirtualMachinesClient and VirtualMachineScaleSetVMsClient), and
newAzureComputeClient via azidentity.NewDefaultAzureCredential
(workload-identity-friendly).

controller.go wires the azure case into SetupCloudProvider and implements
syncAzureTags mirroring syncGCPLabels: parse the node's provider ID, fetch the
current tags, merge while preserving unmanaged tags, sanitize keys/values,
skip the round-trip when nothing changed, and replace the full tag set
otherwise.

controller_test.go adds mockAzureClient with TestReconcileAzure (7 cases),
TestParseAzureProviderID (8 cases), and sanitization tests.

Deps: armcompute/v8 v8.2.0, azidentity v1.14.0, azcore v1.22.0.
@winmillwill
winmillwill marked this pull request as ready for review August 3, 2026 17:42
@winmillwill
winmillwill requested a review from a team as a code owner August 3, 2026 17:42
@winmillwill
winmillwill merged commit 0402409 into main Aug 21, 2026
6 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.

2 participants