Skip to content

Commit

Permalink
Merge pull request #552 from lxiaopei/topic/lxiaopei/networkinfo
Browse files Browse the repository at this point in the history
Add NetworkInfo CR
  • Loading branch information
lxiaopei committed Apr 24, 2024
2 parents 778eb97 + 1f58e05 commit 7aa926b
Show file tree
Hide file tree
Showing 18 changed files with 876 additions and 42 deletions.
67 changes: 67 additions & 0 deletions build/yaml/crd/nsx.vmware.com_networkinfoes.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
---
apiVersion: apiextensions.k8s.io/v1
kind: CustomResourceDefinition
metadata:
annotations:
controller-gen.kubebuilder.io/version: v0.11.0
creationTimestamp: null
name: networkinfoes.nsx.vmware.com
spec:
group: nsx.vmware.com
names:
kind: NetworkInfo
listKind: NetworkInfoList
plural: networkinfoes
singular: networkinfo
scope: Namespaced
versions:
- name: v1alpha1
schema:
openAPIV3Schema:
description: NetworkInfo is used to report the network information for a namespace.
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'
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'
type: string
metadata:
type: object
vpcs:
items:
description: VPCState defines information for VPC.
properties:
defaultSNATIP:
description: Default SNAT IP for Private Subnets.
type: string
loadBalancerIPAddresses:
description: LoadBalancerIPAddresses (AVI SE Subnet CIDR or NSX
LB SNAT IPs).
type: string
name:
description: VPC name.
type: string
privateIPv4CIDRs:
description: Private CIDRs used for the VPC.
items:
type: string
type: array
vpcPath:
description: NSX Policy path for VPC.
type: string
required:
- defaultSNATIP
- name
- vpcPath
type: object
type: array
required:
- vpcs
type: object
served: true
storage: true
36 changes: 11 additions & 25 deletions build/yaml/crd/nsx.vmware.com_vpcnetworkconfigurations.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -91,45 +91,31 @@ spec:
type: array
shortID:
description: ShortID specifies Identifier to use when displaying VPC
context in logs. Less than equal to 8 characters.
context in logs. Less than or equal to 8 characters.
maxLength: 8
type: string
type: object
status:
description: VPCNetworkConfigurationStatus defines the observed state
of VPCNetworkConfiguration
properties:
conditions:
description: Conditions describes current state of VPCNetworkConfiguration.
vpcs:
description: VPCs describes VPC info, now it includes lb Subnet info
which are needed for AKO.
items:
description: Condition defines condition of custom resource.
description: VPCInfo defines VPC info needed by tenant admin.
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.
format: date-time
lbSubnetPath:
description: AVISESubnetPath is the NSX Policy Path for the
AVI SE Subnet.
type: string
message:
description: Message shows a human-readable message about condition.
type: string
reason:
description: Reason shows a brief reason of condition.
type: string
status:
description: Status of the condition, one of True, False, Unknown.
type: string
type:
description: Type defines condition type.
name:
description: VPC name.
type: string
required:
- status
- type
- name
type: object
type: array
required:
- conditions
type: object
type: object
served: true
Expand Down
47 changes: 47 additions & 0 deletions pkg/apis/nsx.vmware.com/v1alpha1/networkinfo_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* Copyright © 2024 VMware, Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0 */

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

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

// NetworkInfo is used to report the network information for a namespace.
type NetworkInfo struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

VPCs []VPCState `json:"vpcs"`
}

//+kubebuilder:object:root=true

// NetworkInfoList contains a list of NetworkInfo.
type NetworkInfoList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NetworkInfo `json:"items"`
}

// VPCState defines information for VPC.
type VPCState struct {
// VPC name.
Name string `json:"name"`
// NSX Policy path for VPC.
VPCPath string `json:"vpcPath"`
// Default SNAT IP for Private Subnets.
DefaultSNATIP string `json:"defaultSNATIP"`
// 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"`
}

func init() {
SchemeBuilder.Register(&NetworkInfo{}, &NetworkInfoList{})
}
17 changes: 15 additions & 2 deletions pkg/apis/nsx.vmware.com/v1alpha1/vpcnetworkconfiguration_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,12 +41,25 @@ type VPCNetworkConfigurationSpec struct {
// 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"`
}

// VPCNetworkConfigurationStatus defines the observed state of VPCNetworkConfiguration
type VPCNetworkConfigurationStatus struct {
// Conditions describes current state of VPCNetworkConfiguration.
Conditions []Condition `json:"conditions"`
// VPCs describes VPC info, now it includes lb Subnet info which are needed for AKO.
VPCs []VPCInfo `json:"vpcs,omitempty"`
}

// VPCInfo defines VPC info needed by tenant admin.
type VPCInfo struct {
// VPC name.
Name string `json:"name"`
// AVISESubnetPath is the NSX Policy Path for the AVI SE Subnet.
AVISESubnetPath string `json:"lbSubnetPath,omitempty"`
}

// +genclient
Expand Down
109 changes: 103 additions & 6 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.

47 changes: 47 additions & 0 deletions pkg/apis/v1alpha1/networkinfo_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
/* Copyright © 2024 VMware, Inc. All Rights Reserved.
SPDX-License-Identifier: Apache-2.0 */

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

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

// NetworkInfo is used to report the network information for a namespace.
type NetworkInfo struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

VPCs []VPCState `json:"vpcs"`
}

//+kubebuilder:object:root=true

// NetworkInfoList contains a list of NetworkInfo.
type NetworkInfoList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []NetworkInfo `json:"items"`
}

// VPCState defines information for VPC.
type VPCState struct {
// VPC name.
Name string `json:"name"`
// NSX Policy path for VPC.
VPCPath string `json:"vpcPath"`
// Default SNAT IP for Private Subnets.
DefaultSNATIP string `json:"defaultSNATIP"`
// 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"`
}

func init() {
SchemeBuilder.Register(&NetworkInfo{}, &NetworkInfoList{})
}
Loading

0 comments on commit 7aa926b

Please sign in to comment.