diff --git a/.gitignore b/.gitignore index 59402d8ae..c60704db4 100644 --- a/.gitignore +++ b/.gitignore @@ -2,4 +2,6 @@ bin/ .DS_Store go.work -go.work.sum \ No newline at end of file +go.work.sum +vendor/ +.golangci-bin/ diff --git a/build/yaml/crd/nsx.vmware.com_ipaddressallocations.yaml b/build/yaml/crd/nsx.vmware.com_ipaddressallocations.yaml index 476fa42d6..45ce7a190 100644 --- a/build/yaml/crd/nsx.vmware.com_ipaddressallocations.yaml +++ b/build/yaml/crd/nsx.vmware.com_ipaddressallocations.yaml @@ -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 @@ -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 @@ -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: diff --git a/build/yaml/crd/nsx.vmware.com_ippools.yaml b/build/yaml/crd/nsx.vmware.com_ippools.yaml index e6cf505c4..3402a97f7 100644 --- a/build/yaml/crd/nsx.vmware.com_ippools.yaml +++ b/build/yaml/crd/nsx.vmware.com_ippools.yaml @@ -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: diff --git a/build/yaml/crd/nsx.vmware.com_subnets.yaml b/build/yaml/crd/nsx.vmware.com_subnets.yaml index 4b3af9df8..40aaa02dc 100644 --- a/build/yaml/crd/nsx.vmware.com_subnets.yaml +++ b/build/yaml/crd/nsx.vmware.com_subnets.yaml @@ -61,6 +61,7 @@ spec: enum: - Private - Public + - Project type: string advancedConfig: description: Subnet advanced configuration. diff --git a/build/yaml/crd/nsx.vmware.com_subnetsets.yaml b/build/yaml/crd/nsx.vmware.com_subnetsets.yaml index 912d1a93b..ac06b82e9 100644 --- a/build/yaml/crd/nsx.vmware.com_subnetsets.yaml +++ b/build/yaml/crd/nsx.vmware.com_subnetsets.yaml @@ -61,6 +61,7 @@ spec: enum: - Private - Public + - Project type: string advancedConfig: description: Subnet advanced configuration. diff --git a/build/yaml/crd/nsx.vmware.com_vpcnetworkconfigurations.yaml b/build/yaml/crd/nsx.vmware.com_vpcnetworkconfigurations.yaml index 23b96a849..1376e18d7 100644 --- a/build/yaml/crd/nsx.vmware.com_vpcnetworkconfigurations.yaml +++ b/build/yaml/crd/nsx.vmware.com_vpcnetworkconfigurations.yaml @@ -53,32 +53,30 @@ 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: 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. + defaultPodSubnetAccessMode: + description: DefaultPodSubnetAccessMode defines the access mode of + the default SubnetSet for PodVM. Must be Public or Private. enum: - Public - Private + - Project 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 + lbServiceSize: + enum: + - SMALL + - MEDIUM + - LARGE + - XLARGE + type: string nsxtProject: description: NSX-T Project the Namespace associated with. type: string @@ -94,6 +92,10 @@ spec: context in logs. Less than or 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 diff --git a/build/yaml/samples/nsx_v1alpha1_vpcnetworkconfigurations.yaml b/build/yaml/samples/nsx_v1alpha1_vpcnetworkconfigurations.yaml index c19703c2f..04cdb1727 100644 --- a/build/yaml/samples/nsx_v1alpha1_vpcnetworkconfigurations.yaml +++ b/build/yaml/samples/nsx_v1alpha1_vpcnetworkconfigurations.yaml @@ -12,4 +12,4 @@ spec: privateIPv4CIDRs: - 172.26.0.0/16 - 172.36.0.0/16 - defaultSubnetAccessMode: Private + defaultPodSubnetAccessMode: Private diff --git a/go.mod b/go.mod index bc94941b3..feda924c2 100644 --- a/go.mod +++ b/go.mod @@ -32,10 +32,6 @@ require ( github.com/vmware-tanzu/nsx-operator/pkg/client v0.0.0-20240102061654-537b080e159f github.com/vmware-tanzu/vm-operator/api v1.8.2 github.com/vmware/govmomi v0.27.4 - github.com/vmware/vsphere-automation-sdk-go/lib v0.7.0 - github.com/vmware/vsphere-automation-sdk-go/runtime v0.7.1-0.20240611083326-25a4e1834c4d - github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.12.0 - github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.6.0 go.uber.org/automaxprocs v1.5.3 go.uber.org/zap v1.25.0 golang.org/x/crypto v0.17.0 @@ -48,6 +44,13 @@ require ( sigs.k8s.io/controller-runtime v0.16.0 ) +require ( + github.com/vmware/vsphere-automation-sdk-go/lib v0.7.0 + github.com/vmware/vsphere-automation-sdk-go/runtime v0.7.1-0.20240611083326-25a4e1834c4d + github.com/vmware/vsphere-automation-sdk-go/services/nsxt v0.0.0-00010101000000-000000000000 + github.com/vmware/vsphere-automation-sdk-go/services/nsxt-mp v0.0.0-00010101000000-000000000000 +) + require ( github.com/beevik/etree v1.1.0 // indirect github.com/beorn7/perks v1.0.1 // indirect diff --git a/pkg/apis/nsx.vmware.com/v1alpha1/subnet_types.go b/pkg/apis/nsx.vmware.com/v1alpha1/subnet_types.go index 47553cd10..4fe02e827 100644 --- a/pkg/apis/nsx.vmware.com/v1alpha1/subnet_types.go +++ b/pkg/apis/nsx.vmware.com/v1alpha1/subnet_types.go @@ -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;Project AccessMode AccessMode `json:"accessMode,omitempty"` // Subnet CIDRS. // +kubebuilder:validation:MinItems=0 @@ -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" @@ -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 { diff --git a/pkg/apis/nsx.vmware.com/v1alpha1/subnetset_types.go b/pkg/apis/nsx.vmware.com/v1alpha1/subnetset_types.go index 3d8883355..7f9a9df17 100644 --- a/pkg/apis/nsx.vmware.com/v1alpha1/subnetset_types.go +++ b/pkg/apis/nsx.vmware.com/v1alpha1/subnetset_types.go @@ -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;Project AccessMode AccessMode `json:"accessMode,omitempty"` // Subnet advanced configuration. AdvancedConfig AdvancedConfig `json:"advancedConfig,omitempty"` @@ -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" @@ -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 { diff --git a/pkg/apis/nsx.vmware.com/v1alpha1/vpcnetworkconfiguration_types.go b/pkg/apis/nsx.vmware.com/v1alpha1/vpcnetworkconfiguration_types.go index 9ba4babbc..ac417b4bd 100644 --- a/pkg/apis/nsx.vmware.com/v1alpha1/vpcnetworkconfiguration_types.go +++ b/pkg/apis/nsx.vmware.com/v1alpha1/vpcnetworkconfiguration_types.go @@ -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. @@ -19,16 +24,18 @@ 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"` + // VPCConnectivityProfile ID. This profile has configuration related to create VPC transit gateway attachment. + VPCConnectivityProfile string `json:"vpcConnectivityProfile,omitempty"` + + // +kubebuilder:validation:Enum=SMALL;MEDIUM;LARGE;XLARGE + LbServiceSize string `json:"lbServiceSize,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 @@ -37,12 +44,12 @@ type VPCNetworkConfigurationSpec struct { // Defaults to 26. // +kubebuilder:default=26 DefaultIPv4SubnetSize int `json:"defaultIPv4SubnetSize,omitempty"` - // DefaultSubnetAccessMode defines the access mode of the default SubnetSet for PodVM and VM. + // DefaultPodSubnetAccessMode defines the access mode of the default SubnetSet for PodVM. // Must be Public or Private. - // +kubebuilder:validation:Enum=Public;Private - DefaultSubnetAccessMode string `json:"defaultSubnetAccessMode,omitempty"` + // +kubebuilder:validation:Enum=Public;Private;Project + DefaultPodSubnetAccessMode string `json:"defaultPodSubnetAccessMode,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"` @@ -64,9 +71,9 @@ 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" @@ -81,7 +88,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 { diff --git a/pkg/apis/nsx.vmware.com/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/nsx.vmware.com/v1alpha1/zz_generated.deepcopy.go index 5919f2d28..3b3620558 100644 --- a/pkg/apis/nsx.vmware.com/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/nsx.vmware.com/v1alpha1/zz_generated.deepcopy.go @@ -80,6 +80,102 @@ func (in *DNSClientConfig) DeepCopy() *DNSClientConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressAllocation) DeepCopyInto(out *IPAddressAllocation) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocation. +func (in *IPAddressAllocation) DeepCopy() *IPAddressAllocation { + if in == nil { + return nil + } + out := new(IPAddressAllocation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPAddressAllocation) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressAllocationList) DeepCopyInto(out *IPAddressAllocationList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]IPAddressAllocation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationList. +func (in *IPAddressAllocationList) DeepCopy() *IPAddressAllocationList { + if in == nil { + return nil + } + out := new(IPAddressAllocationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPAddressAllocationList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressAllocationSpec) DeepCopyInto(out *IPAddressAllocationSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationSpec. +func (in *IPAddressAllocationSpec) DeepCopy() *IPAddressAllocationSpec { + if in == nil { + return nil + } + out := new(IPAddressAllocationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressAllocationStatus) DeepCopyInto(out *IPAddressAllocationStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationStatus. +func (in *IPAddressAllocationStatus) DeepCopy() *IPAddressAllocationStatus { + if in == nil { + return nil + } + out := new(IPAddressAllocationStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IPBlock) DeepCopyInto(out *IPBlock) { *out = *in @@ -1334,11 +1430,6 @@ func (in *VPCNetworkConfigurationList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VPCNetworkConfigurationSpec) DeepCopyInto(out *VPCNetworkConfigurationSpec) { *out = *in - if in.ExternalIPv4Blocks != nil { - in, out := &in.ExternalIPv4Blocks, &out.ExternalIPv4Blocks - *out = make([]string, len(*in)) - copy(*out, *in) - } if in.PrivateIPv4CIDRs != nil { in, out := &in.PrivateIPv4CIDRs, &out.PrivateIPv4CIDRs *out = make([]string, len(*in)) @@ -1395,92 +1486,3 @@ func (in *VPCState) DeepCopy() *VPCState { in.DeepCopyInto(out) return out } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *IPAddressAllocation) DeepCopyInto(out *IPAddressAllocation) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocation. -func (in *IPAddressAllocation) DeepCopy() *IPAddressAllocation { - if in == nil { - return nil - } - out := new(IPAddressAllocation) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *IPAddressAllocation) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *IPAddressAllocationList) DeepCopyInto(out *IPAddressAllocationList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]IPAddressAllocation, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationList. -func (in *IPAddressAllocationList) DeepCopy() *IPAddressAllocationList { - if in == nil { - return nil - } - out := new(IPAddressAllocationList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *IPAddressAllocationList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *IPAddressAllocationSpec) DeepCopyInto(out *IPAddressAllocationSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationSpec. -func (in *IPAddressAllocationSpec) DeepCopy() *IPAddressAllocationSpec { - if in == nil { - return nil - } - out := new(IPAddressAllocationSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *IPAddressAllocationStatus) DeepCopyInto(out *IPAddressAllocationStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationStatus. -func (in *IPAddressAllocationStatus) DeepCopy() *IPAddressAllocationStatus { - if in == nil { - return nil - } - out := new(IPAddressAllocationStatus) - in.DeepCopyInto(out) - return out -} \ No newline at end of file diff --git a/pkg/apis/nsx.vmware.com/v1alpha2/ippool_types.go b/pkg/apis/nsx.vmware.com/v1alpha2/ippool_types.go index 469dc43ef..a6d995d7c 100644 --- a/pkg/apis/nsx.vmware.com/v1alpha2/ippool_types.go +++ b/pkg/apis/nsx.vmware.com/v1alpha2/ippool_types.go @@ -10,9 +10,9 @@ import ( ) // +genclient -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status -//+kubebuilder:storageversion +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion // IPPool is the Schema for the ippools API. // +kubebuilder:printcolumn:name="Type",type=string,JSONPath=`.spec.type`,description="Type of IPPool" @@ -25,7 +25,7 @@ type IPPool struct { Status IPPoolStatus `json:"status,omitempty"` } -//+kubebuilder:object:root=true +// +kubebuilder:object:root=true // IPPoolList contains a list of IPPool. type IPPoolList struct { @@ -36,8 +36,8 @@ type IPPoolList struct { // IPPoolSpec defines the desired state of IPPool. type IPPoolSpec struct { - // Type defines the type of this IPPool, Public or Private. - // +kubebuilder:validation:Enum=Public;Private + // Type defines the type of this IPPool, Public, Private or Project. + // +kubebuilder:validation:Enum=Public;Private;Project // +optional Type string `json:"type,omitempty"` // Subnets defines set of subnets need to be allocated. diff --git a/pkg/apis/v1alpha1/subnet_types.go b/pkg/apis/v1alpha1/subnet_types.go index 47553cd10..4fe02e827 100644 --- a/pkg/apis/v1alpha1/subnet_types.go +++ b/pkg/apis/v1alpha1/subnet_types.go @@ -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;Project AccessMode AccessMode `json:"accessMode,omitempty"` // Subnet CIDRS. // +kubebuilder:validation:MinItems=0 @@ -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" @@ -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 { diff --git a/pkg/apis/v1alpha1/subnetset_types.go b/pkg/apis/v1alpha1/subnetset_types.go index 3d8883355..7f9a9df17 100644 --- a/pkg/apis/v1alpha1/subnetset_types.go +++ b/pkg/apis/v1alpha1/subnetset_types.go @@ -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;Project AccessMode AccessMode `json:"accessMode,omitempty"` // Subnet advanced configuration. AdvancedConfig AdvancedConfig `json:"advancedConfig,omitempty"` @@ -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" @@ -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 { diff --git a/pkg/apis/v1alpha1/vpcnetworkconfiguration_types.go b/pkg/apis/v1alpha1/vpcnetworkconfiguration_types.go index 9ba4babbc..9ca5c63b8 100644 --- a/pkg/apis/v1alpha1/vpcnetworkconfiguration_types.go +++ b/pkg/apis/v1alpha1/vpcnetworkconfiguration_types.go @@ -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. @@ -19,16 +24,18 @@ 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"` + // VPCConnectivityProfile ID. This profile has configuration related to create VPC transit gateway attachment. + VPCConnectivityProfile string `json:"vpcConnectivityProfile,omitempty"` + + // +kubebuilder:validation:Enum=SMALL;MEDIUM;LARGE;XLARGE + LbServiceSize string `json:"lbServiceSize,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 @@ -37,10 +44,10 @@ type VPCNetworkConfigurationSpec struct { // Defaults to 26. // +kubebuilder:default=26 DefaultIPv4SubnetSize int `json:"defaultIPv4SubnetSize,omitempty"` - // DefaultSubnetAccessMode defines the access mode of the default SubnetSet for PodVM and VM. + // DefaultPodSubnetAccessMode defines the access mode of the default SubnetSet for PodVM. // Must be Public or Private. - // +kubebuilder:validation:Enum=Public;Private - DefaultSubnetAccessMode string `json:"defaultSubnetAccessMode,omitempty"` + // +kubebuilder:validation:Enum=Public;Private;Project + DefaultPodSubnetAccessMode string `json:"defaultPodSubnetAccessMode,omitempty"` // ShortID specifies Identifier to use when displaying VPC context in logs. // Less than or equal to 8 characters. // +kubebuilder:validation:MaxLength=8 @@ -64,9 +71,9 @@ 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" @@ -81,7 +88,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 { diff --git a/pkg/apis/v1alpha1/zz_generated.deepcopy.go b/pkg/apis/v1alpha1/zz_generated.deepcopy.go index 5919f2d28..3b3620558 100644 --- a/pkg/apis/v1alpha1/zz_generated.deepcopy.go +++ b/pkg/apis/v1alpha1/zz_generated.deepcopy.go @@ -80,6 +80,102 @@ func (in *DNSClientConfig) DeepCopy() *DNSClientConfig { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressAllocation) DeepCopyInto(out *IPAddressAllocation) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) + out.Spec = in.Spec + in.Status.DeepCopyInto(&out.Status) +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocation. +func (in *IPAddressAllocation) DeepCopy() *IPAddressAllocation { + if in == nil { + return nil + } + out := new(IPAddressAllocation) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPAddressAllocation) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressAllocationList) DeepCopyInto(out *IPAddressAllocationList) { + *out = *in + out.TypeMeta = in.TypeMeta + in.ListMeta.DeepCopyInto(&out.ListMeta) + if in.Items != nil { + in, out := &in.Items, &out.Items + *out = make([]IPAddressAllocation, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationList. +func (in *IPAddressAllocationList) DeepCopy() *IPAddressAllocationList { + if in == nil { + return nil + } + out := new(IPAddressAllocationList) + in.DeepCopyInto(out) + return out +} + +// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. +func (in *IPAddressAllocationList) DeepCopyObject() runtime.Object { + if c := in.DeepCopy(); c != nil { + return c + } + return nil +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressAllocationSpec) DeepCopyInto(out *IPAddressAllocationSpec) { + *out = *in +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationSpec. +func (in *IPAddressAllocationSpec) DeepCopy() *IPAddressAllocationSpec { + if in == nil { + return nil + } + out := new(IPAddressAllocationSpec) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *IPAddressAllocationStatus) DeepCopyInto(out *IPAddressAllocationStatus) { + *out = *in + if in.Conditions != nil { + in, out := &in.Conditions, &out.Conditions + *out = make([]Condition, len(*in)) + for i := range *in { + (*in)[i].DeepCopyInto(&(*out)[i]) + } + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationStatus. +func (in *IPAddressAllocationStatus) DeepCopy() *IPAddressAllocationStatus { + if in == nil { + return nil + } + out := new(IPAddressAllocationStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *IPBlock) DeepCopyInto(out *IPBlock) { *out = *in @@ -1334,11 +1430,6 @@ func (in *VPCNetworkConfigurationList) DeepCopyObject() runtime.Object { // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VPCNetworkConfigurationSpec) DeepCopyInto(out *VPCNetworkConfigurationSpec) { *out = *in - if in.ExternalIPv4Blocks != nil { - in, out := &in.ExternalIPv4Blocks, &out.ExternalIPv4Blocks - *out = make([]string, len(*in)) - copy(*out, *in) - } if in.PrivateIPv4CIDRs != nil { in, out := &in.PrivateIPv4CIDRs, &out.PrivateIPv4CIDRs *out = make([]string, len(*in)) @@ -1395,92 +1486,3 @@ func (in *VPCState) DeepCopy() *VPCState { in.DeepCopyInto(out) return out } - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *IPAddressAllocation) DeepCopyInto(out *IPAddressAllocation) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ObjectMeta.DeepCopyInto(&out.ObjectMeta) - out.Spec = in.Spec - out.Status = in.Status -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocation. -func (in *IPAddressAllocation) DeepCopy() *IPAddressAllocation { - if in == nil { - return nil - } - out := new(IPAddressAllocation) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *IPAddressAllocation) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *IPAddressAllocationList) DeepCopyInto(out *IPAddressAllocationList) { - *out = *in - out.TypeMeta = in.TypeMeta - in.ListMeta.DeepCopyInto(&out.ListMeta) - if in.Items != nil { - in, out := &in.Items, &out.Items - *out = make([]IPAddressAllocation, len(*in)) - for i := range *in { - (*in)[i].DeepCopyInto(&(*out)[i]) - } - } -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationList. -func (in *IPAddressAllocationList) DeepCopy() *IPAddressAllocationList { - if in == nil { - return nil - } - out := new(IPAddressAllocationList) - in.DeepCopyInto(out) - return out -} - -// DeepCopyObject is an autogenerated deepcopy function, copying the receiver, creating a new runtime.Object. -func (in *IPAddressAllocationList) DeepCopyObject() runtime.Object { - if c := in.DeepCopy(); c != nil { - return c - } - return nil -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *IPAddressAllocationSpec) DeepCopyInto(out *IPAddressAllocationSpec) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationSpec. -func (in *IPAddressAllocationSpec) DeepCopy() *IPAddressAllocationSpec { - if in == nil { - return nil - } - out := new(IPAddressAllocationSpec) - in.DeepCopyInto(out) - return out -} - -// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. -func (in *IPAddressAllocationStatus) DeepCopyInto(out *IPAddressAllocationStatus) { - *out = *in -} - -// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new IPAddressAllocationStatus. -func (in *IPAddressAllocationStatus) DeepCopy() *IPAddressAllocationStatus { - if in == nil { - return nil - } - out := new(IPAddressAllocationStatus) - in.DeepCopyInto(out) - return out -} \ No newline at end of file diff --git a/pkg/apis/v1alpha2/ippool_types.go b/pkg/apis/v1alpha2/ippool_types.go index 469dc43ef..a6d995d7c 100644 --- a/pkg/apis/v1alpha2/ippool_types.go +++ b/pkg/apis/v1alpha2/ippool_types.go @@ -10,9 +10,9 @@ import ( ) // +genclient -//+kubebuilder:object:root=true -//+kubebuilder:subresource:status -//+kubebuilder:storageversion +// +kubebuilder:object:root=true +// +kubebuilder:subresource:status +// +kubebuilder:storageversion // IPPool is the Schema for the ippools API. // +kubebuilder:printcolumn:name="Type",type=string,JSONPath=`.spec.type`,description="Type of IPPool" @@ -25,7 +25,7 @@ type IPPool struct { Status IPPoolStatus `json:"status,omitempty"` } -//+kubebuilder:object:root=true +// +kubebuilder:object:root=true // IPPoolList contains a list of IPPool. type IPPoolList struct { @@ -36,8 +36,8 @@ type IPPoolList struct { // IPPoolSpec defines the desired state of IPPool. type IPPoolSpec struct { - // Type defines the type of this IPPool, Public or Private. - // +kubebuilder:validation:Enum=Public;Private + // Type defines the type of this IPPool, Public, Private or Project. + // +kubebuilder:validation:Enum=Public;Private;Project // +optional Type string `json:"type,omitempty"` // Subnets defines set of subnets need to be allocated. diff --git a/pkg/controllers/ippool/ippool_controller.go b/pkg/controllers/ippool/ippool_controller.go index 85e0c9722..4c7450e62 100644 --- a/pkg/controllers/ippool/ippool_controller.go +++ b/pkg/controllers/ippool/ippool_controller.go @@ -127,7 +127,7 @@ func (r *IPPoolReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr } // TODO: As we do not have base controller in Go, we need to take care of NSX exceptions in each controller separately. - //I agree we should not do infinite retry for all errors, but it's ok to add error handling in a following patch + // I agree we should not do infinite retry for all errors, but it's ok to add error handling in a following patch // TODO: Since only the cloud provider creates it, we can take all the validation logic into consideration later. @@ -145,7 +145,7 @@ func (r *IPPoolReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr updateFail(r, &ctx, obj, &err) return resultRequeue, err } - obj.Spec.Type = vpcNetworkConfig.DefaultSubnetAccessMode + obj.Spec.Type = vpcNetworkConfig.DefaultPodSubnetAccessMode } if obj.ObjectMeta.DeletionTimestamp.IsZero() { diff --git a/pkg/controllers/networkinfo/vpcnetworkconfig_handler.go b/pkg/controllers/networkinfo/vpcnetworkconfig_handler.go index e580dbf2a..e1032480f 100644 --- a/pkg/controllers/networkinfo/vpcnetworkconfig_handler.go +++ b/pkg/controllers/networkinfo/vpcnetworkconfig_handler.go @@ -121,17 +121,17 @@ func buildNetworkConfigInfo(vpcConfigCR v1alpha1.VPCNetworkConfiguration) (*comm } ninfo := &commontypes.VPCNetworkConfigInfo{ - IsDefault: isDefaultNetworkConfigCR(vpcConfigCR), - Org: org, - Name: vpcConfigCR.Name, - DefaultGatewayPath: vpcConfigCR.Spec.DefaultGatewayPath, - EdgeClusterPath: vpcConfigCR.Spec.EdgeClusterPath, - NsxtProject: project, - ExternalIPv4Blocks: vpcConfigCR.Spec.ExternalIPv4Blocks, - PrivateIPv4CIDRs: vpcConfigCR.Spec.PrivateIPv4CIDRs, - DefaultIPv4SubnetSize: vpcConfigCR.Spec.DefaultIPv4SubnetSize, - DefaultSubnetAccessMode: vpcConfigCR.Spec.DefaultSubnetAccessMode, - ShortID: vpcConfigCR.Spec.ShortID, + IsDefault: isDefaultNetworkConfigCR(vpcConfigCR), + Org: org, + Name: vpcConfigCR.Name, + EdgeClusterPath: vpcConfigCR.Spec.EdgeClusterPath, + VPCConnectivityProfile: vpcConfigCR.Spec.VPCConnectivityProfile, + LbServiceSize: vpcConfigCR.Spec.LbServiceSize, + NsxtProject: project, + PrivateIPv4CIDRs: vpcConfigCR.Spec.PrivateIPv4CIDRs, + DefaultIPv4SubnetSize: vpcConfigCR.Spec.DefaultIPv4SubnetSize, + DefaultPodSubnetAccessMode: vpcConfigCR.Spec.DefaultPodSubnetAccessMode, + ShortID: vpcConfigCR.Spec.ShortID, } return ninfo, nil } diff --git a/pkg/controllers/networkinfo/vpcnetworkconfig_handler_test.go b/pkg/controllers/networkinfo/vpcnetworkconfig_handler_test.go index 85a464933..ace8ec528 100644 --- a/pkg/controllers/networkinfo/vpcnetworkconfig_handler_test.go +++ b/pkg/controllers/networkinfo/vpcnetworkconfig_handler_test.go @@ -73,22 +73,24 @@ func TestBuildNetworkConfigInfo(t *testing.T) { assert.NotNil(t, e) spec1 := v1alpha1.VPCNetworkConfigurationSpec{ - DefaultGatewayPath: "test-gw-path-1", - EdgeClusterPath: "test-edge-path-1", - ExternalIPv4Blocks: []string{"external-ipb-1", "external-ipb-2"}, - PrivateIPv4CIDRs: []string{"private-ipb-1", "private-ipb-2"}, - DefaultIPv4SubnetSize: 64, - DefaultSubnetAccessMode: "Public", - NSXTProject: "/orgs/default/projects/nsx_operator_e2e_test", + // DefaultGatewayPath: "test-gw-path-1", + // EdgeClusterPath: "test-edge-path-1", + // ExternalIPv4Blocks: []string{"external-ipb-1", "external-ipb-2"}, + PrivateIPv4CIDRs: []string{"private-ipb-1", "private-ipb-2"}, + DefaultIPv4SubnetSize: 64, + // VPCServiceProfile: "test-VpcServiceProfile", + VPCConnectivityProfile: "test-VPCConnectivityProfile", + DefaultPodSubnetAccessMode: "Public", + NSXTProject: "/orgs/default/projects/nsx_operator_e2e_test", } spec2 := v1alpha1.VPCNetworkConfigurationSpec{ - DefaultGatewayPath: "test-gw-path-2", - EdgeClusterPath: "test-edge-path-2", - ExternalIPv4Blocks: []string{"external-ipb-1", "external-ipb-2"}, - PrivateIPv4CIDRs: []string{"private-ipb-1", "private-ipb-2"}, - DefaultIPv4SubnetSize: 32, - DefaultSubnetAccessMode: "Private", - NSXTProject: "/orgs/anotherOrg/projects/anotherProject", + // DefaultGatewayPath: "test-gw-path-2", + // EdgeClusterPath: "test-edge-path-2", + // ExternalIPv4Blocks: []string{"external-ipb-1", "external-ipb-2"}, + PrivateIPv4CIDRs: []string{"private-ipb-1", "private-ipb-2"}, + DefaultIPv4SubnetSize: 32, + DefaultPodSubnetAccessMode: "Private", + NSXTProject: "/orgs/anotherOrg/projects/anotherProject", } testCRD1 := v1alpha1.VPCNetworkConfiguration{ Spec: spec1, @@ -110,30 +112,31 @@ func TestBuildNetworkConfigInfo(t *testing.T) { testCRD3.Name = "test-3" tests := []struct { - name string - nc v1alpha1.VPCNetworkConfiguration - gw string - edge string - org string - project string - subnetSize int - accessMode string - isDefault bool + name string + nc v1alpha1.VPCNetworkConfiguration + gw string + edge string + org string + project string + subnetSize int + accessMode string + isDefault bool + vpcConnectivityProfile string }{ - {"1", testCRD1, "test-gw-path-1", "test-edge-path-1", "default", "nsx_operator_e2e_test", 64, "Public", false}, - {"2", testCRD2, "test-gw-path-2", "test-edge-path-2", "anotherOrg", "anotherProject", 32, "Private", false}, - {"3", testCRD3, "test-gw-path-2", "test-edge-path-2", "anotherOrg", "anotherProject", 32, "Private", true}, + {"test-nsxtProjectPathToId", testCRD1, "test-gw-path-1", "test-edge-path-1", "default", "nsx_operator_e2e_test", 64, "Public", false, ""}, + {"with-VPCConnectivityProfile", testCRD2, "test-gw-path-2", "test-edge-path-2", "anotherOrg", "anotherProject", 32, "Private", false, "test-VpcConnectivityProfile"}, + {"with-defaultNetworkConfig", testCRD3, "test-gw-path-2", "test-edge-path-2", "anotherOrg", "anotherProject", 32, "Private", true, ""}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { nc, e := buildNetworkConfigInfo(tt.nc) assert.Nil(t, e) - assert.Equal(t, tt.gw, nc.DefaultGatewayPath) - assert.Equal(t, tt.edge, nc.EdgeClusterPath) + // assert.Equal(t, tt.gw, nc.DefaultGatewayPath) + // assert.Equal(t, tt.edge, nc.EdgeClusterPath) assert.Equal(t, tt.org, nc.Org) assert.Equal(t, tt.project, nc.NsxtProject) assert.Equal(t, tt.subnetSize, nc.DefaultIPv4SubnetSize) - assert.Equal(t, tt.accessMode, nc.DefaultSubnetAccessMode) + assert.Equal(t, tt.accessMode, nc.DefaultPodSubnetAccessMode) assert.Equal(t, tt.isDefault, nc.IsDefault) }) } diff --git a/pkg/controllers/subnet/subnet_controller.go b/pkg/controllers/subnet/subnet_controller.go index d2de63968..ee6c1b839 100644 --- a/pkg/controllers/subnet/subnet_controller.go +++ b/pkg/controllers/subnet/subnet_controller.go @@ -84,7 +84,7 @@ func (r *SubnetReconciler) Reconcile(ctx context.Context, req ctrl.Request) (ctr return ResultRequeue, err } if obj.Spec.AccessMode == "" { - obj.Spec.AccessMode = v1alpha1.AccessMode(vpcNetworkConfig.DefaultSubnetAccessMode) + obj.Spec.AccessMode = v1alpha1.AccessMode(vpcNetworkConfig.DefaultPodSubnetAccessMode) } if obj.Spec.IPv4SubnetSize == 0 { obj.Spec.IPv4SubnetSize = vpcNetworkConfig.DefaultIPv4SubnetSize diff --git a/pkg/controllers/subnetset/subnetset_controller.go b/pkg/controllers/subnetset/subnetset_controller.go index b50fa42b6..bcb5b66c5 100644 --- a/pkg/controllers/subnetset/subnetset_controller.go +++ b/pkg/controllers/subnetset/subnetset_controller.go @@ -75,7 +75,7 @@ func (r *SubnetSetReconciler) Reconcile(ctx context.Context, req ctrl.Request) ( return ResultRequeue, err } if obj.Spec.AccessMode == "" { - obj.Spec.AccessMode = v1alpha1.AccessMode(vpcNetworkConfig.DefaultSubnetAccessMode) + obj.Spec.AccessMode = v1alpha1.AccessMode(vpcNetworkConfig.DefaultPodSubnetAccessMode) } if obj.Spec.IPv4SubnetSize == 0 { obj.Spec.IPv4SubnetSize = vpcNetworkConfig.DefaultIPv4SubnetSize diff --git a/pkg/nsx/services/common/types.go b/pkg/nsx/services/common/types.go index 08d671dff..1676b257a 100644 --- a/pkg/nsx/services/common/types.go +++ b/pkg/nsx/services/common/types.go @@ -191,19 +191,21 @@ type VPCResourceInfo struct { ID string ParentID string PrivateIpv4Blocks []string - ExternalIPv4Blocks []string + ExternalIPv4Blocks []string // deprecated, existing field } type VPCNetworkConfigInfo struct { - IsDefault bool - Org string - Name string - DefaultGatewayPath string - EdgeClusterPath string - NsxtProject string - ExternalIPv4Blocks []string - PrivateIPv4CIDRs []string - DefaultIPv4SubnetSize int - DefaultSubnetAccessMode string - ShortID string + IsDefault bool + Org string + Name string + DefaultGatewayPath string + VPCConnectivityProfile string + LbServiceSize string + EdgeClusterPath string + NsxtProject string + ExternalIPv4Blocks []string + PrivateIPv4CIDRs []string + DefaultIPv4SubnetSize int + DefaultPodSubnetAccessMode string + ShortID string } diff --git a/pkg/nsx/services/vpc/builder.go b/pkg/nsx/services/vpc/builder.go index 5189ac73e..61b58c795 100644 --- a/pkg/nsx/services/vpc/builder.go +++ b/pkg/nsx/services/vpc/builder.go @@ -67,7 +67,6 @@ func buildNSXVPC(obj *v1alpha1.NetworkInfo, nsObj *v1.Namespace, nc common.VPCNe vpcName := util.GenerateDisplayName("", "vpc", obj.GetNamespace(), "", cluster) vpc.DisplayName = &vpcName vpc.Id = common.String(string(nsObj.GetUID())) - vpc.DefaultGatewayPath = &nc.DefaultGatewayPath vpc.IpAddressType = &DefaultVPCIPAddressType siteInfos := []model.SiteInfo{ @@ -80,8 +79,9 @@ func buildNSXVPC(obj *v1alpha1.NetworkInfo, nsObj *v1.Namespace, nc common.VPCNe vpc.Tags = util.BuildBasicTags(cluster, obj, nsObj.UID) } + vpc.VpcConnectivityProfile = &nc.VPCConnectivityProfile + // update private/public blocks - vpc.ExternalIpv4Blocks = nc.ExternalIPv4Blocks vpc.PrivateIpv4Blocks = util.GetMapValues(pathMap) if nc.ShortID != "" { vpc.ShortId = &nc.ShortID diff --git a/pkg/nsx/services/vpc/vpc.go b/pkg/nsx/services/vpc/vpc.go index 415b92773..3d8ee90af 100644 --- a/pkg/nsx/services/vpc/vpc.go +++ b/pkg/nsx/services/vpc/vpc.go @@ -173,11 +173,11 @@ func InitializeVPC(service common.Service) (*VPCService, error) { VPCService.VPCNSNetworkConfigStore = VPCNsNetworkConfigStore{ VPCNSNetworkConfigMap: make(map[string]string), } - //initialize vpc store and ip blocks store + // initialize vpc store and ip blocks store go VPCService.InitializeResourceStore(&wg, fatalErrors, common.ResourceTypeVpc, nil, VPCService.VpcStore) go VPCService.InitializeResourceStore(&wg, fatalErrors, common.ResourceTypeIPBlock, nil, VPCService.IpblockStore) - //initalize avi rule related store + // initalize avi rule related store if enableAviAllowRule { VPCService.RuleStore = &AviRuleStore{ResourceStore: common.ResourceStore{ Indexer: cache.NewIndexer(keyFuncAVI, nil), diff --git a/test/e2e/manifest/testVPC/customize_networkconfig.yaml b/test/e2e/manifest/testVPC/customize_networkconfig.yaml index 913c8e46d..7f712bdbe 100644 --- a/test/e2e/manifest/testVPC/customize_networkconfig.yaml +++ b/test/e2e/manifest/testVPC/customize_networkconfig.yaml @@ -15,5 +15,5 @@ spec: privateIPv4CIDRs: - 172.29.0.0/16 - 172.39.0.0/16 - defaultSubnetAccessMode: Public + defaultPodSubnetAccessMode: Public \ No newline at end of file diff --git a/test/e2e/manifest/testVPC/customize_networkconfig_updated.yaml b/test/e2e/manifest/testVPC/customize_networkconfig_updated.yaml index a718cd518..e103e47c8 100644 --- a/test/e2e/manifest/testVPC/customize_networkconfig_updated.yaml +++ b/test/e2e/manifest/testVPC/customize_networkconfig_updated.yaml @@ -16,5 +16,5 @@ spec: - 172.29.0.0/16 - 172.39.0.0/16 - 172.49.0.0/16 - defaultSubnetAccessMode: Public + defaultPodSubnetAccessMode: Public \ No newline at end of file diff --git a/test/e2e/manifest/testVPC/default_networkconfig.yaml b/test/e2e/manifest/testVPC/default_networkconfig.yaml index dbfb2edb3..fd2d8d6f6 100644 --- a/test/e2e/manifest/testVPC/default_networkconfig.yaml +++ b/test/e2e/manifest/testVPC/default_networkconfig.yaml @@ -19,4 +19,4 @@ spec: privateIPv4CIDRs: - 172.28.0.0/16 - 172.38.0.0/16 - defaultSubnetAccessMode: Public + defaultPodSubnetAccessMode: Public diff --git a/test/e2e/manifest/testVPC/system_networkconfig.yaml b/test/e2e/manifest/testVPC/system_networkconfig.yaml index 843f7b5d0..7db836d78 100644 --- a/test/e2e/manifest/testVPC/system_networkconfig.yaml +++ b/test/e2e/manifest/testVPC/system_networkconfig.yaml @@ -16,5 +16,5 @@ spec: privateIPv4CIDRs: - 172.27.0.0/16 - 172.37.0.0/16 - defaultSubnetAccessMode: Public + defaultPodSubnetAccessMode: Public \ No newline at end of file diff --git a/test/e2e/nsx_subnet_test.go b/test/e2e/nsx_subnet_test.go index f89b56408..4ac51c6c2 100644 --- a/test/e2e/nsx_subnet_test.go +++ b/test/e2e/nsx_subnet_test.go @@ -41,8 +41,8 @@ func verifySubnetSetCR(subnetSet string) bool { log.Printf("Failed to get %s/%s: %s", E2ENamespace, subnetSet, err) return false } - if string(subnetSetCR.Spec.AccessMode) != vpcNetworkConfig.Spec.DefaultSubnetAccessMode { - log.Printf("AccessMode is %s, while it's expected to be %s", subnetSetCR.Spec.AccessMode, vpcNetworkConfig.Spec.DefaultSubnetAccessMode) + if string(subnetSetCR.Spec.AccessMode) != vpcNetworkConfig.Spec.DefaultPodSubnetAccessMode { + log.Printf("AccessMode is %s, while it's expected to be %s", subnetSetCR.Spec.AccessMode, vpcNetworkConfig.Spec.DefaultPodSubnetAccessMode) return false } if subnetSetCR.Spec.IPv4SubnetSize != vpcNetworkConfig.Spec.DefaultIPv4SubnetSize {