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 5, 2021
1 parent 32164d0 commit 6cd163c
Show file tree
Hide file tree
Showing 6 changed files with 60 additions and 27 deletions.
40 changes: 26 additions & 14 deletions config/crd/bases/mysql.presslabs.org_mysqlclusters.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -51,20 +51,6 @@ spec:
description: 'MysqlClusterSpec defines the desired state of MysqlCluster
nolint: maligned'
properties:
MasterServiceSpec:
description: Master service extra specification
properties:
annotations:
additionalProperties:
type: string
description: Annotations allow to specify annotations for MysqlCluster's
services
type: object
loadBalancer:
description: LoadBalancer configures whether a service is a LoadBalancer
or not.
type: boolean
type: object
backupCompressCommand:
description: BackupCompressCommand is a command to use for compressing
the backup.
Expand Down Expand Up @@ -116,6 +102,26 @@ spec:
items:
type: string
type: array
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
description: Annotations allow to specify annotations for MysqlCluster's
services
type: object
loadBalancer:
description: LoadBalancer configures whether a service is a LoadBalancer
or not.
type: boolean
type: object
maxSlaveLatency:
description: MaxSlaveLatency represents the allowed latency for a
slave node in seconds. If set then the node with a latency grater
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 @@ -46,18 +46,6 @@ spec:
spec:
description: 'MysqlClusterSpec defines the desired state of MysqlCluster nolint: maligned'
properties:
MasterServiceSpec:
description: Master service extra specification
properties:
annotations:
additionalProperties:
type: string
description: Annotations allow to specify annotations for MysqlCluster's services
type: object
loadBalancer:
description: LoadBalancer configures whether a service is a LoadBalancer or not.
type: boolean
type: object
backupCompressCommand:
description: BackupCompressCommand is a command to use for compressing the backup.
items:
Expand Down Expand Up @@ -99,6 +87,23 @@ spec:
items:
type: string
type: array
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
description: Annotations allow to specify annotations for MysqlCluster's services
type: object
loadBalancer:
description: LoadBalancer configures whether a service is a LoadBalancer or not.
type: boolean
type: object
maxSlaveLatency:
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.
format: int64
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
6 changes: 5 additions & 1 deletion pkg/apis/mysql/v1alpha1/mysqlcluster_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ type MysqlClusterSpec struct {

// Master service extra specification
// +optional
MasterServiceSpec ServiceSpec `json:"MasterServiceSpec,omitempty"`
MasterServiceSpec ServiceSpec `json:"masterServiceSpec,omitempty"`

// Healthy replica service extra specification
// +optional
Expand Down 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 6cd163c

Please sign in to comment.