Skip to content

Commit

Permalink
update NetworkConfiguration CR with new VPC API
Browse files Browse the repository at this point in the history
Signed-off-by: Wenqi Qiu <[email protected]>
  • Loading branch information
wenqiq committed Aug 7, 2024
1 parent 2cc0f8d commit 4a5f82b
Show file tree
Hide file tree
Showing 51 changed files with 450 additions and 518 deletions.
4 changes: 3 additions & 1 deletion build/yaml/crd/vpc/crd.nsx.vmware.com_ippools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -183,10 +183,12 @@ spec:
type: object
type: array
type:
description: Type defines the type of this IPPool, Public or Private.
description: Type defines the type of this IPPool, can be Public,
Private, PrivateTGW.
enum:
- Public
- Private
- PrivateTGW
type: string
type: object
status:
Expand Down
2 changes: 1 addition & 1 deletion build/yaml/crd/vpc/crd.nsx.vmware.com_networkinfos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ spec:
name:
description: VPC name.
type: string
privateIPv4CIDRs:
privateIPs:
description: Private CIDRs used for the VPC.
items:
type: string
Expand Down
2 changes: 2 additions & 0 deletions build/yaml/crd/vpc/crd.nsx.vmware.com_subnets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ spec:
type: boolean
type: object
accessMode:
default: Private
description: Access mode of Subnet, accessible only from within VPC
or from outside VPC.
enum:
- Private
- Public
- PrivateTGW
type: string
advancedConfig:
description: Subnet advanced configuration.
Expand Down
2 changes: 2 additions & 0 deletions build/yaml/crd/vpc/crd.nsx.vmware.com_subnetsets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -60,11 +60,13 @@ spec:
type: boolean
type: object
accessMode:
default: Private
description: Access mode of Subnet, accessible only from within VPC
or from outside VPC.
enum:
- Private
- Public
- PrivateTGW
type: string
advancedConfig:
description: Subnet advanced configuration.
Expand Down
61 changes: 23 additions & 38 deletions build/yaml/crd/vpc/crd.nsx.vmware.com_vpcnetworkconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,17 +15,13 @@ spec:
scope: Cluster
versions:
- additionalPrinterColumns:
- description: NSXTProject the Namespace associated with
jsonPath: .spec.nsxtProject
name: NSXTProject
- description: NSXProject the Namespace associated with
jsonPath: .spec.nsxProject
name: NSXProject
type: string
- description: ExternalIPv4Blocks assigned to the Namespace
jsonPath: .spec.externalIPv4Blocks
name: ExternalIPv4Blocks
type: string
- description: PrivateIPv4CIDRs assigned to the Namespace
jsonPath: .spec.privateIPv4CIDRs
name: PrivateIPv4CIDRs
- description: PrivateIPs assigned to the Namespace
jsonPath: .spec.privateIPs
name: PrivateIPs
type: string
name: v1alpha1
schema:
Expand Down Expand Up @@ -58,56 +54,45 @@ spec:
in a Namespace's VPCNetworkConfiguration, the Namespace will use the value
in the default VPCNetworkConfiguration.
properties:
defaultGatewayPath:
description: PolicyPath of Tier0 or Tier0 VRF gateway.
type: string
defaultIPv4SubnetSize:
defaultSubnetSize:
default: 32
description: |-
Default size of Subnet based upon estimated workload count.
Default size of Subnets.
Defaults to 32.
type: integer
defaultSubnetAccessMode:
nsxProject:
description: NSX Project the Namespace associated with.
type: string
podSubnetAccessMode:
description: |-
DefaultSubnetAccessMode defines the access mode of the default SubnetSet for PodVM and VM.
Must be Public or Private.
PodSubnetAccessMode defines the access mode of the default SubnetSet for PodVMs.
Must be Public, Private or PrivateTGW.
enum:
- Public
- Private
- PrivateTGW
type: string
edgeClusterPath:
description: Edge cluster path on which the networking elements will
be created.
type: string
externalIPv4Blocks:
description: NSX-T IPv4 Block paths used to allocate external Subnets.
privateIPs:
description: Private IPs.
items:
type: string
maxItems: 5
minItems: 0
type: array
nsxtProject:
description: NSX-T Project the Namespace associated with.
type: string
privateIPv4CIDRs:
description: Private IPv4 CIDRs used to allocate Private Subnets.
items:
type: string
maxItems: 5
minItems: 0
type: array
shortID:
description: |-
ShortID specifies Identifier to use when displaying VPC context in logs.
Less than or equal to 8 characters.
Less than equal to 8 characters.
maxLength: 8
type: string
vpc:
description: |-
NSX path of the VPC the Namespace associated with.
If vpc is set, only defaultIPv4SubnetSize and defaultSubnetAccessMode
If VPC is set, only defaultIPv4SubnetSize and defaultSubnetAccessMode
take effect, other fields are ignored.
type: string
vpcConnectivityProfile:
description: VPCConnectivityProfile ID. This profile has configuration
related to creating VPC transit gateway attachment.
type: string
type: object
status:
description: VPCNetworkConfigurationStatus defines the observed state
Expand Down
2 changes: 1 addition & 1 deletion build/yaml/samples/nsx_v1alpha1_networkinfo.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,6 @@ vpcs:
- defaultSNATIP: 192.168.0.0
loadBalancerIPAddresses: 172.26.0.0/26
name: vpc-d110d5aa-006d-4b59-9caf-424a4fba932c--kube-system
privateIPv4CIDRs:
privateIPs:
- 172.26.0.0/16
vpcPath: /orgs/default/projects/project-quality/vpcs/19a8a52e-beb0-4396-91ce-5821a15a43db
13 changes: 7 additions & 6 deletions build/yaml/samples/nsx_v1alpha1_vpcnetworkconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ metadata:
spec:
defaultGatewayPath: /infra/tier-0s/t0
edgeClusterPath: /infra/sites/default/enforcement-points/default/edge-clusters/2d9df59f-6dc6-4911-8865-21fadc23d4da
defaultIPv4SubnetSize: 32
nsxtProject: proj-1
defaultSubnetSize: 32
nsxProject: proj-1
externalIPv4Blocks:
- block1
privateIPv4CIDRs:
privateIPs:
- 172.26.0.0/16
- 172.36.0.0/16
defaultSubnetAccessMode: Private
podSubnetAccessMode: Private
---
# Sample to create VPCNetworkConfiguration CR using a pre-created NSX VPC.
apiVersion: crd.nsx.vmware.com/v1alpha1
Expand All @@ -21,5 +21,6 @@ metadata:
name: vpc-network-config-with-pre-created-vpc
spec:
vpc: /orgs/default/projects/proj-1/vpcs/vpc-1
defaultIPv4SubnetSize: 32
defaultSubnetAccessMode: Private
defaultSubnetSize: 32
podSubnetAccessMode: Private
vpcConnectivityProfile: /orgs/default/projects/wenqi-test/vpc-connectivity-profiles/default
8 changes: 4 additions & 4 deletions pkg/apis/crd.nsx.vmware.com/v1alpha1/networkinfo_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,8 @@ import (
)

// +genclient
//+kubebuilder:object:root=true
//+kubebuilder:storageversion
// +kubebuilder:object:root=true
// +kubebuilder:storageversion

// NetworkInfo is used to report the network information for a namespace.
// +kubebuilder:resource:path=networkinfos
Expand All @@ -20,7 +20,7 @@ type NetworkInfo struct {
VPCs []VPCState `json:"vpcs"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// NetworkInfoList contains a list of NetworkInfo.
type NetworkInfoList struct {
Expand All @@ -40,7 +40,7 @@ type VPCState struct {
// LoadBalancerIPAddresses (AVI SE Subnet CIDR or NSX LB SNAT IPs).
LoadBalancerIPAddresses string `json:"loadBalancerIPAddresses,omitempty"`
// Private CIDRs used for the VPC.
PrivateIPv4CIDRs []string `json:"privateIPv4CIDRs,omitempty"`
PrivateIPs []string `json:"privateIPs,omitempty"`
}

func init() {
Expand Down
10 changes: 5 additions & 5 deletions pkg/apis/crd.nsx.vmware.com/v1alpha1/subnet_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ type SubnetSpec struct {
// +kubebuilder:validation:Minimum:=16
IPv4SubnetSize int `json:"ipv4SubnetSize,omitempty"`
// Access mode of Subnet, accessible only from within VPC or from outside VPC.
// +kubebuilder:validation:Enum=Private;Public
// +kubebuilder:validation:Enum=Private;Public;PrivateTGW
AccessMode AccessMode `json:"accessMode,omitempty"`
// Subnet CIDRS.
// +kubebuilder:validation:MinItems=0
Expand All @@ -38,9 +38,9 @@ type SubnetStatus struct {
}

// +genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:storageversion
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion

// Subnet is the Schema for the subnets API.
// +kubebuilder:printcolumn:name="AccessMode",type=string,JSONPath=`.spec.accessMode`,description="Access mode of Subnet"
Expand All @@ -54,7 +54,7 @@ type Subnet struct {
Status SubnetStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// SubnetList contains a list of Subnet.
type SubnetList struct {
Expand Down
10 changes: 5 additions & 5 deletions pkg/apis/crd.nsx.vmware.com/v1alpha1/subnetset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ type SubnetSetSpec struct {
// +kubebuilder:validation:Minimum:=16
IPv4SubnetSize int `json:"ipv4SubnetSize,omitempty"`
// Access mode of Subnet, accessible only from within VPC or from outside VPC.
// +kubebuilder:validation:Enum=Private;Public
// +kubebuilder:validation:Enum=Private;Public;PrivateTGW
AccessMode AccessMode `json:"accessMode,omitempty"`
// Subnet advanced configuration.
AdvancedConfig AdvancedConfig `json:"advancedConfig,omitempty"`
Expand All @@ -37,9 +37,9 @@ type SubnetSetStatus struct {
}

// +genclient
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:storageversion
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion

// SubnetSet is the Schema for the subnetsets API.
// +kubebuilder:printcolumn:name="AccessMode",type=string,JSONPath=`.spec.accessMode`,description="Access mode of Subnet"
Expand All @@ -53,7 +53,7 @@ type SubnetSet struct {
Status SubnetSetStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// SubnetSetList contains a list of SubnetSet.
type SubnetSetList struct {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (
const (
AccessModePublic string = "Public"
AccessModePrivate string = "Private"
AccessModeProject string = "PrivateTGW"
)

// VPCNetworkConfigurationSpec defines the desired state of VPCNetworkConfiguration.
Expand All @@ -19,38 +20,36 @@ const (
// in a Namespace's VPCNetworkConfiguration, the Namespace will use the value
// in the default VPCNetworkConfiguration.
type VPCNetworkConfigurationSpec struct {
// PolicyPath of Tier0 or Tier0 VRF gateway.
DefaultGatewayPath string `json:"defaultGatewayPath,omitempty"`
// Edge cluster path on which the networking elements will be created.
EdgeClusterPath string `json:"edgeClusterPath,omitempty"`
// NSX-T Project the Namespace associated with.
NSXTProject string `json:"nsxtProject,omitempty"`
// NSX-T IPv4 Block paths used to allocate external Subnets.
// +kubebuilder:validation:MinItems=0
// +kubebuilder:validation:MaxItems=5
ExternalIPv4Blocks []string `json:"externalIPv4Blocks,omitempty"`
// Private IPv4 CIDRs used to allocate Private Subnets.
// +kubebuilder:validation:MinItems=0
// +kubebuilder:validation:MaxItems=5
PrivateIPv4CIDRs []string `json:"privateIPv4CIDRs,omitempty"`
// Default size of Subnet based upon estimated workload count.
// Defaults to 32.
// +kubebuilder:default=32
DefaultIPv4SubnetSize int `json:"defaultIPv4SubnetSize,omitempty"`
// DefaultSubnetAccessMode defines the access mode of the default SubnetSet for PodVM and VM.
// Must be Public or Private.
// +kubebuilder:validation:Enum=Public;Private
DefaultSubnetAccessMode string `json:"defaultSubnetAccessMode,omitempty"`
// ShortID specifies Identifier to use when displaying VPC context in logs.
// Less than or equal to 8 characters.
// +kubebuilder:validation:MaxLength=8
// +optional
ShortID string `json:"shortID,omitempty"`
// NSX path of the VPC the Namespace associated with.
// If vpc is set, only defaultIPv4SubnetSize and defaultSubnetAccessMode
// If VPC is set, only defaultIPv4SubnetSize and defaultSubnetAccessMode
// take effect, other fields are ignored.
// +optional
VPC string `json:"vpc,omitempty"`

// NSX Project the Namespace associated with.
NSXProject string `json:"nsxProject,omitempty"`

// VPCConnectivityProfile ID. This profile has configuration related to creating VPC transit gateway attachment.
VPCConnectivityProfile string `json:"vpcConnectivityProfile,omitempty"`

// Private IPs.
PrivateIPs []string `json:"privateIPs,omitempty"`

// ShortID specifies Identifier to use when displaying VPC context in logs.
// Less than equal to 8 characters.
// +kubebuilder:validation:MaxLength=8
// +optional
ShortID string `json:"shortID,omitempty"`

// Default size of Subnets.
// Defaults to 32.
// +kubebuilder:default=32
DefaultSubnetSize int `json:"defaultSubnetSize,omitempty"`

// PodSubnetAccessMode defines the access mode of the default SubnetSet for PodVMs.
// Must be Public, Private or PrivateTGW.
// +kubebuilder:validation:Enum=Public;Private;PrivateTGW
PodSubnetAccessMode string `json:"podSubnetAccessMode,omitempty"`
}

// VPCNetworkConfigurationStatus defines the observed state of VPCNetworkConfiguration
Expand All @@ -71,15 +70,14 @@ type VPCInfo struct {

// +genclient
// +genclient:nonNamespaced
//+kubebuilder:object:root=true
//+kubebuilder:subresource:status
//+kubebuilder:storageversion
// +kubebuilder:object:root=true
// +kubebuilder:subresource:status
// +kubebuilder:storageversion

// VPCNetworkConfiguration is the Schema for the vpcnetworkconfigurations API.
// +kubebuilder:resource:scope="Cluster"
// +kubebuilder:printcolumn:name="NSXTProject",type=string,JSONPath=`.spec.nsxtProject`,description="NSXTProject the Namespace associated with"
// +kubebuilder:printcolumn:name="ExternalIPv4Blocks",type=string,JSONPath=`.spec.externalIPv4Blocks`,description="ExternalIPv4Blocks assigned to the Namespace"
// +kubebuilder:printcolumn:name="PrivateIPv4CIDRs",type=string,JSONPath=`.spec.privateIPv4CIDRs`,description="PrivateIPv4CIDRs assigned to the Namespace"
// +kubebuilder:printcolumn:name="NSXProject",type=string,JSONPath=`.spec.nsxProject`,description="NSXProject the Namespace associated with"
// +kubebuilder:printcolumn:name="PrivateIPs",type=string,JSONPath=`.spec.privateIPs`,description="PrivateIPs assigned to the Namespace"
type VPCNetworkConfiguration struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`
Expand All @@ -88,7 +86,7 @@ type VPCNetworkConfiguration struct {
Status VPCNetworkConfigurationStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true
// +kubebuilder:object:root=true

// VPCNetworkConfigurationList contains a list of VPCNetworkConfiguration.
type VPCNetworkConfigurationList struct {
Expand Down
Loading

0 comments on commit 4a5f82b

Please sign in to comment.