Skip to content

Support IPv6 for Subnet/SubnetSet #1437

Open
yanjunz97 wants to merge 2 commits into
vmware-tanzu:mainfrom
yanjunz97:subnet-ipv6
Open

Support IPv6 for Subnet/SubnetSet #1437
yanjunz97 wants to merge 2 commits into
vmware-tanzu:mainfrom
yanjunz97:subnet-ipv6

Conversation

@yanjunz97
Copy link
Copy Markdown
Contributor

This PR focus on the happy path for IPv6 support on Subnet/SubnetSet.
It covers the following topics

  • Supports IPv6 and daul stack Subnet CR
  • Supports shared Subnet with IPv6 or dual stack
  • Supports auto-scaled IPv6 and dual stack SubnetSet CR
  • Supports pre-created SubnetSet with IPv6 or/and dual stack Subnets
  • Supports auto-scaled default SubnetSet for Pod/VM in IPv6/Dual stack supervisor

Testing done:
IPv6 Subnet is not fully support at NSX side so the testing done only covers some simple cases.

Add IPv6 blocks to vpcconnectivityprofile and mock sv ipfamily to DualStack
Created ns-3 and observed the default SubnetSet are IPv4IPv6

kubectl get subnetset -n ns-3        
NAME          ACCESSMODE   IPADDRESSTYPE   IPV4SUBNETSIZE   IPV6PREFIXLENGTH   NETWORKADDRESSES
pod-default   PrivateTGW   IPv4IPv6        32               64                 
vm-default    Private      IPv4IPv6        32               64                 

Create a IPv6 Subnet

apiVersion: crd.nsx.vmware.com/v1alpha1
kind: Subnet
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"crd.nsx.vmware.com/v1alpha1","kind":"Subnet","metadata":{"annotations":{},"name":"subnet-2","namespace":"ns-3"},"spec":{"advancedConfig":{"staticIPAllocation":{"enabled":false}},"ipAddressType":"IPv6"}}
  creationTimestamp: "2026-05-18T05:58:46Z"
  generation: 2
  name: subnet-2
  namespace: ns-3
  resourceVersion: "2986477"
  uid: c0ce19bc-da4d-49aa-9d59-53405ef0c1c7
spec:
  advancedConfig:
    connectivityState: Connected
    staticIPAllocation:
      enabled: false
  ipAddressType: IPv6
  ipv6PrefixLength: 64
  subnetDHCPConfig:
    dhcpServerAdditionalConfig: {}
  subnetDHCPv6Config:
    dhcpv6ServerAdditionalConfig: {}
  vpcName: project-quality:ns-3_ax2p2
status:
  conditions:
  - lastTransitionTime: "2026-05-18T05:58:47Z"
    message: 'NSX Subnet with DHCPv6: DHCPDeactivated has been successfully created/updated'
    reason: SubnetReady
    status: "True"
    type: Ready
  gatewayAddresses:
  - 2001:db8:0:0:0:0:0:1/64
  networkAddresses:
  - 2001:db8::/64
  shared: false
  vlanExtension: {}

Create a dual stack Subnet

apiVersion: crd.nsx.vmware.com/v1alpha1
kind: Subnet
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"crd.nsx.vmware.com/v1alpha1","kind":"Subnet","metadata":{"annotations":{},"name":"subnet-4","namespace":"ns-3"},"spec":{"advancedConfig":{"staticIPAllocation":{"enabled":false}},"ipAddressType":"IPv4IPv6","subnetDHCPConfig":{"mode":"DHCPServer"},"subnetDHCPv6Config":{"mode":"DHCPServer"}}}
  creationTimestamp: "2026-05-18T05:58:47Z"
  generation: 2
  name: subnet-4
  namespace: ns-3
  resourceVersion: "2986506"
  uid: e4a3b692-9e3a-45e0-8f1f-7b6db9b32e69
spec:
  accessMode: Private
  advancedConfig:
    connectivityState: Connected
    staticIPAllocation:
      enabled: false
  ipAddressType: IPv4IPv6
  ipv4SubnetSize: 32
  ipv6PrefixLength: 64
  subnetDHCPConfig:
    dhcpServerAdditionalConfig: {}
    mode: DHCPServer
  subnetDHCPv6Config:
    dhcpv6ServerAdditionalConfig: {}
    mode: DHCPServer
  vpcName: project-quality:ns-3_ax2p2
status:
  DHCPServerAddresses:
  - 172.26.0.34/27 <—— NSX API still has bug to show multiple addresses in status
  conditions:
  - lastTransitionTime: "2026-05-18T05:58:50Z"
    message: 'NSX Subnet with DHCPv4: DHCPServer, DHCPv6: DHCPServer has been successfully
      created/updated'
    reason: SubnetReady
    status: "True"
    type: Ready
  gatewayAddresses:
  - 172.26.0.33/27
  networkAddresses:
  - 172.26.0.32/27
  shared: false
  vlanExtension: {}

Create a subnet in nsx and shared through vpcenetworkconfiguration

kubectl get subnet -n ns-3 -o yaml test
apiVersion: crd.nsx.vmware.com/v1alpha1
kind: Subnet
metadata:
  annotations:
    nsx.vmware.com/associated-resource: project-quality:ns-1_1dkmu:test
  creationTimestamp: "2026-05-18T08:48:49Z"
  generation: 1
  name: test
  namespace: ns-3
  resourceVersion: "3084001"
  uid: 3ebbc94b-7f61-44ee-89be-7d817f2d497f
spec:
  accessMode: Private
  advancedConfig:
    connectivityState: Connected
    dhcpServerAddresses:
    - 2001:db8:0:4:0:0:0:2/64
    gatewayAddresses:
    - 2001:db8:0:4::1/64
    staticIPAllocation:
      enabled: false
  ipAddressType: IPv6
  ipAddresses:
  - 2001:db8:0:4::/64
  ipv6PrefixLength: 64
  subnetDHCPConfig:
    dhcpServerAdditionalConfig: {}
    mode: DHCPDeactivated
  subnetDHCPv6Config:
    dhcpv6ServerAdditionalConfig: {}
    mode: DHCPServer
  vpcName: project-quality:ns-1_1dkmu
status:

Create a pre-created SubnetSet with IPv6 subnet and IPv4IPv6 Subnet

apiVersion: crd.nsx.vmware.com/v1alpha1
kind: SubnetSet
metadata:
  annotations:
    kubectl.kubernetes.io/last-applied-configuration: |
      {"apiVersion":"crd.nsx.vmware.com/v1alpha1","kind":"SubnetSet","metadata":{"annotations":{},"name":"subnetset-2","namespace":"ns-3"},"spec":{"subnetNames":["subnet-2","subnet-4"]}}
  creationTimestamp: "2026-05-18T07:34:19Z"
  generation: 5
  name: subnetset-2
  namespace: ns-3
  resourceVersion: "3056260"
  uid: cdeb5ed7-0392-49f1-acbc-e297e7ecb1ed
spec:
  ipAddressType: IPv6
  subnetDHCPConfig:
    dhcpServerAdditionalConfig: {}
  subnetDHCPv6Config:
    dhcpv6ServerAdditionalConfig: {}
  subnetNames:
  - subnet-2
  - subnet-4
status:
  conditions:
  - lastTransitionTime: "2026-05-18T07:34:19Z"
    message: SubnetSet CR has been successfully created/updated
    reason: SubnetSetReady
    status: "True"
    type: Ready
  subnets:
  - gatewayAddresses:
    - 2001:db8:0:0:0:0:0:1/64
    networkAddresses:
    - 2001:db8::/64
  - DHCPServerAddresses:
    - 172.26.0.34/27
    gatewayAddresses:
    - 172.26.0.33/27
    networkAddresses:
    - 172.26.0.32/27

wenqiq and others added 2 commits May 15, 2026 19:12
Signed-off-by: Wenqi Qiu <wenqi.qiu@broadcom.com>
Signed-off-by: Yanjun Zhou <yanjun.zhou@broadcom.com>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 77.53165% with 71 lines in your changes missing coverage. Please review.
✅ Project coverage is 76.98%. Comparing base (ff79596) to head (a5dfbbb).

Files with missing lines Patch % Lines
pkg/controllers/subnet/subnet_controller.go 42.42% 16 Missing and 3 partials ⚠️
pkg/controllers/subnetset/subnetset_controller.go 57.14% 9 Missing and 3 partials ⚠️
pkg/nsx/services/subnet/subnet.go 74.35% 7 Missing and 3 partials ⚠️
pkg/util/ip.go 40.00% 8 Missing and 1 partial ⚠️
.../controllers/networkinfo/networkinfo_controller.go 84.61% 6 Missing and 2 partials ⚠️
pkg/nsx/services/subnet/builder.go 89.58% 3 Missing and 2 partials ⚠️
pkg/nsx/services/subnet/compare.go 78.57% 2 Missing and 1 partial ⚠️
pkg/config/config.go 80.00% 2 Missing ⚠️
pkg/controllers/common/utils.go 95.23% 1 Missing and 1 partial ⚠️
pkg/controllers/namespace/namespace_controller.go 91.66% 0 Missing and 1 partial ⚠️
Additional details and impacted files

Impacted file tree graph

@@            Coverage Diff             @@
##             main    #1437      +/-   ##
==========================================
- Coverage   77.02%   76.98%   -0.05%     
==========================================
  Files         156      156              
  Lines       22048    22281     +233     
==========================================
+ Hits        16983    17153     +170     
- Misses       3859     3908      +49     
- Partials     1206     1220      +14     
Flag Coverage Δ
unit-tests 76.98% <77.53%> (-0.05%) ⬇️
Files with missing lines Coverage Δ
pkg/controllers/networkinfo/subnetset_handler.go 50.00% <100.00%> (-5.89%) ⬇️
pkg/controllers/subnetset/subnetset_webhook.go 78.26% <100.00%> (-0.11%) ⬇️
pkg/nsx/util/utils.go 88.17% <100.00%> (+0.15%) ⬆️
pkg/controllers/namespace/namespace_controller.go 72.24% <91.66%> (+0.54%) ⬆️
pkg/config/config.go 72.60% <80.00%> (+0.33%) ⬆️
pkg/controllers/common/utils.go 85.78% <95.23%> (+1.08%) ⬆️
pkg/nsx/services/subnet/compare.go 86.48% <78.57%> (-5.83%) ⬇️
pkg/nsx/services/subnet/builder.go 90.13% <89.58%> (-1.61%) ⬇️
.../controllers/networkinfo/networkinfo_controller.go 72.27% <84.61%> (+1.60%) ⬆️
pkg/util/ip.go 80.51% <40.00%> (-4.38%) ⬇️
... and 3 more
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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.

3 participants