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 Jul 4, 2024
1 parent 4bc8285 commit 487b211
Show file tree
Hide file tree
Showing 36 changed files with 462 additions and 483 deletions.
28 changes: 12 additions & 16 deletions build/yaml/crd/nsx.vmware.com_ipaddressallocations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,8 @@ apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.14.0
controller-gen.kubebuilder.io/version: v0.11.0
creationTimestamp: null
name: ipaddressallocations.nsx.vmware.com
spec:
group: nsx.vmware.com
Expand All @@ -29,19 +30,14 @@ spec:
description: IPAddressAllocation is the Schema for the IP allocation API.
properties:
apiVersion:
description: |-
APIVersion defines the versioned schema of this representation of an object.
Servers should convert recognized schemas to the latest internal value, and
may reject unrecognized values.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources
description: 'APIVersion defines the versioned schema of this representation
of an object. Servers should convert recognized schemas to the latest
internal value, and may reject unrecognized values. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#resources'
type: string
kind:
description: |-
Kind is a string value representing the REST resource this object represents.
Servers may infer this from the endpoint the client submits requests to.
Cannot be updated.
In CamelCase.
More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds
description: 'Kind is a string value representing the REST resource this
object represents. Servers may infer this from the endpoint the client
submits requests to. Cannot be updated. In CamelCase. More info: https://git.k8s.io/community/contributors/devel/sig-architecture/api-conventions.md#types-kinds'
type: string
metadata:
type: object
Expand Down Expand Up @@ -73,10 +69,10 @@ spec:
description: Condition defines condition of custom resource.
properties:
lastTransitionTime:
description: |-
Last time the condition transitioned from one status to another.
This should be when the underlying condition changed. If that is not known, then using the time when
the API field changed is acceptable.
description: Last time the condition transitioned from one status
to another. This should be when the underlying condition changed.
If that is not known, then using the time when the API field
changed is acceptable.
format: date-time
type: string
message:
Expand Down
4 changes: 3 additions & 1 deletion build/yaml/crd/nsx.vmware.com_ippools.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -172,10 +172,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, Public, Private
or Project.
enum:
- Public
- Private
- Project
type: string
type: object
status:
Expand Down
2 changes: 1 addition & 1 deletion build/yaml/crd/nsx.vmware.com_networkinfos.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,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/nsx.vmware.com_subnets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,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
- Project
type: string
advancedConfig:
description: Subnet advanced configuration.
Expand Down
2 changes: 2 additions & 0 deletions build/yaml/crd/nsx.vmware.com_subnetsets.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,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
- Project
type: string
advancedConfig:
description: Subnet advanced configuration.
Expand Down
52 changes: 24 additions & 28 deletions build/yaml/crd/nsx.vmware.com_vpcnetworkconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,9 +24,9 @@ spec:
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 All @@ -53,47 +53,43 @@ spec:
When a field is not set 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: 26
description: Default size of Subnet based upon estimated workload
count. Defaults to 26.
type: integer
defaultSubnetAccessMode:
description: DefaultSubnetAccessMode defines the access mode of the
default SubnetSet for PodVM and VM. Must be Public or Private.
lbServiceSize:
enum:
- Public
- Private
- SMALL
- MEDIUM
- LARGE
- XLARGE
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.
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.
podSubnetAccessMode:
description: PodSubnetAccessMode defines the access mode of the default
SubnetSet for PodVM. Must be Public or Private.
enum:
- Public
- Private
- Project
type: string
privateIPs:
description: Private IPs.
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.
context in logs. Less than equal to 8 characters.
maxLength: 8
type: string
vpcConnectivityProfile:
description: VPCConnectivityProfile ID. This profile has configuration
related to create 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
6 changes: 3 additions & 3 deletions build/yaml/samples/nsx_v1alpha1_vpcnetworkconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@ metadata:
spec:
defaultGatewayPath: /infra/tier-0s/t0
edgeClusterPath: /infra/sites/default/enforcement-points/default/edge-clusters/2d9df59f-6dc6-4911-8865-21fadc23d4da
defaultIPv4SubnetSize: 26
defaultSubnetSize: 26
nsxtProject: proj-1
externalIPv4Blocks:
- block1
privateIPv4CIDRs:
privateIPs:
- 172.26.0.0/16
- 172.36.0.0/16
defaultSubnetAccessMode: Private
podSubnetAccessMode: Private
8 changes: 4 additions & 4 deletions pkg/apis/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
11 changes: 6 additions & 5 deletions pkg/apis/nsx.vmware.com/v1alpha1/subnet_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ 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:default:=Private
// +kubebuilder:validation:Enum=Private;Public;Project
AccessMode AccessMode `json:"accessMode,omitempty"`
// Subnet CIDRS.
// +kubebuilder:validation:MinItems=0
Expand All @@ -38,9 +39,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 +55,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
11 changes: 6 additions & 5 deletions pkg/apis/nsx.vmware.com/v1alpha1/subnetset_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,8 @@ 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:default:=Private
// +kubebuilder:validation:Enum=Private;Public;Project
AccessMode AccessMode `json:"accessMode,omitempty"`
// Subnet advanced configuration.
AdvancedConfig AdvancedConfig `json:"advancedConfig,omitempty"`
Expand All @@ -37,9 +38,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 +54,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
60 changes: 32 additions & 28 deletions pkg/apis/nsx.vmware.com/v1alpha1/vpcnetworkconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,13 @@ import (
)

const (
AccessModePublic string = "Public"
AccessModePrivate string = "Private"
AccessModePublic string = "Public"
AccessModePrivate string = "Private"
AccessModeProject string = "Project"
LbServiceSizeSmall string = "SMALL"
LbServiceSizeMedium string = "MEDIUM"
LbServiceSizeLarge string = "LARGE"
LbServiceSizeXlarge string = "XLARGE"
)

// VPCNetworkConfigurationSpec defines the desired state of VPCNetworkConfiguration.
Expand All @@ -19,33 +24,32 @@ 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 26.
// +kubebuilder:default=26
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"`

// VPCConnectivityProfile ID. This profile has configuration related to create 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 or equal to 8 characters.
// Less than equal to 8 characters.
// +kubebuilder:validation:MaxLength=8
// +optional
ShortID string `json:"shortID,omitempty"`

// +kubebuilder:validation:Enum=SMALL;MEDIUM;LARGE;XLARGE
LbServiceSize string `json:"lbServiceSize,omitempty"`

// Default size of Subnet based upon estimated workload count.
// Defaults to 26.
// +kubebuilder:default=26
DefaultSubnetSize int `json:"defaultSubnetSize,omitempty"`
// PodSubnetAccessMode defines the access mode of the default SubnetSet for PodVM.
// Must be Public or Private.
// +kubebuilder:validation:Enum=Public;Private;Project
PodSubnetAccessMode string `json:"podSubnetAccessMode,omitempty"`
}

// VPCNetworkConfigurationStatus defines the observed state of VPCNetworkConfiguration
Expand All @@ -64,15 +68,15 @@ 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="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 @@ -81,7 +85,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 487b211

Please sign in to comment.