Skip to content

Commit 1b16804

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

File tree

6 files changed

+61
-28
lines changed

6 files changed

+61
-28
lines changed

Diff for: config/crd/bases/mysql.presslabs.org_mysqlclusters.yaml

+26-14
Original file line numberDiff line numberDiff line change
@@ -51,20 +51,6 @@ spec:
5151
description: 'MysqlClusterSpec defines the desired state of MysqlCluster
5252
nolint: maligned'
5353
properties:
54-
MasterServiceSpec:
55-
description: Master service extra specification
56-
properties:
57-
annotations:
58-
additionalProperties:
59-
type: string
60-
description: Annotations allow to specify annotations for MysqlCluster's
61-
services
62-
type: object
63-
loadBalancer:
64-
description: LoadBalancer configures whether a service is a LoadBalancer
65-
or not.
66-
type: boolean
67-
type: object
6854
backupCompressCommand:
6955
description: BackupCompressCommand is a command to use for compressing
7056
the backup.
@@ -116,6 +102,26 @@ spec:
116102
items:
117103
type: string
118104
type: array
105+
masterServiceSpec:
106+
description: Master service extra specification
107+
properties:
108+
allowedSourceRanges:
109+
description: AllowedSourceRanges sets a list of CIDR blocks allowed
110+
to access the cluster using LoadBalancer service.
111+
items:
112+
type: string
113+
type: array
114+
annotations:
115+
additionalProperties:
116+
type: string
117+
description: Annotations allow to specify annotations for MysqlCluster's
118+
services
119+
type: object
120+
loadBalancer:
121+
description: LoadBalancer configures whether a service is a LoadBalancer
122+
or not.
123+
type: boolean
124+
type: object
119125
maxSlaveLatency:
120126
description: MaxSlaveLatency represents the allowed latency for a
121127
slave node in seconds. If set then the node with a latency grater
@@ -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

Diff for: deploy/charts/mysql-operator/crds/mysql.presslabs.org_mysqlclusters.yaml

+22-12
Original file line numberDiff line numberDiff line change
@@ -46,18 +46,6 @@ spec:
4646
spec:
4747
description: 'MysqlClusterSpec defines the desired state of MysqlCluster nolint: maligned'
4848
properties:
49-
MasterServiceSpec:
50-
description: Master service extra specification
51-
properties:
52-
annotations:
53-
additionalProperties:
54-
type: string
55-
description: Annotations allow to specify annotations for MysqlCluster's services
56-
type: object
57-
loadBalancer:
58-
description: LoadBalancer configures whether a service is a LoadBalancer or not.
59-
type: boolean
60-
type: object
6149
backupCompressCommand:
6250
description: BackupCompressCommand is a command to use for compressing the backup.
6351
items:
@@ -99,6 +87,23 @@ spec:
9987
items:
10088
type: string
10189
type: array
90+
masterServiceSpec:
91+
description: Master service extra specification
92+
properties:
93+
allowedSourceRanges:
94+
description: AllowedSourceRanges sets a list of CIDR blocks allowed to access the cluster using LoadBalancer service.
95+
items:
96+
type: string
97+
type: array
98+
annotations:
99+
additionalProperties:
100+
type: string
101+
description: Annotations allow to specify annotations for MysqlCluster's services
102+
type: object
103+
loadBalancer:
104+
description: LoadBalancer configures whether a service is a LoadBalancer or not.
105+
type: boolean
106+
type: object
102107
maxSlaveLatency:
103108
description: MaxSlaveLatency represents the allowed latency for a slave node in seconds. If set then the node with a latency grater than this is removed from service.
104109
format: int64
@@ -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

Diff for: pkg/apis/mysql/v1alpha1/mysqlcluster_types.go

+6-2
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,7 @@ type MysqlClusterSpec struct {
109109

110110
// Master service extra specification
111111
// +optional
112-
MasterServiceSpec ServiceSpec `json:"MasterServiceSpec,omitempty"`
112+
MasterServiceSpec ServiceSpec `json:"masterServiceSpec,omitempty"`
113113

114114
// Healthy replica service extra specification
115115
// +optional
@@ -249,12 +249,16 @@ type VolumeSpec struct {
249249
PersistentVolumeClaim *core.PersistentVolumeClaimSpec `json:"persistentVolumeClaim,omitempty"`
250250
}
251251

252-
// ServiceSpec s the desired spec for addition configuration of MysqlCluster services
252+
// ServiceSpec is the desired spec for addition configuration of MysqlCluster services
253253
type ServiceSpec struct {
254254
// LoadBalancer configures whether a service is a LoadBalancer or not.
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"`

Diff for: pkg/apis/mysql/v1alpha1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Diff for: pkg/controller/mysqlcluster/internal/syncer/healthy_replicas_service.go

+1
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

Diff for: pkg/controller/mysqlcluster/internal/syncer/master_service.go

+1
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)