Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

syncer: support external network access service and automatic expose metrics port #156 #160

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion charts/mysql-operator/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ nameOverride: ""
fullnameOverride: ""

manager:
image: zhyass/manager
image: radondb/mysql-operator
tag: 0.1
resources: {}
# We usually recommend not to specify default resources and to leave this as a conscious
Expand Down
26 changes: 20 additions & 6 deletions cluster/syncer/follower_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,18 +41,32 @@ func NewFollowerSVCSyncer(cli client.Client, c *cluster.Cluster) syncer.Interfac
},
}
return syncer.NewObjectSyncer("FollowerSVC", c.Unwrap(), service, cli, func() error {
service.Spec.Type = "ClusterIP"
if service.Spec.Type == "" {
service.Spec.Type = "ClusterIP"
}

service.Spec.Selector = c.GetSelectorLabels()
service.Spec.Selector["role"] = "follower"
service.Spec.Selector["healthy"] = "yes"

if len(service.Spec.Ports) != 1 {
service.Spec.Ports = make([]corev1.ServicePort, 1)
svcPorts := []corev1.ServicePort{
{
Name: utils.MysqlPortName,
Port: utils.MysqlPort,
TargetPort: intstr.FromInt(utils.MysqlPort),
},
}

service.Spec.Ports[0].Name = utils.MysqlPortName
service.Spec.Ports[0].Port = utils.MysqlPort
service.Spec.Ports[0].TargetPort = intstr.FromInt(utils.MysqlPort)
if c.Spec.MetricsOpts.Enabled {
svcPorts = append(svcPorts, corev1.ServicePort{
Name: utils.MetricsPortName,
Port: utils.MetricsPort,
TargetPort: intstr.FromInt(utils.MetricsPort),
})
}

service.Spec.Ports = svcPorts

return nil
})
}
26 changes: 20 additions & 6 deletions cluster/syncer/leader_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,17 +41,31 @@ func NewLeaderSVCSyncer(cli client.Client, c *cluster.Cluster) syncer.Interface
},
}
return syncer.NewObjectSyncer("LeaderSVC", c.Unwrap(), service, cli, func() error {
service.Spec.Type = "ClusterIP"
if service.Spec.Type == "" {
service.Spec.Type = "ClusterIP"
}

service.Spec.Selector = c.GetSelectorLabels()
service.Spec.Selector["role"] = "leader"

if len(service.Spec.Ports) != 1 {
service.Spec.Ports = make([]corev1.ServicePort, 1)
svcPorts := []corev1.ServicePort{
{
Name: utils.MysqlPortName,
Port: utils.MysqlPort,
TargetPort: intstr.FromInt(utils.MysqlPort),
},
}

if c.Spec.MetricsOpts.Enabled {
svcPorts = append(svcPorts, corev1.ServicePort{
Name: utils.MetricsPortName,
Port: utils.MetricsPort,
TargetPort: intstr.FromInt(utils.MetricsPort),
})
}

service.Spec.Ports[0].Name = utils.MysqlPortName
service.Spec.Ports[0].Port = utils.MysqlPort
service.Spec.Ports[0].TargetPort = intstr.FromInt(utils.MysqlPort)
service.Spec.Ports = svcPorts

return nil
})
}
2 changes: 1 addition & 1 deletion config/samples/mysql_v1alpha1_cluster.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ spec:

podSpec:
imagePullPolicy: IfNotPresent
sidecarImage: zhyass/sidecar:0.1
sidecarImage: radondb/mysql-sidecar:0.1
busyboxImage: busybox:1.32

slowLogTail: false
Expand Down