Skip to content

Commit 4695712

Browse files
committed
Support loadBalancerSourceRanges configuration for master/replica services
1 parent 32164d0 commit 4695712

File tree

6 files changed

+33
-0
lines changed

6 files changed

+33
-0
lines changed

config/crd/bases/mysql.presslabs.org_mysqlclusters.yaml

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -54,6 +54,12 @@ spec:
5454
MasterServiceSpec:
5555
description: Master service extra specification
5656
properties:
57+
allowedSourceRanges:
58+
description: AllowedSourceRanges sets a list of CIDR blocks allowed
59+
to access the cluster using LoadBalancer service.
60+
items:
61+
type: string
62+
type: array
5763
annotations:
5864
additionalProperties:
5965
type: string
@@ -6178,6 +6184,12 @@ spec:
61786184
replicaServiceSpec:
61796185
description: Healthy replica service extra specification
61806186
properties:
6187+
allowedSourceRanges:
6188+
description: AllowedSourceRanges sets a list of CIDR blocks allowed
6189+
to access the cluster using LoadBalancer service.
6190+
items:
6191+
type: string
6192+
type: array
61816193
annotations:
61826194
additionalProperties:
61836195
type: string

deploy/charts/mysql-operator/crds/mysql.presslabs.org_mysqlclusters.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,11 @@ spec:
4949
MasterServiceSpec:
5050
description: Master service extra specification
5151
properties:
52+
allowedSourceRanges:
53+
description: AllowedSourceRanges sets a list of CIDR blocks allowed to access the cluster using LoadBalancer service.
54+
items:
55+
type: string
56+
type: array
5257
annotations:
5358
additionalProperties:
5459
type: string
@@ -3774,6 +3779,11 @@ spec:
37743779
replicaServiceSpec:
37753780
description: Healthy replica service extra specification
37763781
properties:
3782+
allowedSourceRanges:
3783+
description: AllowedSourceRanges sets a list of CIDR blocks allowed to access the cluster using LoadBalancer service.
3784+
items:
3785+
type: string
3786+
type: array
37773787
annotations:
37783788
additionalProperties:
37793789
type: string

pkg/apis/mysql/v1alpha1/mysqlcluster_types.go

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,10 @@ type ServiceSpec struct {
255255
// +optional
256256
LoadBalancer bool `json:"loadBalancer,omitempty"`
257257

258+
// AllowedSourceRanges sets a list of CIDR blocks allowed to access the cluster using LoadBalancer service.
259+
// +optional
260+
AllowedSourceRanges []string `json:"allowedSourceRanges,omitempty"`
261+
258262
// Annotations allow to specify annotations for MysqlCluster's services
259263
// +optional
260264
Annotations map[string]string `json:"annotations,omitempty"`

pkg/apis/mysql/v1alpha1/zz_generated.deepcopy.go

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

pkg/controller/mysqlcluster/internal/syncer/healthy_replicas_service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func NewHealthyReplicasSVCSyncer(c client.Client, scheme *runtime.Scheme, cluste
4040
// set service type
4141
if cluster.Spec.ReplicaServiceSpec.LoadBalancer {
4242
service.Spec.Type = core.ServiceTypeLoadBalancer
43+
service.Spec.LoadBalancerSourceRanges = cluster.Spec.ReplicaServiceSpec.AllowedSourceRanges
4344
}
4445

4546
// merge annotations

pkg/controller/mysqlcluster/internal/syncer/master_service.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ func NewMasterSVCSyncer(c client.Client, scheme *runtime.Scheme, cluster *mysqlc
4040
// set service type
4141
if cluster.Spec.MasterServiceSpec.LoadBalancer {
4242
service.Spec.Type = core.ServiceTypeLoadBalancer
43+
service.Spec.LoadBalancerSourceRanges = cluster.Spec.MasterServiceSpec.AllowedSourceRanges
4344
}
4445

4546
// merge annotations

0 commit comments

Comments
 (0)