Skip to content

Commit

Permalink
Add labels on services, fixes #299
Browse files Browse the repository at this point in the history
  • Loading branch information
AMecea committed May 8, 2019
1 parent 05db9ce commit e4ac846
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,13 @@ func NewHeadlessSVCSyncer(c client.Client, scheme *runtime.Scheme, cluster *mysq
return syncer.NewObjectSyncer("HeadlessSVC", nil, obj, c, scheme, func(in runtime.Object) error {
out := in.(*core.Service)

// add general labels to this service
out.Labels = map[string]string{
"app.kubernetes.io/name": "mysql",
"app.kubernetes.io/managed-by": "mysql.presslabs.org",
}
out.Labels["mysql.presslabs.org/service-type"] = "common-headless"

out.Spec.ClusterIP = "None"
out.Spec.Selector = labels.Set{
"app.kubernetes.io/name": "mysql",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,10 @@ func NewHealthySVCSyncer(c client.Client, scheme *runtime.Scheme, cluster *mysql
return syncer.NewObjectSyncer("HealthySVC", cluster.Unwrap(), obj, c, scheme, func(in runtime.Object) error {
out := in.(*core.Service)

// set service labels
out.Labels = cluster.GetLabels()
out.Labels["mysql.presslabs.org/service-type"] = "healthy"

out.Spec.Type = "ClusterIP"
out.Spec.Selector = cluster.GetSelectorLabels()
out.Spec.Selector["healthy"] = "yes"
Expand Down
6 changes: 6 additions & 0 deletions pkg/controller/mysqlcluster/internal/syncer/master_service.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,13 @@ func NewMasterSVCSyncer(c client.Client, scheme *runtime.Scheme, cluster *mysqlc
return syncer.NewObjectSyncer("MasterSVC", cluster.Unwrap(), obj, c, scheme, func(in runtime.Object) error {
out := in.(*core.Service)

// set service labels
out.Labels = cluster.GetLabels()
out.Labels["mysql.presslabs.org/service-type"] = "master"

out.Spec.Type = "ClusterIP"

// set selectors for master node
out.Spec.Selector = cluster.GetSelectorLabels()
out.Spec.Selector["role"] = "master"

Expand Down

0 comments on commit e4ac846

Please sign in to comment.