Skip to content

Commit 913cc48

Browse files
LoadBalancer integration for VPC (#817)
Signed-off-by: Prajyot-Parab <[email protected]> Signed-off-by: Prajyot-Parab <[email protected]>
1 parent a452a66 commit 913cc48

18 files changed

+726
-87
lines changed

api/v1alpha3/conversion.go

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,3 +104,21 @@ func (dst *IBMVPCMachineTemplateList) ConvertFrom(srcRaw conversion.Hub) error {
104104

105105
return Convert_v1beta1_IBMVPCMachineTemplateList_To_v1alpha3_IBMVPCMachineTemplateList(src, dst, nil)
106106
}
107+
108+
// Convert_v1beta1_IBMVPCClusterSpec_To_v1alpha3_IBMVPCClusterSpec is an autogenerated conversion function.
109+
// Requires manual conversion as ControlPlaneLoadBalancer does not exist in v1alpha4 version of IBMVPCClusterSpec.
110+
func Convert_v1beta1_IBMVPCClusterSpec_To_v1alpha3_IBMVPCClusterSpec(in *infrav1beta1.IBMVPCClusterSpec, out *IBMVPCClusterSpec, s apiconversion.Scope) error {
111+
return autoConvert_v1beta1_IBMVPCClusterSpec_To_v1alpha3_IBMVPCClusterSpec(in, out, s)
112+
}
113+
114+
// Convert_v1beta1_IBMVPCClusterStatus_To_v1alpha3_IBMVPCClusterStatus is an autogenerated conversion function.
115+
// Requires manual conversion as ControlPlaneLoadBalancerState and Conditions does not exist in v1alpha4 version of IBMVPCClusterStatus.
116+
func Convert_v1beta1_IBMVPCClusterStatus_To_v1alpha3_IBMVPCClusterStatus(in *infrav1beta1.IBMVPCClusterStatus, out *IBMVPCClusterStatus, s apiconversion.Scope) error {
117+
return autoConvert_v1beta1_IBMVPCClusterStatus_To_v1alpha3_IBMVPCClusterStatus(in, out, s)
118+
}
119+
120+
// Convert_v1beta1_VPCEndpoint_To_v1alpha3_VPCEndpoint is an autogenerated conversion function.
121+
// Requires manual conversion as LBID does not exist in v1alpha4 version of VPCEndpoint.
122+
func Convert_v1beta1_VPCEndpoint_To_v1alpha3_VPCEndpoint(in *infrav1beta1.VPCEndpoint, out *VPCEndpoint, s apiconversion.Scope) error {
123+
return autoConvert_v1beta1_VPCEndpoint_To_v1alpha3_VPCEndpoint(in, out, s)
124+
}

api/v1alpha3/zz_generated.conversion.go

Lines changed: 19 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1alpha4/ibmvpc_conversion.go

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ limitations under the License.
1717
package v1alpha4
1818

1919
import (
20+
apiconversion "k8s.io/apimachinery/pkg/conversion"
2021
"sigs.k8s.io/controller-runtime/pkg/conversion"
2122

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

9495
return Convert_v1beta1_IBMVPCMachineTemplateList_To_v1alpha4_IBMVPCMachineTemplateList(src, dst, nil)
9596
}
97+
98+
// Convert_v1beta1_IBMVPCClusterSpec_To_v1alpha4_IBMVPCClusterSpec is an autogenerated conversion function.
99+
// Requires manual conversion as ControlPlaneLoadBalancer does not exist in v1alpha4 version of IBMVPCClusterSpec.
100+
func Convert_v1beta1_IBMVPCClusterSpec_To_v1alpha4_IBMVPCClusterSpec(in *infrav1beta1.IBMVPCClusterSpec, out *IBMVPCClusterSpec, s apiconversion.Scope) error {
101+
return autoConvert_v1beta1_IBMVPCClusterSpec_To_v1alpha4_IBMVPCClusterSpec(in, out, s)
102+
}
103+
104+
// Convert_v1beta1_IBMVPCClusterStatus_To_v1alpha4_IBMVPCClusterStatus is an autogenerated conversion function.
105+
// Requires manual conversion as ControlPlaneLoadBalancerState and Conditions does not exist in v1alpha4 version of IBMVPCClusterStatus.
106+
func Convert_v1beta1_IBMVPCClusterStatus_To_v1alpha4_IBMVPCClusterStatus(in *infrav1beta1.IBMVPCClusterStatus, out *IBMVPCClusterStatus, s apiconversion.Scope) error {
107+
return autoConvert_v1beta1_IBMVPCClusterStatus_To_v1alpha4_IBMVPCClusterStatus(in, out, s)
108+
}
109+
110+
// Convert_v1beta1_VPCEndpoint_To_v1alpha4_VPCEndpoint is an autogenerated conversion function.
111+
// Requires manual conversion as LBID does not exist in v1alpha4 version of VPCEndpoint.
112+
func Convert_v1beta1_VPCEndpoint_To_v1alpha4_VPCEndpoint(in *infrav1beta1.VPCEndpoint, out *VPCEndpoint, s apiconversion.Scope) error {
113+
return autoConvert_v1beta1_VPCEndpoint_To_v1alpha4_VPCEndpoint(in, out, s)
114+
}

api/v1alpha4/zz_generated.conversion.go

Lines changed: 19 additions & 30 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

api/v1beta1/conditions_consts.go

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,3 +65,13 @@ const (
6565
// ImageImportedCondition reports on current status of the image import job. Ready indicates the import job is finished.
6666
ImageImportedCondition capiv1beta1.ConditionType = "ImageImported"
6767
)
68+
69+
const (
70+
// LoadBalancerNotReadyReason used when cluster is waiting for load balancer to be ready before proceeding.
71+
LoadBalancerNotReadyReason = "LoadBalancerNotReady"
72+
)
73+
74+
const (
75+
// LoadBalancerReadyCondition reports on current status of the load balancer. Ready indicates the load balancer is in a active state.
76+
LoadBalancerReadyCondition capiv1beta1.ConditionType = "LoadBalancerReady"
77+
)

api/v1beta1/ibmvpccluster_types.go

Lines changed: 34 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,17 +49,40 @@ type IBMVPCClusterSpec struct {
4949
// ControlPlaneEndpoint represents the endpoint used to communicate with the control plane.
5050
// +optional
5151
ControlPlaneEndpoint capiv1beta1.APIEndpoint `json:"controlPlaneEndpoint"`
52+
53+
// ControlPlaneLoadBalancer is optional configuration for customizing control plane behavior.
54+
// +optional
55+
ControlPlaneLoadBalancer *VPCLoadBalancerSpec `json:"controlPlaneLoadBalancer,omitempty"`
56+
}
57+
58+
// VPCLoadBalancerSpec defines the desired state of an VPC load balancer.
59+
type VPCLoadBalancerSpec struct {
60+
// Name sets the name of the VPC load balancer.
61+
// +kubebuilder:validation:MaxLength:=64
62+
// +kubebuilder:validation:Pattern=`^[A-Za-z0-9]([A-Za-z0-9]{0,31}|[-A-Za-z0-9]{0,30}[A-Za-z0-9])$`
63+
// +optional
64+
Name string `json:"name,omitempty"`
5265
}
5366

5467
// IBMVPCClusterStatus defines the observed state of IBMVPCCluster.
5568
type IBMVPCClusterStatus struct {
5669
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
5770
// Important: Run "make" to regenerate code after modifying this file
5871
VPC VPC `json:"vpc,omitempty"`
59-
// Bastion Instance `json:"bastion,omitempty"`
72+
73+
// Ready is true when the provider resource is ready.
74+
// +optional
6075
Ready bool `json:"ready"`
6176
Subnet Subnet `json:"subnet,omitempty"`
6277
VPCEndpoint VPCEndpoint `json:"vpcEndpoint,omitempty"`
78+
79+
// ControlPlaneLoadBalancerState is the status of the load balancer.
80+
// +optional
81+
ControlPlaneLoadBalancerState VPCLoadBalancerState `json:"controlPlaneLoadBalancerState,omitempty"`
82+
83+
// Conditions defines current service state of the load balancer.
84+
// +optional
85+
Conditions capiv1beta1.Conditions `json:"conditions,omitempty"`
6386
}
6487

6588
// VPC holds the VPC information.
@@ -96,3 +119,13 @@ type IBMVPCClusterList struct {
96119
func init() {
97120
SchemeBuilder.Register(&IBMVPCCluster{}, &IBMVPCClusterList{})
98121
}
122+
123+
// GetConditions returns the observations of the operational state of the IBMVPCCluster resource.
124+
func (r *IBMVPCCluster) GetConditions() capiv1beta1.Conditions {
125+
return r.Status.Conditions
126+
}
127+
128+
// SetConditions sets the underlying service state of the IBMVPCCluster to the predescribed clusterv1.Conditions.
129+
func (r *IBMVPCCluster) SetConditions(conditions capiv1beta1.Conditions) {
130+
r.Status.Conditions = conditions
131+
}

api/v1beta1/ibmvpcmachine_types.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,8 @@ type IBMVPCMachineStatus struct {
6868

6969
InstanceID string `json:"instanceID,omitempty"`
7070

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

7375
// Addresses contains the GCP instance associated addresses.

api/v1beta1/types.go

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,20 @@ var (
5353
PowerVSImageStateImporting = PowerVSImageState("importing")
5454
)
5555

56+
// VPCLoadBalancerState describes the state of the load balancer.
57+
type VPCLoadBalancerState string
58+
59+
var (
60+
// VPCLoadBalancerStateActive is the string representing the load balancer in a active state.
61+
VPCLoadBalancerStateActive = VPCLoadBalancerState("active")
62+
63+
// VPCLoadBalancerStateCreatePending is the string representing the load balancer in a queued state.
64+
VPCLoadBalancerStateCreatePending = VPCLoadBalancerState("create_pending")
65+
66+
// VPCLoadBalancerStateDeletePending is the string representing the load balancer in a failed state.
67+
VPCLoadBalancerStateDeletePending = VPCLoadBalancerState("delete_pending")
68+
)
69+
5670
// DeletePolicy defines the policy used to identify images to be preserved.
5771
type DeletePolicy string
5872

@@ -78,5 +92,8 @@ type Subnet struct {
7892
// VPCEndpoint describes a VPCEndpoint.
7993
type VPCEndpoint struct {
8094
Address *string `json:"address"`
81-
FIPID *string `json:"floatingIPID"`
95+
// +optional
96+
FIPID *string `json:"floatingIPID,omitempty"`
97+
// +optional
98+
LBID *string `json:"loadBalancerIPID,omitempty"`
8299
}

0 commit comments

Comments
 (0)