Skip to content

Commit 681762d

Browse files
committed
Update docs/book/src/topics/network-load-balancer-with-awscluster.md
1 parent f0b6914 commit 681762d

21 files changed

+474
-475
lines changed

api/v1beta1/awscluster_conversion.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@ func (src *AWSCluster) ConvertTo(dstRaw conversion.Hub) error {
5353
func restoreControlPlaneLoadBalancerStatus(restored, dst *infrav1.LoadBalancer) {
5454
dst.ARN = restored.ARN
5555
dst.LoadBalancerType = restored.LoadBalancerType
56-
dst.V2Attributes = restored.V2Attributes
57-
dst.V2Listeners = restored.V2Listeners
56+
dst.ELBAttributes = restored.ELBAttributes
57+
dst.ELBListeners = restored.ELBListeners
5858
}
5959

6060
// restoreControlPlaneLoadBalancer manually restores the control plane loadbalancer data.

api/v1beta1/conversion.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ func Convert_v1beta2_NetworkStatus_To_v1beta1_NetworkStatus(in *v1beta2.NetworkS
4646
func Convert_v1beta1_ClassicELB_To_v1beta2_LoadBalancer(in *ClassicELB, out *v1beta2.LoadBalancer, s conversion.Scope) error {
4747
out.Name = in.Name
4848
out.DNSName = in.DNSName
49-
out.Scheme = v1beta2.ElbScheme(in.Scheme)
49+
out.Scheme = v1beta2.ELBScheme(in.Scheme)
5050
out.HealthCheck = (*v1beta2.ClassicELBHealthCheck)(in.HealthCheck)
5151
out.AvailabilityZones = in.AvailabilityZones
5252
out.ClassicElbAttributes = (v1beta2.ClassicELBAttributes)(in.Attributes)

api/v1beta1/zz_generated.conversion.go

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

api/v1beta2/awscluster_types.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,7 @@ type AWSLoadBalancerSpec struct {
176176
// +kubebuilder:default=internet-facing
177177
// +kubebuilder:validation:Enum=internet-facing;internal
178178
// +optional
179-
Scheme *ElbScheme `json:"scheme,omitempty"`
179+
Scheme *ELBScheme `json:"scheme,omitempty"`
180180

181181
// CrossZoneLoadBalancing enables the classic ELB cross availability zone balancing.
182182
//
@@ -194,9 +194,9 @@ type AWSLoadBalancerSpec struct {
194194
Subnets []string `json:"subnets,omitempty"`
195195

196196
// HealthCheckProtocol sets the protocol type for ELB health check target
197-
// default value is ElbProtocolSSL
197+
// default value is ELBProtocolSSL
198198
// +optional
199-
HealthCheckProtocol *ElbProtocol `json:"healthCheckProtocol,omitempty"`
199+
HealthCheckProtocol *ELBProtocol `json:"healthCheckProtocol,omitempty"`
200200

201201
// AdditionalSecurityGroups sets the security groups used by the load balancer. Expected to be security group IDs
202202
// This is optional - if not provided new security groups will be created for the load balancer

api/v1beta2/awscluster_webhook.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,7 @@ func (r *AWSCluster) ValidateUpdate(old runtime.Object) error {
9292
}
9393
if oldC.Spec.ControlPlaneLoadBalancer == nil {
9494
// If old scheme was nil, the only value accepted here is the default value: internet-facing
95-
if newLoadBalancer.Scheme != nil && newLoadBalancer.Scheme.String() != ElbSchemeInternetFacing.String() {
95+
if newLoadBalancer.Scheme != nil && newLoadBalancer.Scheme.String() != ELBSchemeInternetFacing.String() {
9696
allErrs = append(allErrs,
9797
field.Invalid(field.NewPath("spec", "controlPlaneLoadBalancer", "scheme"),
9898
r.Spec.ControlPlaneLoadBalancer.Scheme, "field is immutable, default value was set to internet-facing"),
@@ -117,7 +117,7 @@ func (r *AWSCluster) ValidateUpdate(old runtime.Object) error {
117117
}
118118
}
119119

120-
// Block the update for HealthCheckProtocol :
120+
// Block the update for Protocol :
121121
// - if it was not set in old spec but added in new spec
122122
// - if it was set in old spec but changed in new spec
123123
if !cmp.Equal(newLoadBalancer.HealthCheckProtocol, existingLoadBalancer.HealthCheckProtocol) {

api/v1beta2/awscluster_webhook_test.go

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ func TestAWSClusterDefault(t *testing.T) {
4242
}
4343

4444
func TestAWSCluster_ValidateCreate(t *testing.T) {
45-
unsupportedIncorrectScheme := ElbScheme("any-other-scheme")
45+
unsupportedIncorrectScheme := ELBScheme("any-other-scheme")
4646

4747
tests := []struct {
4848
name string
@@ -351,14 +351,14 @@ func TestAWSCluster_ValidateUpdate(t *testing.T) {
351351
oldCluster: &AWSCluster{
352352
Spec: AWSClusterSpec{
353353
ControlPlaneLoadBalancer: &AWSLoadBalancerSpec{
354-
Scheme: &ElbSchemeInternal,
354+
Scheme: &ELBSchemeInternal,
355355
},
356356
},
357357
},
358358
newCluster: &AWSCluster{
359359
Spec: AWSClusterSpec{
360360
ControlPlaneLoadBalancer: &AWSLoadBalancerSpec{
361-
Scheme: &ElbSchemeInternetFacing,
361+
Scheme: &ELBSchemeInternetFacing,
362362
},
363363
},
364364
},
@@ -372,7 +372,7 @@ func TestAWSCluster_ValidateUpdate(t *testing.T) {
372372
newCluster: &AWSCluster{
373373
Spec: AWSClusterSpec{
374374
ControlPlaneLoadBalancer: &AWSLoadBalancerSpec{
375-
Scheme: &ElbSchemeInternal,
375+
Scheme: &ELBSchemeInternal,
376376
},
377377
},
378378
},
@@ -386,7 +386,7 @@ func TestAWSCluster_ValidateUpdate(t *testing.T) {
386386
newCluster: &AWSCluster{
387387
Spec: AWSClusterSpec{
388388
ControlPlaneLoadBalancer: &AWSLoadBalancerSpec{
389-
Scheme: &ElbSchemeInternetFacing,
389+
Scheme: &ELBSchemeInternetFacing,
390390
},
391391
},
392392
},
@@ -526,14 +526,14 @@ func TestAWSCluster_ValidateUpdate(t *testing.T) {
526526
oldCluster: &AWSCluster{
527527
Spec: AWSClusterSpec{
528528
ControlPlaneLoadBalancer: &AWSLoadBalancerSpec{
529-
HealthCheckProtocol: &ElbProtocolTCP,
529+
HealthCheckProtocol: &ELBProtocolTCP,
530530
},
531531
},
532532
},
533533
newCluster: &AWSCluster{
534534
Spec: AWSClusterSpec{
535535
ControlPlaneLoadBalancer: &AWSLoadBalancerSpec{
536-
HealthCheckProtocol: &ElbProtocolSSL,
536+
HealthCheckProtocol: &ELBProtocolSSL,
537537
},
538538
},
539539
},
@@ -544,14 +544,14 @@ func TestAWSCluster_ValidateUpdate(t *testing.T) {
544544
oldCluster: &AWSCluster{
545545
Spec: AWSClusterSpec{
546546
ControlPlaneLoadBalancer: &AWSLoadBalancerSpec{
547-
HealthCheckProtocol: &ElbProtocolTCP,
547+
HealthCheckProtocol: &ELBProtocolTCP,
548548
},
549549
},
550550
},
551551
newCluster: &AWSCluster{
552552
Spec: AWSClusterSpec{
553553
ControlPlaneLoadBalancer: &AWSLoadBalancerSpec{
554-
HealthCheckProtocol: &ElbProtocolTCP,
554+
HealthCheckProtocol: &ELBProtocolTCP,
555555
},
556556
},
557557
},
@@ -565,7 +565,7 @@ func TestAWSCluster_ValidateUpdate(t *testing.T) {
565565
newCluster: &AWSCluster{
566566
Spec: AWSClusterSpec{
567567
ControlPlaneLoadBalancer: &AWSLoadBalancerSpec{
568-
HealthCheckProtocol: &ElbProtocolTCP,
568+
HealthCheckProtocol: &ELBProtocolTCP,
569569
},
570570
},
571571
},

api/v1beta2/defaults.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ func SetDefaults_AWSClusterSpec(s *AWSClusterSpec) { //nolint:golint,stylecheck
6363
}
6464
if s.ControlPlaneLoadBalancer == nil {
6565
s.ControlPlaneLoadBalancer = &AWSLoadBalancerSpec{
66-
Scheme: &ElbSchemeInternetFacing,
66+
Scheme: &ELBSchemeInternetFacing,
6767
LoadBalancerType: LoadBalancerTypeClassic,
6868
}
6969
}

api/v1beta2/network_types.go

Lines changed: 54 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,13 @@ import (
2222
"time"
2323
)
2424

25+
const (
26+
// DefaultAPIServerPort defines the API server port when defining a Load Balancer.
27+
DefaultAPIServerPort = 6443
28+
// DefaultAPIServerPortString defines the API server port as a string for convenience.
29+
DefaultAPIServerPortString = "6443"
30+
)
31+
2532
// NetworkStatus encapsulates AWS networking resources.
2633
type NetworkStatus struct {
2734
// SecurityGroups is a map from the role/kind of the security group to its unique name, if any.
@@ -31,57 +38,53 @@ type NetworkStatus struct {
3138
APIServerELB LoadBalancer `json:"apiServerElb,omitempty"`
3239
}
3340

34-
// ElbScheme defines the scheme of a load balancer.
35-
type ElbScheme string
41+
// ELBScheme defines the scheme of a load balancer.
42+
type ELBScheme string
3643

3744
var (
38-
// ElbSchemeInternetFacing defines an internet-facing, publicly
45+
// ELBSchemeInternetFacing defines an internet-facing, publicly
3946
// accessible AWS ELB scheme.
40-
ElbSchemeInternetFacing = ElbScheme("internet-facing")
47+
ELBSchemeInternetFacing = ELBScheme("internet-facing")
4148

42-
// ElbSchemeInternal defines an internal-only facing
49+
// ELBSchemeInternal defines an internal-only facing
4350
// load balancer internal to an ELB.
44-
ElbSchemeInternal = ElbScheme("internal")
51+
ELBSchemeInternal = ELBScheme("internal")
4552
)
4653

47-
func (e ElbScheme) String() string {
54+
func (e ELBScheme) String() string {
4855
return string(e)
4956
}
5057

51-
// ElbProtocol defines listener protocols for a load balancer.
52-
type ElbProtocol string
58+
// ELBProtocol defines listener protocols for a load balancer.
59+
type ELBProtocol string
5360

54-
func (e ElbProtocol) String() string {
61+
func (e ELBProtocol) String() string {
5562
return string(e)
5663
}
5764

5865
var (
59-
// ElbProtocolTCP defines the ELB API string representing the TCP protocol.
60-
ElbProtocolTCP = ElbProtocol("TCP")
61-
62-
// ElbProtocolSSL defines the ELB API string representing the TLS protocol.
63-
ElbProtocolSSL = ElbProtocol("SSL")
64-
65-
// ElbProtocolHTTP defines the ELB API string representing the HTTP protocol at L7.
66-
ElbProtocolHTTP = ElbProtocol("HTTP")
67-
68-
// ElbProtocolHTTPS defines the ELB API string representing the HTTP protocol at L7.
69-
ElbProtocolHTTPS = ElbProtocol("HTTPS")
70-
71-
// ElbProtocolTLS defines the NLB API string representing the TLS protocol.
72-
ElbProtocolTLS = ElbProtocol("TLS")
73-
// ElbProtocolUDP defines the NLB API string representing the UPD protocol.
74-
ElbProtocolUDP = ElbProtocol("UDP")
66+
// ELBProtocolTCP defines the ELB API string representing the TCP protocol.
67+
ELBProtocolTCP = ELBProtocol("TCP")
68+
// ELBProtocolSSL defines the ELB API string representing the TLS protocol.
69+
ELBProtocolSSL = ELBProtocol("SSL")
70+
// ELBProtocolHTTP defines the ELB API string representing the HTTP protocol at L7.
71+
ELBProtocolHTTP = ELBProtocol("HTTP")
72+
// ELBProtocolHTTPS defines the ELB API string representing the HTTP protocol at L7.
73+
ELBProtocolHTTPS = ELBProtocol("HTTPS")
74+
// ELBProtocolTLS defines the NLB API string representing the TLS protocol.
75+
ELBProtocolTLS = ELBProtocol("TLS")
76+
// ELBProtocolUDP defines the NLB API string representing the UPD protocol.
77+
ELBProtocolUDP = ELBProtocol("UDP")
7578
)
7679

7780
// TargetGroupHealthCheck defines health check settings for the target group.
7881
type TargetGroupHealthCheck struct {
79-
HealthCheckProtocol *string `json:"healthCheckProtocol,omitempty"`
80-
HealthCheckPath *string `json:"healthCheckPath,omitempty"`
81-
HealthCheckPort *string `json:"healthCheckPort,omitempty"`
82-
HealthCheckIntervalSeconds *int64 `json:"healthCheckIntervalSeconds,omitempty"`
83-
HealthCheckTimeoutSeconds *int64 `json:"healthCheckTimeoutSeconds,omitempty"`
84-
HealthyThresholdCount *int64 `json:"healthyThresholdCount,omitempty"`
82+
Protocol *string `json:"protocol,omitempty"`
83+
Path *string `json:"path,omitempty"`
84+
Port *string `json:"port,omitempty"`
85+
IntervalSeconds *int64 `json:"intervalSeconds,omitempty"`
86+
TimeoutSeconds *int64 `json:"timeoutSeconds,omitempty"`
87+
ThresholdCount *int64 `json:"thresholdCount,omitempty"`
8588
}
8689

8790
// TargetGroupAttribute defines attribute key values for V2 Load Balancer Attributes.
@@ -95,25 +98,28 @@ var (
9598
type LoadBalancerAttribute string
9699

97100
var (
98-
LoadBalancerAttributeEnableLoadBalancingCrossZone = "load_balancing.cross_zone.enabled"
99-
LoadBalancerAttributeIdleTimeTimeoutSeconds = "idle_timeout.timeout_seconds"
101+
LoadBalancerAttributeEnableLoadBalancingCrossZone = "load_balancing.cross_zone.enabled"
102+
LoadBalancerAttributeIdleTimeTimeoutSeconds = "idle_timeout.timeout_seconds"
103+
LoadBalancerAttributeIdleTimeDefaultTimeoutSecondsInSeconds = "60"
100104
)
101105

102106
// TargetGroupSpec specifies target group settings for a given listener.
103107
// This is created first, and the ARN is then passed to the listener.
104108
type TargetGroupSpec struct {
105-
Name *string `json:"name"`
106-
Port *int64 `json:"port"`
109+
// Name of the TargetGroup. Must be unique over the same group of listeners.
110+
Name string `json:"name"`
111+
// Port is the exposed port
112+
Port int64 `json:"port"`
107113
// +kubebuilder:validation:Enum=tcp;tls;upd
108-
Protocol ElbProtocol `json:"protocol"`
109-
VpcID *string `json:"vpcId"`
114+
Protocol ELBProtocol `json:"protocol"`
115+
VpcID string `json:"vpcId"`
110116
// HealthCheck is the elb health check associated with the load balancer.
111117
HealthCheck *TargetGroupHealthCheck `json:"targetGroupHealthCheck,omitempty"`
112118
}
113119

114120
// Listener defines an AWS network load balancer listener.
115121
type Listener struct {
116-
Protocol ElbProtocol `json:"protocol"`
122+
Protocol ELBProtocol `json:"protocol"`
117123
Port int64 `json:"port"`
118124
TargetGroup TargetGroupSpec `json:"targetGroup"`
119125
}
@@ -132,7 +138,7 @@ type LoadBalancer struct {
132138
DNSName string `json:"dnsName,omitempty"`
133139

134140
// Scheme is the load balancer scheme, either internet-facing or private.
135-
Scheme ElbScheme `json:"scheme,omitempty"`
141+
Scheme ELBScheme `json:"scheme,omitempty"`
136142

137143
// AvailabilityZones is an array of availability zones in the VPC attached to the load balancer.
138144
AvailabilityZones []string `json:"availabilityZones,omitempty"`
@@ -155,14 +161,14 @@ type LoadBalancer struct {
155161
// Tags is a map of tags associated with the load balancer.
156162
Tags map[string]string `json:"tags,omitempty"`
157163

158-
// V2Listeners is an array of listeners associated with the load balancer. There must be at least one.
159-
V2Listeners []Listener `json:"v2Listeners,omitempty"`
164+
// ELBListeners is an array of listeners associated with the load balancer. There must be at least one.
165+
ELBListeners []Listener `json:"elbListeners,omitempty"`
160166

161-
// V2Attributes defines extra attributes associated with v2 load balancers.
162-
V2Attributes map[string]*string `json:"v2Attributes,omitempty"`
167+
// ELBAttributes defines extra attributes associated with v2 load balancers.
168+
ELBAttributes map[string]*string `json:"elbAttributes,omitempty"`
163169

164-
// LoadBalancerType defines the type of the Load Balancer.
165-
// +kubebuilder:validation:Enum=classic;nlb;alb;elb
170+
// LoadBalancerType sets the type for a load balancer. The default type is classic.
171+
// +kubebuilder:validation:Enum:=classic;elb;alb;nlb
166172
LoadBalancerType LoadBalancerType `json:"loadBalancerType"`
167173
}
168174

@@ -189,9 +195,9 @@ type ClassicELBAttributes struct {
189195

190196
// ClassicELBListener defines an AWS classic load balancer listener.
191197
type ClassicELBListener struct {
192-
Protocol ElbProtocol `json:"protocol"`
198+
Protocol ELBProtocol `json:"protocol"`
193199
Port int64 `json:"port"`
194-
InstanceProtocol ElbProtocol `json:"instanceProtocol"`
200+
InstanceProtocol ELBProtocol `json:"instanceProtocol"`
195201
InstancePort int64 `json:"instancePort"`
196202
}
197203

0 commit comments

Comments
 (0)