diff --git a/api/v1beta1/zz_generated.conversion.go b/api/v1beta1/zz_generated.conversion.go index 85cbe2a6b..928ade768 100644 --- a/api/v1beta1/zz_generated.conversion.go +++ b/api/v1beta1/zz_generated.conversion.go @@ -1298,7 +1298,9 @@ func autoConvert_v1beta2_IBMVPCClusterStatus_To_v1beta1_IBMVPCClusterStatus(in * if err := Convert_v1beta2_VPC_To_v1beta1_VPC(&in.VPC, &out.VPC, s); err != nil { return err } + // WARNING: in.Network requires manual conversion: does not exist in peer-type out.Ready = in.Ready + // WARNING: in.ResourceGroup requires manual conversion: does not exist in peer-type if err := Convert_v1beta2_Subnet_To_v1beta1_Subnet(&in.Subnet, &out.Subnet, s); err != nil { return err } diff --git a/api/v1beta2/ibmvpccluster_types.go b/api/v1beta2/ibmvpccluster_types.go index 322cb44c6..4cad55e20 100644 --- a/api/v1beta2/ibmvpccluster_types.go +++ b/api/v1beta2/ibmvpccluster_types.go @@ -98,7 +98,7 @@ type AdditionalListenerSpec struct { Port int64 `json:"port"` } -// VPCNetworkSpec defines the desired state of the network resources for the cluster. +// VPCNetworkSpec defines the desired state of the network resources for the cluster for extended VPC Infrastructure support. type VPCNetworkSpec struct { // workerSubnets is a set of Subnet's which define the Worker subnets. // +optional @@ -113,7 +113,11 @@ type VPCNetworkSpec struct { // +optional ResourceGroup *string `json:"resourceGroup,omitempty"` - // TODO(cjschaef): Complete spec definition (SecurityGroups, VPC) + // vpc defines the IBM Cloud VPC for extended VPC Infrastructure support. + // +optional + VPC *VPCResource `json:"vpc,omitempty"` + + // TODO(cjschaef): Complete spec definition (SecurityGroups, etc.) } // VPCSecurityGroupStatus defines a vpc security group resource status with its id and respective rule's ids. @@ -146,11 +150,22 @@ type VPCLoadBalancerStatus struct { type IBMVPCClusterStatus struct { // INSERT ADDITIONAL STATUS FIELD - define observed state of cluster // Important: Run "make" to regenerate code after modifying this file + // dep: rely on Network instead. VPC VPC `json:"vpc,omitempty"` + // network is the status of the VPC network resources for extended VPC Infrastructure support. + // +optional + Network *VPCNetworkStatus `json:"network,omitempty"` + // Ready is true when the provider resource is ready. // +optional - Ready bool `json:"ready"` + // +kubebuilder:default=false + Ready bool `json:"ready"` + + // resourceGroup is the status of the cluster's Resource Group for extended VPC Infrastructure support. + // +optional + ResourceGroup *ResourceStatus `json:"resourceGroup,omitempty"` + Subnet Subnet `json:"subnet,omitempty"` VPCEndpoint VPCEndpoint `json:"vpcEndpoint,omitempty"` @@ -163,6 +178,18 @@ type IBMVPCClusterStatus struct { Conditions capiv1beta1.Conditions `json:"conditions,omitempty"` } +// VPCNetworkStatus provides details on the status of VPC network resources for extended VPC Infrastructure support. +type VPCNetworkStatus struct { + // resourceGroup references the Resource Group for Network resources for the cluster. + // This can be the same or unique from the cluster's Resource Group. + // +optional + ResourceGroup *ResourceStatus `json:"resourceGroup,omitempty"` + + // vpc references the status of the IBM Cloud VPC as part of the extended VPC Infrastructure support. + // +optional + VPC *ResourceStatus `json:"vpc,omitempty"` +} + // VPC holds the VPC information. type VPC struct { ID string `json:"id"` diff --git a/api/v1beta2/types.go b/api/v1beta2/types.go index 8ea0fd817..0507cf27d 100644 --- a/api/v1beta2/types.go +++ b/api/v1beta2/types.go @@ -400,3 +400,42 @@ type VPCEndpoint struct { // +optional LBID *string `json:"loadBalancerIPID,omitempty"` } + +// ResourceStatus identifies a resource by id (and name) and whether it is ready. +type ResourceStatus struct { + // id defines the Id of the IBM Cloud resource status. + // +required + ID string `json:"id"` + + // name defines the name of the IBM Cloud resource status. + // +optional + Name *string `json:"name,omitempty"` + + // ready defines whether the IBM Cloud resource is ready. + // +required + Ready bool `json:"ready"` +} + +// Set sets the ResourceStatus fields. +func (s *ResourceStatus) Set(resource ResourceStatus) { + s.ID = resource.ID + // Set the name if it hasn't been, or the incoming name won't remove it (nil). + if s.Name == nil && resource.Name != nil { + s.Name = resource.Name + } + s.Ready = resource.Ready +} + +// VPCResource represents a VPC resource. +// +kubebuilder:validation:XValidation:rule="has(self.id) || has(self.name)",message="an id or name must be provided" +type VPCResource struct { + // id of the resource. + // +kubebuilder:validation:MinLength=1 + // +optional + ID *string `json:"id,omitempty"` + + // name of the resource. + // +kubebuilder:validation:MinLength=1 + // +optional + Name *string `json:"name,omitempty"` +} diff --git a/api/v1beta2/zz_generated.deepcopy.go b/api/v1beta2/zz_generated.deepcopy.go index 134bd9099..c6a2b3589 100644 --- a/api/v1beta2/zz_generated.deepcopy.go +++ b/api/v1beta2/zz_generated.deepcopy.go @@ -894,6 +894,16 @@ func (in *IBMVPCClusterSpec) DeepCopy() *IBMVPCClusterSpec { func (in *IBMVPCClusterStatus) DeepCopyInto(out *IBMVPCClusterStatus) { *out = *in out.VPC = in.VPC + if in.Network != nil { + in, out := &in.Network, &out.Network + *out = new(VPCNetworkStatus) + (*in).DeepCopyInto(*out) + } + if in.ResourceGroup != nil { + in, out := &in.ResourceGroup, &out.ResourceGroup + *out = new(ResourceStatus) + (*in).DeepCopyInto(*out) + } in.Subnet.DeepCopyInto(&out.Subnet) in.VPCEndpoint.DeepCopyInto(&out.VPCEndpoint) if in.Conditions != nil { @@ -1320,6 +1330,26 @@ func (in *ResourceReference) DeepCopy() *ResourceReference { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *ResourceStatus) DeepCopyInto(out *ResourceStatus) { + *out = *in + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new ResourceStatus. +func (in *ResourceStatus) DeepCopy() *ResourceStatus { + if in == nil { + return nil + } + out := new(ResourceStatus) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *Subnet) DeepCopyInto(out *Subnet) { *out = *in @@ -1512,6 +1542,11 @@ func (in *VPCNetworkSpec) DeepCopyInto(out *VPCNetworkSpec) { *out = new(string) **out = **in } + if in.VPC != nil { + in, out := &in.VPC, &out.VPC + *out = new(VPCResource) + (*in).DeepCopyInto(*out) + } } // DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VPCNetworkSpec. @@ -1524,6 +1559,56 @@ func (in *VPCNetworkSpec) DeepCopy() *VPCNetworkSpec { return out } +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VPCNetworkStatus) DeepCopyInto(out *VPCNetworkStatus) { + *out = *in + if in.ResourceGroup != nil { + in, out := &in.ResourceGroup, &out.ResourceGroup + *out = new(ResourceStatus) + (*in).DeepCopyInto(*out) + } + if in.VPC != nil { + in, out := &in.VPC, &out.VPC + *out = new(ResourceStatus) + (*in).DeepCopyInto(*out) + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VPCNetworkStatus. +func (in *VPCNetworkStatus) DeepCopy() *VPCNetworkStatus { + if in == nil { + return nil + } + out := new(VPCNetworkStatus) + in.DeepCopyInto(out) + return out +} + +// DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. +func (in *VPCResource) DeepCopyInto(out *VPCResource) { + *out = *in + if in.ID != nil { + in, out := &in.ID, &out.ID + *out = new(string) + **out = **in + } + if in.Name != nil { + in, out := &in.Name, &out.Name + *out = new(string) + **out = **in + } +} + +// DeepCopy is an autogenerated deepcopy function, copying the receiver, creating a new VPCResource. +func (in *VPCResource) DeepCopy() *VPCResource { + if in == nil { + return nil + } + out := new(VPCResource) + in.DeepCopyInto(out) + return out +} + // DeepCopyInto is an autogenerated deepcopy function, copying the receiver, writing into out. in must be non-nil. func (in *VPCResourceReference) DeepCopyInto(out *VPCResourceReference) { *out = *in diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_ibmvpcclusters.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_ibmvpcclusters.yaml index f4b2d9840..d487dc7ff 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_ibmvpcclusters.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_ibmvpcclusters.yaml @@ -320,6 +320,22 @@ spec: resourceGroup is the name of the Resource Group containing all of the newtork resources. This can be different than the Resource Group containing the remaining cluster resources. type: string + vpc: + description: vpc defines the IBM Cloud VPC for extended VPC Infrastructure + support. + properties: + id: + description: id of the resource. + minLength: 1 + type: string + name: + description: name of the resource. + minLength: 1 + type: string + type: object + x-kubernetes-validations: + - message: an id or name must be provided + rule: has(self.id) || has(self.name) workerSubnets: description: workerSubnets is a set of Subnet's which define the Worker subnets. @@ -413,9 +429,71 @@ spec: description: ControlPlaneLoadBalancerState is the status of the load balancer. type: string + network: + description: network is the status of the VPC network resources for + extended VPC Infrastructure support. + properties: + resourceGroup: + description: |- + resourceGroup references the Resource Group for Network resources for the cluster. + This can be the same or unique from the cluster's Resource Group. + properties: + id: + description: id defines the Id of the IBM Cloud resource status. + type: string + name: + description: name defines the name of the IBM Cloud resource + status. + type: string + ready: + description: ready defines whether the IBM Cloud resource + is ready. + type: boolean + required: + - id + - ready + type: object + vpc: + description: vpc references the status of the IBM Cloud VPC as + part of the extended VPC Infrastructure support. + properties: + id: + description: id defines the Id of the IBM Cloud resource status. + type: string + name: + description: name defines the name of the IBM Cloud resource + status. + type: string + ready: + description: ready defines whether the IBM Cloud resource + is ready. + type: boolean + required: + - id + - ready + type: object + type: object ready: + default: false description: Ready is true when the provider resource is ready. type: boolean + resourceGroup: + description: resourceGroup is the status of the cluster's Resource + Group for extended VPC Infrastructure support. + properties: + id: + description: id defines the Id of the IBM Cloud resource status. + type: string + name: + description: name defines the name of the IBM Cloud resource status. + type: string + ready: + description: ready defines whether the IBM Cloud resource is ready. + type: boolean + required: + - id + - ready + type: object subnet: description: Subnet describes a subnet. properties: @@ -438,6 +516,7 @@ spec: description: |- INSERT ADDITIONAL STATUS FIELD - define observed state of cluster Important: Run "make" to regenerate code after modifying this file + dep: rely on Network instead. properties: id: type: string diff --git a/config/crd/bases/infrastructure.cluster.x-k8s.io_ibmvpcclustertemplates.yaml b/config/crd/bases/infrastructure.cluster.x-k8s.io_ibmvpcclustertemplates.yaml index 82890dc15..f75f70bf3 100644 --- a/config/crd/bases/infrastructure.cluster.x-k8s.io_ibmvpcclustertemplates.yaml +++ b/config/crd/bases/infrastructure.cluster.x-k8s.io_ibmvpcclustertemplates.yaml @@ -170,6 +170,22 @@ spec: resourceGroup is the name of the Resource Group containing all of the newtork resources. This can be different than the Resource Group containing the remaining cluster resources. type: string + vpc: + description: vpc defines the IBM Cloud VPC for extended + VPC Infrastructure support. + properties: + id: + description: id of the resource. + minLength: 1 + type: string + name: + description: name of the resource. + minLength: 1 + type: string + type: object + x-kubernetes-validations: + - message: an id or name must be provided + rule: has(self.id) || has(self.name) workerSubnets: description: workerSubnets is a set of Subnet's which define the Worker subnets.