Skip to content

Commit

Permalink
Refactor subnet subnetset CRD
Browse files Browse the repository at this point in the history
1.Remove subnet CRD unused DHCP options since these fields are not
used, so not expose to uesers.
2.Add gatewayAddress and DHCPServerAddress into the subnet CRD status
field, also adding them in subnet field of subnetset CRD.
  • Loading branch information
timdengyun committed Jun 19, 2024
1 parent b7bf875 commit a7bc26f
Show file tree
Hide file tree
Showing 8 changed files with 82 additions and 94 deletions.
32 changes: 8 additions & 24 deletions build/yaml/crd/nsx.vmware.com_subnets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,6 @@ spec:
DHCPConfig:
description: DHCPConfig DHCP configuration.
properties:
dhcpRelayConfigPath:
description: DHCPRelayConfigPath is policy path of DHCP-relay-config.
type: string
dhcpV4PoolSize:
default: 80
description: DHCPV4PoolSize IPs in % to be reserved for DHCP ranges.
By default, 80% of IPv4 IPs will be reserved for DHCP. Configure
0 if no pool is required.
maximum: 100
minimum: 0
type: integer
dhcpV6PoolSize:
default: 2000
description: DHCPV6PoolSize number of IPs to be reserved for DHCP
ranges. By default, 2000 IPv6 IPs will be reserved for DHCP.
type: integer
dnsClientConfig:
description: DNSClientConfig holds DNS configurations.
properties:
dnsServersIPs:
items:
type: string
type: array
type: object
enableDHCP:
default: false
type: boolean
Expand Down Expand Up @@ -116,6 +92,10 @@ spec:
status:
description: SubnetStatus defines the observed state of Subnet.
properties:
DHCPServerAddress:
items:
type: string
type: array
conditions:
items:
description: Condition defines condition of custom resource.
Expand Down Expand Up @@ -144,6 +124,10 @@ spec:
- type
type: object
type: array
gatewayAddress:
items:
type: string
type: array
ipAddresses:
items:
type: string
Expand Down
34 changes: 10 additions & 24 deletions build/yaml/crd/nsx.vmware.com_subnetsets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,30 +51,6 @@ spec:
DHCPConfig:
description: DHCPConfig DHCP configuration.
properties:
dhcpRelayConfigPath:
description: DHCPRelayConfigPath is policy path of DHCP-relay-config.
type: string
dhcpV4PoolSize:
default: 80
description: DHCPV4PoolSize IPs in % to be reserved for DHCP ranges.
By default, 80% of IPv4 IPs will be reserved for DHCP. Configure
0 if no pool is required.
maximum: 100
minimum: 0
type: integer
dhcpV6PoolSize:
default: 2000
description: DHCPV6PoolSize number of IPs to be reserved for DHCP
ranges. By default, 2000 IPv6 IPs will be reserved for DHCP.
type: integer
dnsClientConfig:
description: DNSClientConfig holds DNS configurations.
properties:
dnsServersIPs:
items:
type: string
type: array
type: object
enableDHCP:
default: false
type: boolean
Expand Down Expand Up @@ -142,13 +118,23 @@ spec:
description: SubnetInfo defines the observed state of a single Subnet
of a SubnetSet.
properties:
DHCPServerAddress:
items:
type: string
type: array
gatewayAddress:
items:
type: string
type: array
ipAddresses:
items:
type: string
type: array
nsxResourcePath:
type: string
required:
- DHCPServerAddress
- gatewayAddress
- ipAddresses
- nsxResourcePath
type: object
Expand Down
22 changes: 5 additions & 17 deletions pkg/apis/nsx.vmware.com/v1alpha1/subnet_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ type SubnetSpec struct {

// SubnetStatus defines the observed state of Subnet.
type SubnetStatus struct {
NSXResourcePath string `json:"nsxResourcePath,omitempty"`
IPAddresses []string `json:"ipAddresses,omitempty"`
Conditions []Condition `json:"conditions,omitempty"`
NSXResourcePath string `json:"nsxResourcePath,omitempty"`
IPAddresses []string `json:"ipAddresses,omitempty"`
GatewayAddress []string `json:"gatewayAddress,omitempty"`
DHCPServerAddress []string `json:"DHCPServerAddress,omitempty"`
Conditions []Condition `json:"conditions,omitempty"`
}

// +genclient
Expand Down Expand Up @@ -78,20 +80,6 @@ type StaticIPAllocation struct {
type DHCPConfig struct {
// +kubebuilder:default:=false
EnableDHCP bool `json:"enableDHCP,omitempty"`
// DHCPRelayConfigPath is policy path of DHCP-relay-config.
DHCPRelayConfigPath string `json:"dhcpRelayConfigPath,omitempty"`
// DHCPV4PoolSize IPs in % to be reserved for DHCP ranges.
// By default, 80% of IPv4 IPs will be reserved for DHCP.
// Configure 0 if no pool is required.
// +kubebuilder:default:=80
// +kubebuilder:validation:Maximum:=100
// +kubebuilder:validation:Minimum:=0
DHCPV4PoolSize int `json:"dhcpV4PoolSize,omitempty"`
// DHCPV6PoolSize number of IPs to be reserved for DHCP ranges.
// By default, 2000 IPv6 IPs will be reserved for DHCP.
// +kubebuilder:default:=2000
DHCPV6PoolSize int `json:"dhcpV6PoolSize,omitempty"`
DNSClientConfig DNSClientConfig `json:"dnsClientConfig,omitempty"`
}

// DNSClientConfig holds DNS configurations.
Expand Down
6 changes: 4 additions & 2 deletions pkg/apis/nsx.vmware.com/v1alpha1/subnetset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ type SubnetSetSpec struct {

// SubnetInfo defines the observed state of a single Subnet of a SubnetSet.
type SubnetInfo struct {
NSXResourcePath string `json:"nsxResourcePath"`
IPAddresses []string `json:"ipAddresses"`
NSXResourcePath string `json:"nsxResourcePath"`
IPAddresses []string `json:"ipAddresses"`
GatewayAddress []string `json:"gatewayAddress"`
DHCPServerAddress []string `json:"DHCPServerAddress"`
}

// SubnetSetStatus defines the observed state of SubnetSet.
Expand Down
27 changes: 23 additions & 4 deletions pkg/apis/nsx.vmware.com/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

22 changes: 5 additions & 17 deletions pkg/apis/v1alpha1/subnet_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,11 @@ type SubnetSpec struct {

// SubnetStatus defines the observed state of Subnet.
type SubnetStatus struct {
NSXResourcePath string `json:"nsxResourcePath,omitempty"`
IPAddresses []string `json:"ipAddresses,omitempty"`
Conditions []Condition `json:"conditions,omitempty"`
NSXResourcePath string `json:"nsxResourcePath,omitempty"`
IPAddresses []string `json:"ipAddresses,omitempty"`
GatewayAddress []string `json:"gatewayAddress,omitempty"`
DHCPServerAddress []string `json:"DHCPServerAddress,omitempty"`
Conditions []Condition `json:"conditions,omitempty"`
}

// +genclient
Expand Down Expand Up @@ -78,20 +80,6 @@ type StaticIPAllocation struct {
type DHCPConfig struct {
// +kubebuilder:default:=false
EnableDHCP bool `json:"enableDHCP,omitempty"`
// DHCPRelayConfigPath is policy path of DHCP-relay-config.
DHCPRelayConfigPath string `json:"dhcpRelayConfigPath,omitempty"`
// DHCPV4PoolSize IPs in % to be reserved for DHCP ranges.
// By default, 80% of IPv4 IPs will be reserved for DHCP.
// Configure 0 if no pool is required.
// +kubebuilder:default:=80
// +kubebuilder:validation:Maximum:=100
// +kubebuilder:validation:Minimum:=0
DHCPV4PoolSize int `json:"dhcpV4PoolSize,omitempty"`
// DHCPV6PoolSize number of IPs to be reserved for DHCP ranges.
// By default, 2000 IPv6 IPs will be reserved for DHCP.
// +kubebuilder:default:=2000
DHCPV6PoolSize int `json:"dhcpV6PoolSize,omitempty"`
DNSClientConfig DNSClientConfig `json:"dnsClientConfig,omitempty"`
}

// DNSClientConfig holds DNS configurations.
Expand Down
6 changes: 4 additions & 2 deletions pkg/apis/v1alpha1/subnetset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@ type SubnetSetSpec struct {

// SubnetInfo defines the observed state of a single Subnet of a SubnetSet.
type SubnetInfo struct {
NSXResourcePath string `json:"nsxResourcePath"`
IPAddresses []string `json:"ipAddresses"`
NSXResourcePath string `json:"nsxResourcePath"`
IPAddresses []string `json:"ipAddresses"`
GatewayAddress []string `json:"gatewayAddress"`
DHCPServerAddress []string `json:"DHCPServerAddress"`
}

// SubnetSetStatus defines the observed state of SubnetSet.
Expand Down
27 changes: 23 additions & 4 deletions pkg/apis/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit a7bc26f

Please sign in to comment.