Skip to content

Commit

Permalink
update vpcnetworkconfigurations crd
Browse files Browse the repository at this point in the history
Signed-off-by: Wenqi Qiu <wenqiq@vmware.com>
  • Loading branch information
wenqiq committed Jul 4, 2024
1 parent fc1f7e5 commit 99bdeda
Show file tree
Hide file tree
Showing 26 changed files with 148 additions and 156 deletions.
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
32 changes: 15 additions & 17 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,19 +53,11 @@ spec:
When a field is not set in a Namespace's VPCNetworkConfiguration, the
Namespace will use the value in the default VPCNetworkConfiguration.
properties:
defaultIPv4SubnetSize:
defaultSubnetSize:
default: 26
description: Default size of Subnet based upon estimated workload
count. Defaults to 26.
type: integer
defaultPodSubnetAccessMode:
description: DefaultPodSubnetAccessMode defines the access mode of
the default SubnetSet for PodVM. Must be Public or Private.
enum:
- Public
- Private
- Project
type: string
lbServiceSize:
enum:
- SMALL
Expand All @@ -76,16 +68,22 @@ spec:
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:
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
defaultPodSubnetAccessMode: 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
32 changes: 16 additions & 16 deletions pkg/apis/nsx.vmware.com/v1alpha1/vpcnetworkconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,32 @@ const (
// in a Namespace's VPCNetworkConfiguration, the Namespace will use the value
// in the default VPCNetworkConfiguration.
type VPCNetworkConfigurationSpec struct {
// NSX-T Project the Namespace associated with.
NSXTProject string `json:"nsxtProject,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 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"`

// NSX-T Project the Namespace associated with.
NSXTProject string `json:"nsxtProject,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"`
// DefaultPodSubnetAccessMode defines the access mode of the default SubnetSet for PodVM.
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
DefaultPodSubnetAccessMode string `json:"defaultPodSubnetAccessMode,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"`
PodSubnetAccessMode string `json:"podSubnetAccessMode,omitempty"`
}

// VPCNetworkConfigurationStatus defines the observed state of VPCNetworkConfiguration
Expand All @@ -76,7 +76,7 @@ type VPCInfo struct {
// +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 Down
8 changes: 4 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.

8 changes: 4 additions & 4 deletions pkg/apis/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
32 changes: 16 additions & 16 deletions pkg/apis/v1alpha1/vpcnetworkconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,32 +24,32 @@ const (
// in a Namespace's VPCNetworkConfiguration, the Namespace will use the value
// in the default VPCNetworkConfiguration.
type VPCNetworkConfigurationSpec struct {
// NSX-T Project the Namespace associated with.
NSXTProject string `json:"nsxtProject,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 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"`

// NSX-T Project the Namespace associated with.
NSXTProject string `json:"nsxtProject,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"`
// DefaultPodSubnetAccessMode defines the access mode of the default SubnetSet for PodVM.
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
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
// +optional
ShortID string `json:"shortID,omitempty"`
PodSubnetAccessMode string `json:"podSubnetAccessMode,omitempty"`
}

// VPCNetworkConfigurationStatus defines the observed state of VPCNetworkConfiguration
Expand All @@ -76,7 +76,7 @@ type VPCInfo struct {
// +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 Down
8 changes: 4 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.

2 changes: 1 addition & 1 deletion pkg/controllers/ippool/ippool_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -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.DefaultPodSubnetAccessMode
obj.Spec.Type = vpcNetworkConfig.PodSubnetAccessMode
}

if obj.ObjectMeta.DeletionTimestamp.IsZero() {
Expand Down
8 changes: 4 additions & 4 deletions pkg/controllers/networkinfo/networkinfo_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ func (r *NetworkInfoReconciler) Reconcile(ctx context.Context, req ctrl.Request)
VPCPath: *createdVpc.Path,
DefaultSNATIP: "",
LoadBalancerIPAddresses: "",
PrivateIPv4CIDRs: nc.PrivateIPv4CIDRs,
PrivateIPs: nc.PrivateIPs,
}
log.Error(err, "update avi rule failed, would retry exponentially", "NetworkInfo", req.NamespacedName)
updateFail(r, &ctx, obj, &err, r.Client, state)
Expand All @@ -106,7 +106,7 @@ func (r *NetworkInfoReconciler) Reconcile(ctx context.Context, req ctrl.Request)
VPCPath: *createdVpc.Path,
DefaultSNATIP: "",
LoadBalancerIPAddresses: "",
PrivateIPv4CIDRs: nc.PrivateIPv4CIDRs,
PrivateIPs: nc.PrivateIPs,
}
updateFail(r, &ctx, obj, &err, r.Client, state)
return common.ResultRequeueAfter10sec, err
Expand All @@ -125,7 +125,7 @@ func (r *NetworkInfoReconciler) Reconcile(ctx context.Context, req ctrl.Request)
VPCPath: *createdVpc.Path,
DefaultSNATIP: snatIP,
LoadBalancerIPAddresses: "",
PrivateIPv4CIDRs: nc.PrivateIPv4CIDRs,
PrivateIPs: nc.PrivateIPs,
}
updateFail(r, &ctx, obj, &err, r.Client, state)
return common.ResultRequeueAfter10sec, err
Expand All @@ -137,7 +137,7 @@ func (r *NetworkInfoReconciler) Reconcile(ctx context.Context, req ctrl.Request)
VPCPath: *createdVpc.Path,
DefaultSNATIP: snatIP,
LoadBalancerIPAddresses: cidr,
PrivateIPv4CIDRs: nc.PrivateIPv4CIDRs,
PrivateIPs: nc.PrivateIPs,
}
updateSuccess(r, &ctx, obj, r.Client, state, nc.Name, path)
} else {
Expand Down
20 changes: 10 additions & 10 deletions pkg/controllers/networkinfo/vpcnetworkconfig_handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,16 +106,16 @@ func buildNetworkConfigInfo(vpcConfigCR v1alpha1.VPCNetworkConfiguration) (*comm
}

ninfo := &commontypes.VPCNetworkConfigInfo{
IsDefault: isDefaultNetworkConfigCR(vpcConfigCR),
Org: org,
Name: vpcConfigCR.Name,
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,
IsDefault: isDefaultNetworkConfigCR(vpcConfigCR),
Org: org,
Name: vpcConfigCR.Name,
VPCConnectivityProfile: vpcConfigCR.Spec.VPCConnectivityProfile,
LbServiceSize: vpcConfigCR.Spec.LbServiceSize,
NsxtProject: project,
PrivateIPs: vpcConfigCR.Spec.PrivateIPs,
DefaultSubnetSize: vpcConfigCR.Spec.DefaultSubnetSize,
PodSubnetAccessMode: vpcConfigCR.Spec.PodSubnetAccessMode,
ShortID: vpcConfigCR.Spec.ShortID,
}
return ninfo, nil
}
Expand Down
Loading

0 comments on commit 99bdeda

Please sign in to comment.