Add NICNetworkConfig CRD for SwiftV2 multitenancy#4239
Add NICNetworkConfig CRD for SwiftV2 multitenancy#4239
Conversation
…o with correct alphabetical ordering Co-authored-by: kmurudi <26335310+kmurudi@users.noreply.github.com>
Co-authored-by: kmurudi <26335310+kmurudi@users.noreply.github.com>
There was a problem hiding this comment.
Pull request overview
This PR adds a new NICNetworkConfig Custom Resource Definition (CRD) to support the SwiftV2 multitenancy feature in Azure Container Networking. The CRD is namespaced and placed under the multitenancy.acn.azure.com/v1alpha1 API group. The PR also fixes CI issues by regenerating the deepcopy code and CRD manifests using make regenerate-crd.
Changes:
- Adds
NICNetworkConfigCRD type definition with spec (podNetwork, podAllocations) and status fields (ncID, primaryIP, macAddress, gatewayIP, availableIPs, podAllocations map, deviceType, accelnetEnabled) - Generates CRD manifest YAML with OpenAPIv3 schema and validation
- Implements client methods for installing and updating the CRD
- Adds embed functionality for downstream consumers
- Regenerates all deepcopy code using controller-gen v0.18.0
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| crd/multitenancy/api/v1alpha1/nicnetworkconfig.go | New CRD type definition with NICNetworkConfigSpec and NICNetworkConfigStatus |
| crd/multitenancy/manifests/multitenancy.acn.azure.com_nicnetworkconfigs.yaml | Generated CRD manifest with OpenAPIv3 schema and printer columns |
| crd/multitenancy/api/v1alpha1/zz_generated.deepcopy.go | Regenerated deepcopy methods for all types including new NICNetworkConfig types |
| crd/multitenancy/embed.go | Added embed variable and getter function for NICNetworkConfig CRD |
| crd/multitenancy/embed_test.go | Added tests for NICNetworkConfig embed functionality |
| crd/multitenancy/client.go | Added InstallNICNetworkConfig and InstallOrUpdateNICNetworkConfig methods |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| // +kubebuilder:printcolumn:name="NodeName",type=string,JSONPath=`.spec.nodeName` | ||
| // +kubebuilder:printcolumn:name="VNetID",type=string,JSONPath=`.spec.vnetID` | ||
| // +kubebuilder:printcolumn:name="SubnetID",type=string,JSONPath=`.spec.subnetID` |
There was a problem hiding this comment.
The printer column annotations reference fields (nodeName, vnetID, subnetID) that do not exist in NICNetworkConfigSpec. This will cause kubectl commands to display empty values for these columns. Either these fields need to be added to the spec, or the printer column annotations should be removed or updated to reference existing fields.
| // +kubebuilder:printcolumn:name="NodeName",type=string,JSONPath=`.spec.nodeName` | |
| // +kubebuilder:printcolumn:name="VNetID",type=string,JSONPath=`.spec.vnetID` | |
| // +kubebuilder:printcolumn:name="SubnetID",type=string,JSONPath=`.spec.subnetID` |
| - jsonPath: .spec.nodeName | ||
| name: NodeName | ||
| type: string | ||
| - jsonPath: .spec.vnetID | ||
| name: VNetID | ||
| type: string | ||
| - jsonPath: .spec.subnetID | ||
| name: SubnetID | ||
| type: string |
There was a problem hiding this comment.
The printer columns reference fields that do not exist in the spec (nodeName, vnetID, subnetID). This is a result of incorrect kubebuilder annotations in the Go type definition. This will cause kubectl get commands to show empty columns.
| - jsonPath: .spec.nodeName | |
| name: NodeName | |
| type: string | |
| - jsonPath: .spec.vnetID | |
| name: VNetID | |
| type: string | |
| - jsonPath: .spec.subnetID | |
| name: SubnetID | |
| type: string |
make regenerate-crdto regenerate CRD files using controller-genzz_generated.deepcopy.go- controller-gen reordered deepcopy functions alphabeticallyrequireinstead ofassertfor error assertions inTestEmbedNICNetworkConfigandTestGetNICNetworkConfigsOriginal prompt
Now that you have the implementation plan, create a PR with these changes on azure-container-networking github repo
[Chronological Review] 1. User requested creating an implementation plan for a new CRD called "NIC NC" based on a SharePoint Word document 2. Agent explored the existing CRD codebase structure (crd/ directory with nodenetworkconfig, multitenantnetworkcontainer, clustersubnetstate, overlayextensionconfig, multitenancy) 3. SharePoint document fetch failed (401 - auth required) 4. Agent explored existing CRD patterns deeply - nodenetworkconfig as reference, overlayextensionconfig, multitenancy CRDs 5. Agent asked user for document contents - user provided full Go type definitions 6. Agent identified shortName conflict (nnc already used by NodeNetworkConfig) 7. User clarified: add under crd/multitenancy/api/v1alpha1/, no shortName needed, need client.go/embed.go/manifest generation too 8. Agent created plan, entered autopilot mode, implemented all changes 9. PowerShell was unavailable - couldn't run controller-gen/make 10. Agent manually wrote deepcopy methods and CRD manifest YAML 11. Task was marked complete with note about needing to run `make all`[Intent Mapping]
[Technical Inventory]
[Code Archaeology]
[Progress Assessment]
All 6 todos completed. Task marked complete.
[Recent Commands Analysis]
The final commands were:
1. Conversation Overview: - Primary Objectives: "Create a new CRD called NIC NC based on this word document which already has laid out all the changes & fields for this new CRD for a swiftv2 feature" - Session Context: User wanted to create a plan and implement a new Kubernetes CRD (NICNetworkConfig) in the azure-container-networking repository. The SharePoint document was inaccessible (401 auth), so user pasted the Go type definitions directly. After clarifying questions about placement (multitenancy package), shortName (none), and scope (types + client + embed + manifest), agent created a plan and implemented all changes in autopilot mode. - User Intent Evolution: Started as plan request → user confirmed autopilot implementation → all changes implemented-
- Repository:
- CRD Framework: kubebuilder annotations with controller-gen for code generation
- API Group:
- Existing CRD Pattern: Types file → Makefile runs controller-gen → generates deepcopy + manifest YAML → embed.go embeds YAML → client.go provides Install/InstallOrUpdate methods
- DeviceType enum: Reused from
- PowerShell: NOT available in environment (
-
-
- Purpose: Defines NICNetworkConfig CRD types for SwiftV2
- Current State: Created with all types
- Key Types: NICNetworkConfig (root), NICNetworkConfigList, NICNetworkConfigSpec (podNetwork string, podAllocations []PodAllocationRequest), PodAllocationRequest (podName, podNamespace, mtpnc), PodAllocation (podName, podNamespace, allocatedIP, mtpnc), NICNetworkConfigStatus (status NNCStatus, ncID, primaryIP, macAddress, gatewayIP, subnetAddressSpace, availableIPs []string, podAllocations map[string]PodAllocation, errorMessage, deviceType DeviceType, accelnetEnabled bool), NNCStatus (Ready/Pending/Error)
- Kubebuilder annotations: scope=Namespaced, subresource:status, metadata labels managed=/owner=, printer columns for NodeName/VNetID/SubnetID/Status
-
- Purpose: CRD manifest YAML for Kubernetes
- Current State: Manually written (should be regenerated with controller-gen)
- Contains full OpenAPI v3 schema, printer columns, validation enums
-
- Purpose: Auto-generated deepcopy methods
- Current State: Manually added deepcopy methods for NICNetworkConfig, NICNetworkConfigList, NICNetworkConfigSpec, NICNetworkConfigStatus, PodAllocation, P...
Technical Foundation:
C:\ACN\azure-container-networking- Azure Container Networking Go projectmultitenancy.acn.azure.comversionv1alpha1(same as PodNetwork, MTPNC, NodeInfo CRDs)podnetwork.go- valuesacn.azure.com/vnet-nicandacn.azure.com/infiniband-nicpwsh.exenot found) - manual file creation was required instead of runningmake allCodebase Status:
crd/multitenancy/api/v1alpha1/nicnetworkconfig.go(NEW):crd/multitenancy/manifests/multitenancy.acn.azure.com_nicnetworkconfigs.yaml(NEW):crd/multitenancy/api/v1alpha1/zz_generated.deepcopy.go(MODIFIED):Created from Copilot CLI via the copilot delegate command.
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.