-
Notifications
You must be signed in to change notification settings - Fork 21
Add StaticIPAllocation in Subnet spec #1119
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
f44b798
to
c08592a
Compare
Please change "subnet" to "Subnet" in the commit message and description. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
VKS has a requirement to not allocate IP for SubentPort, we plan to add StaticIPAllocation in Subnet CRD, so all ports would not get IP if StaticIPAllocation is false for DHCP_Deactivated Subnet. |
d6a2f6a
to
299a782
Compare
done |
299a782
to
210249c
Compare
I see. In NSX API, if StaticIPAllocation is false on a Subnet, a SubnetPort cannot request IP allocation from NSX IPAM? @dantingl |
Yes. For the NSX API behavior for the IP allocation request, I ever posted the verification results in the design doc, if the StaticIPAllocation is disabled, all port creation request with allocate_addresses= |
30b937e
to
9e57c2d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Codecov ReportAll modified and coverable lines are covered by tests ✅
Additional details and impacted files@@ Coverage Diff @@
## main #1119 +/- ##
==========================================
+ Coverage 73.03% 73.05% +0.01%
==========================================
Files 137 137
Lines 21668 21680 +12
==========================================
+ Hits 15826 15838 +12
Misses 4847 4847
Partials 995 995
🚀 New features to boost your workflow:
|
9e57c2d
to
951d094
Compare
951d094
to
2dba326
Compare
235a30e
to
40249da
Compare
fe75170
to
7c7c8a0
Compare
/e2e |
3b42e36
to
f963a6c
Compare
f963a6c
to
eec6a32
Compare
250a41b
to
142a4e1
Compare
@@ -168,6 +169,12 @@ func (r *SubnetReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr | |||
subnetCR.Spec.IPv4SubnetSize = vpcNetworkConfig.Spec.DefaultSubnetSize | |||
specChanged = true | |||
} | |||
|
|||
if subnetCR.Spec.AdvancedConfig.StaticIPAllocation.Enabled == nil { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do we need to check whether subnetCR.Spec.AdvancedConfig is nil or not?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't need because its data structure is not a pointer. In the other word, if I change this line to if subnetCR.Spec.AdvancedConfig != nil && subnetCR.Spec.AdvancedConfig.StaticIPAllocation.Enabled == nil {
, the golang will report error invalid operation: subnetCR.Spec.AdvancedConfig != nil (mismatched types "github.com/vmware-tanzu/nsx-operator/pkg/apis/vpc/v1alpha1".SubnetAdvancedConfig and untyped nil)
And the test cases 3 and 4 already covered the case that AdvancedConfig is not set.
The NSX operator will allow the customer to specify the property subnetAdvancedConfig.staticIpAllocation.enabled for VPC Subnet in the Subnet CR. If staticIPAllocation is not set explicitly in the Subnet CR, the static IP pool allocation will be automatically enabled when the DHCP mode is DHCPDeactivated or not set and disabled when the DHCP mode is DHCPServer or DHCPRelay. The NSX operator will update the spec.subnetAdvancedConfig.staticIpAllocation.enabled with true of false. The static IP pool allocation and DHCP mode cannot both be enabled simultaneously in Subnet. Testing done: 1. create Subnet with the following spec, the NSX Subnet can be created with subnet_dhcp_config.mode=DHCP_DEACTIVATED and advanced_config.static_ip_allocation.enabled=false. ``` spec: accessMode: Private advancedConfig: staticIPAllocation: enabled: false ``` 2. create Subnet with the following spec, the NSX Subnet can be created with subnet_dhcp_config.mode=DHCP_DEACTIVATED and advanced_config.static_ip_allocation.enabled=true. ``` spec: accessMode: Private advancedConfig: staticIPAllocation: enabled: true ``` 3. create Subnet with the following spec, the NSX Subnet can be created with .subnet_dhcp_config.mode=DHCP_SERVER and static_ip_allocation.enabled=false. ``` spec: accessMode: Private subnetDHCPConfig: mode: DHCPServer ``` check the Subnet CR, its spec is updated to ``` spec: accessMode: Private advancedConfig: connectivityState: Connected enableVLANExtension: false staticIPAllocation: enabled: false ipv4SubnetSize: 32 subnetDHCPConfig: mode: DHCPServer vpcName: Project Quality:ns-sunq-01_76261cd3-26a7-4e96-97d5-3886c66f0fa1 ``` 4. create Subnet with the following spec, the NSX Subnet can be created with subnet_dhcp_config.mode=DHCP_DEACTIVATED and static_ip_allocation.enabled=true. ``` spec: accessMode: Private ``` check the Subnet CR, its spec is updated to ``` spec: accessMode: Private advancedConfig: connectivityState: Connected enableVLANExtension: false staticIPAllocation: enabled: true ipv4SubnetSize: 32 subnetDHCPConfig: {} vpcName: Project Quality:ns-sunq-01_76261cd3-26a7-4e96-97d5-3886c66f0fa1 ``` 5. create Subnet with the following spec ``` spec: accessMode: Private advancedConfig: staticIPAllocation: enabled: true subnetDHCPConfig: mode: DHCPServer ``` the kubectl reports the following error: The Subnet "subnet-debug-05" is invalid: spec: Invalid value: "object": Static IP pool allocation and Subnet DHCP configuration cannot both be enabled simultaneously in Subnet
142a4e1
to
ea62c01
Compare
The NSX operator will allow the customer to specify the property
subnetAdvancedConfig.staticIpAllocation.enabled for VPC Subnet in the Subnet CR.
If staticIPAllocation is not set explicitly in the Subnet CR, the static
IP pool allocation will be automatically enabled when the DHCP mode is DHCPDeactivated
or not set and disabled when the DHCP mode is DHCPServer or DHCPRelay. The NSX operator
will update the spec.subnetAdvancedConfig.staticIpAllocation.enabled with true of false.
The static IP pool allocation and DHCP mode cannot both be enabled simultaneously
in Subnet.
Testing done:
subnet_dhcp_config.mode=DHCP_DEACTIVATED and advanced_config.static_ip_allocation.enabled=false.
subnet_dhcp_config.mode=DHCP_DEACTIVATED and advanced_config.static_ip_allocation.enabled=true.
.subnet_dhcp_config.mode=DHCP_SERVER and static_ip_allocation.enabled=false.
check the Subnet CR, its spec is updated to
subnet_dhcp_config.mode=DHCP_DEACTIVATED and static_ip_allocation.enabled=true.
check the Subnet CR, its spec is updated to
the kubectl reports the following error:
The Subnet "subnet-debug-05" is invalid: spec: Invalid value: "object": Static IP pool allocation and Subnet DHCP configuration cannot both be enabled simultaneously in Subnet