Skip to content

Commit

Permalink
LoadBalancer integration for VPC (#817)
Browse files Browse the repository at this point in the history
Signed-off-by: Prajyot-Parab <[email protected]>

Signed-off-by: Prajyot-Parab <[email protected]>
  • Loading branch information
Prajyot-Parab authored Aug 29, 2022
1 parent a452a66 commit 913cc48
Show file tree
Hide file tree
Showing 18 changed files with 726 additions and 87 deletions.
18 changes: 18 additions & 0 deletions api/v1alpha3/conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -104,3 +104,21 @@ func (dst *IBMVPCMachineTemplateList) ConvertFrom(srcRaw conversion.Hub) error {

return Convert_v1beta1_IBMVPCMachineTemplateList_To_v1alpha3_IBMVPCMachineTemplateList(src, dst, nil)
}

// Convert_v1beta1_IBMVPCClusterSpec_To_v1alpha3_IBMVPCClusterSpec is an autogenerated conversion function.
// Requires manual conversion as ControlPlaneLoadBalancer does not exist in v1alpha4 version of IBMVPCClusterSpec.
func Convert_v1beta1_IBMVPCClusterSpec_To_v1alpha3_IBMVPCClusterSpec(in *infrav1beta1.IBMVPCClusterSpec, out *IBMVPCClusterSpec, s apiconversion.Scope) error {
return autoConvert_v1beta1_IBMVPCClusterSpec_To_v1alpha3_IBMVPCClusterSpec(in, out, s)
}

// Convert_v1beta1_IBMVPCClusterStatus_To_v1alpha3_IBMVPCClusterStatus is an autogenerated conversion function.
// Requires manual conversion as ControlPlaneLoadBalancerState and Conditions does not exist in v1alpha4 version of IBMVPCClusterStatus.
func Convert_v1beta1_IBMVPCClusterStatus_To_v1alpha3_IBMVPCClusterStatus(in *infrav1beta1.IBMVPCClusterStatus, out *IBMVPCClusterStatus, s apiconversion.Scope) error {
return autoConvert_v1beta1_IBMVPCClusterStatus_To_v1alpha3_IBMVPCClusterStatus(in, out, s)
}

// Convert_v1beta1_VPCEndpoint_To_v1alpha3_VPCEndpoint is an autogenerated conversion function.
// Requires manual conversion as LBID does not exist in v1alpha4 version of VPCEndpoint.
func Convert_v1beta1_VPCEndpoint_To_v1alpha3_VPCEndpoint(in *infrav1beta1.VPCEndpoint, out *VPCEndpoint, s apiconversion.Scope) error {
return autoConvert_v1beta1_VPCEndpoint_To_v1alpha3_VPCEndpoint(in, out, s)
}
49 changes: 19 additions & 30 deletions api/v1alpha3/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

19 changes: 19 additions & 0 deletions api/v1alpha4/ibmvpc_conversion.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ limitations under the License.
package v1alpha4

import (
apiconversion "k8s.io/apimachinery/pkg/conversion"
"sigs.k8s.io/controller-runtime/pkg/conversion"

infrav1beta1 "sigs.k8s.io/cluster-api-provider-ibmcloud/api/v1beta1"
Expand Down Expand Up @@ -93,3 +94,21 @@ func (dst *IBMVPCMachineTemplateList) ConvertFrom(srcRaw conversion.Hub) error {

return Convert_v1beta1_IBMVPCMachineTemplateList_To_v1alpha4_IBMVPCMachineTemplateList(src, dst, nil)
}

// Convert_v1beta1_IBMVPCClusterSpec_To_v1alpha4_IBMVPCClusterSpec is an autogenerated conversion function.
// Requires manual conversion as ControlPlaneLoadBalancer does not exist in v1alpha4 version of IBMVPCClusterSpec.
func Convert_v1beta1_IBMVPCClusterSpec_To_v1alpha4_IBMVPCClusterSpec(in *infrav1beta1.IBMVPCClusterSpec, out *IBMVPCClusterSpec, s apiconversion.Scope) error {
return autoConvert_v1beta1_IBMVPCClusterSpec_To_v1alpha4_IBMVPCClusterSpec(in, out, s)
}

// Convert_v1beta1_IBMVPCClusterStatus_To_v1alpha4_IBMVPCClusterStatus is an autogenerated conversion function.
// Requires manual conversion as ControlPlaneLoadBalancerState and Conditions does not exist in v1alpha4 version of IBMVPCClusterStatus.
func Convert_v1beta1_IBMVPCClusterStatus_To_v1alpha4_IBMVPCClusterStatus(in *infrav1beta1.IBMVPCClusterStatus, out *IBMVPCClusterStatus, s apiconversion.Scope) error {
return autoConvert_v1beta1_IBMVPCClusterStatus_To_v1alpha4_IBMVPCClusterStatus(in, out, s)
}

// Convert_v1beta1_VPCEndpoint_To_v1alpha4_VPCEndpoint is an autogenerated conversion function.
// Requires manual conversion as LBID does not exist in v1alpha4 version of VPCEndpoint.
func Convert_v1beta1_VPCEndpoint_To_v1alpha4_VPCEndpoint(in *infrav1beta1.VPCEndpoint, out *VPCEndpoint, s apiconversion.Scope) error {
return autoConvert_v1beta1_VPCEndpoint_To_v1alpha4_VPCEndpoint(in, out, s)
}
49 changes: 19 additions & 30 deletions api/v1alpha4/zz_generated.conversion.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 10 additions & 0 deletions api/v1beta1/conditions_consts.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,3 +65,13 @@ const (
// ImageImportedCondition reports on current status of the image import job. Ready indicates the import job is finished.
ImageImportedCondition capiv1beta1.ConditionType = "ImageImported"
)

const (
// LoadBalancerNotReadyReason used when cluster is waiting for load balancer to be ready before proceeding.
LoadBalancerNotReadyReason = "LoadBalancerNotReady"
)

const (
// LoadBalancerReadyCondition reports on current status of the load balancer. Ready indicates the load balancer is in a active state.
LoadBalancerReadyCondition capiv1beta1.ConditionType = "LoadBalancerReady"
)
35 changes: 34 additions & 1 deletion api/v1beta1/ibmvpccluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -49,17 +49,40 @@ type IBMVPCClusterSpec struct {
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
// +optional
ControlPlaneEndpoint capiv1beta1.APIEndpoint `json:"controlPlaneEndpoint"`

// ControlPlaneLoadBalancer is optional configuration for customizing control plane behavior.
// +optional
ControlPlaneLoadBalancer *VPCLoadBalancerSpec `json:"controlPlaneLoadBalancer,omitempty"`
}

// VPCLoadBalancerSpec defines the desired state of an VPC load balancer.
type VPCLoadBalancerSpec struct {
// Name sets the name of the VPC load balancer.
// +kubebuilder:validation:MaxLength:=64
// +kubebuilder:validation:Pattern=`^[A-Za-z0-9]([A-Za-z0-9]{0,31}|[-A-Za-z0-9]{0,30}[A-Za-z0-9])$`
// +optional
Name string `json:"name,omitempty"`
}

// IBMVPCClusterStatus defines the observed state of IBMVPCCluster.
type IBMVPCClusterStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
VPC VPC `json:"vpc,omitempty"`
// Bastion Instance `json:"bastion,omitempty"`

// Ready is true when the provider resource is ready.
// +optional
Ready bool `json:"ready"`
Subnet Subnet `json:"subnet,omitempty"`
VPCEndpoint VPCEndpoint `json:"vpcEndpoint,omitempty"`

// ControlPlaneLoadBalancerState is the status of the load balancer.
// +optional
ControlPlaneLoadBalancerState VPCLoadBalancerState `json:"controlPlaneLoadBalancerState,omitempty"`

// Conditions defines current service state of the load balancer.
// +optional
Conditions capiv1beta1.Conditions `json:"conditions,omitempty"`
}

// VPC holds the VPC information.
Expand Down Expand Up @@ -96,3 +119,13 @@ type IBMVPCClusterList struct {
func init() {
SchemeBuilder.Register(&IBMVPCCluster{}, &IBMVPCClusterList{})
}

// GetConditions returns the observations of the operational state of the IBMVPCCluster resource.
func (r *IBMVPCCluster) GetConditions() capiv1beta1.Conditions {
return r.Status.Conditions
}

// SetConditions sets the underlying service state of the IBMVPCCluster to the predescribed clusterv1.Conditions.
func (r *IBMVPCCluster) SetConditions(conditions capiv1beta1.Conditions) {
r.Status.Conditions = conditions
}
2 changes: 2 additions & 0 deletions api/v1beta1/ibmvpcmachine_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,8 @@ type IBMVPCMachineStatus struct {

InstanceID string `json:"instanceID,omitempty"`

// Ready is true when the provider resource is ready.
// +optional
Ready bool `json:"ready"`

// Addresses contains the GCP instance associated addresses.
Expand Down
19 changes: 18 additions & 1 deletion api/v1beta1/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ var (
PowerVSImageStateImporting = PowerVSImageState("importing")
)

// VPCLoadBalancerState describes the state of the load balancer.
type VPCLoadBalancerState string

var (
// VPCLoadBalancerStateActive is the string representing the load balancer in a active state.
VPCLoadBalancerStateActive = VPCLoadBalancerState("active")

// VPCLoadBalancerStateCreatePending is the string representing the load balancer in a queued state.
VPCLoadBalancerStateCreatePending = VPCLoadBalancerState("create_pending")

// VPCLoadBalancerStateDeletePending is the string representing the load balancer in a failed state.
VPCLoadBalancerStateDeletePending = VPCLoadBalancerState("delete_pending")
)

// DeletePolicy defines the policy used to identify images to be preserved.
type DeletePolicy string

Expand All @@ -78,5 +92,8 @@ type Subnet struct {
// VPCEndpoint describes a VPCEndpoint.
type VPCEndpoint struct {
Address *string `json:"address"`
FIPID *string `json:"floatingIPID"`
// +optional
FIPID *string `json:"floatingIPID,omitempty"`
// +optional
LBID *string `json:"loadBalancerIPID,omitempty"`
}
Loading

0 comments on commit 913cc48

Please sign in to comment.