Add NICNetworkConfig CRD for SwiftV2 multitenancy#4239
Add NICNetworkConfig CRD for SwiftV2 multitenancy#4239
Conversation
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) - Changes
PrefixBlockAllocationSizefield toPrefixBlockCIDRLengthinPodNetworkCRD - see how size is used /28 not 16 to mention number of IPs - 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.
crd/multitenancy/manifests/multitenancy.acn.azure.com_nicnetworkconfigs.yaml
Show resolved
Hide resolved
| type NICNetworkConfigStatus struct { | ||
| // Status indicates the current status of the NIC Network Config | ||
| // +kubebuilder:validation:Enum=Ready;Pending;Error | ||
| Status NNCStatus `json:"status,omitempty"` |
There was a problem hiding this comment.
do we need to add a cooldownTime field now for NIC-NC status? if we decided on the deletion/cleanup path of NIC NC. @ravisraju @prmathur-microsoft
…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>
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com> Signed-off-by: Kshitija Murudi <kmurudi@microsoft.com>
d1cf31a to
b75f3a2
Compare
bde4205 to
b15850e
Compare
| // NodeName is the name of the node this NIC belongs to | ||
| NodeName string `json:"nodeName"` | ||
| // NICName is the name of the physical NIC on the node (e.g., eth1) | ||
| NICName string `json:"nicName"` |
There was a problem hiding this comment.
change to device-id or macaddress
CEL rules referencing self.status.prefixBlockCIDRLength fail with 'no such key: status' on newly created PodNetwork objects that have no status populated yet. Add !has(self.status) guard before accessing nested status fields. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
This reverts commit ad7745b.
… subnetallocationmode" This reverts commit b15850e.
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.