Skip to content

Commit

Permalink
Support loadBalancerSourceRanges configuration for master/replica ser…
Browse files Browse the repository at this point in the history
…vices
  • Loading branch information
ynnt committed Nov 4, 2021
1 parent 32164d0 commit 4695712
Show file tree
Hide file tree
Showing 6 changed files with 33 additions and 0 deletions.
12 changes: 12 additions & 0 deletions config/crd/bases/mysql.presslabs.org_mysqlclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,12 @@ spec:
MasterServiceSpec:
description: Master service extra specification
properties:
allowedSourceRanges:
description: AllowedSourceRanges sets a list of CIDR blocks allowed
to access the cluster using LoadBalancer service.
items:
type: string
type: array
annotations:
additionalProperties:
type: string
Expand Down Expand Up @@ -6178,6 +6184,12 @@ spec:
replicaServiceSpec:
description: Healthy replica service extra specification
properties:
allowedSourceRanges:
description: AllowedSourceRanges sets a list of CIDR blocks allowed
to access the cluster using LoadBalancer service.
items:
type: string
type: array
annotations:
additionalProperties:
type: string
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,11 @@ spec:
MasterServiceSpec:
description: Master service extra specification
properties:
allowedSourceRanges:
description: AllowedSourceRanges sets a list of CIDR blocks allowed to access the cluster using LoadBalancer service.
items:
type: string
type: array
annotations:
additionalProperties:
type: string
Expand Down Expand Up @@ -3774,6 +3779,11 @@ spec:
replicaServiceSpec:
description: Healthy replica service extra specification
properties:
allowedSourceRanges:
description: AllowedSourceRanges sets a list of CIDR blocks allowed to access the cluster using LoadBalancer service.
items:
type: string
type: array
annotations:
additionalProperties:
type: string
Expand Down
4 changes: 4 additions & 0 deletions pkg/apis/mysql/v1alpha1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,10 @@ type ServiceSpec struct {
// +optional
LoadBalancer bool `json:"loadBalancer,omitempty"`

// AllowedSourceRanges sets a list of CIDR blocks allowed to access the cluster using LoadBalancer service.
// +optional
AllowedSourceRanges []string `json:"allowedSourceRanges,omitempty"`

// Annotations allow to specify annotations for MysqlCluster's services
// +optional
Annotations map[string]string `json:"annotations,omitempty"`
Expand Down
5 changes: 5 additions & 0 deletions pkg/apis/mysql/v1alpha1/zz_generated.deepcopy.go

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

Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func NewHealthyReplicasSVCSyncer(c client.Client, scheme *runtime.Scheme, cluste
// set service type
if cluster.Spec.ReplicaServiceSpec.LoadBalancer {
service.Spec.Type = core.ServiceTypeLoadBalancer
service.Spec.LoadBalancerSourceRanges = cluster.Spec.ReplicaServiceSpec.AllowedSourceRanges
}

// merge annotations
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@ func NewMasterSVCSyncer(c client.Client, scheme *runtime.Scheme, cluster *mysqlc
// set service type
if cluster.Spec.MasterServiceSpec.LoadBalancer {
service.Spec.Type = core.ServiceTypeLoadBalancer
service.Spec.LoadBalancerSourceRanges = cluster.Spec.MasterServiceSpec.AllowedSourceRanges
}

// merge annotations
Expand Down

0 comments on commit 4695712

Please sign in to comment.