Skip to content

Commit

Permalink
small improvements
Browse files Browse the repository at this point in the history
  • Loading branch information
pooknull committed Jul 15, 2024
1 parent 1d27fda commit 726f0c6
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 16 deletions.
10 changes: 2 additions & 8 deletions pkg/controller/perconaservermongodb/status.go
Original file line number Diff line number Diff line change
Expand Up @@ -383,14 +383,8 @@ func (r *ReconcilePerconaServerMongoDB) connectionEndpoint(ctx context.Context,
err := r.client.List(ctx,
&list,
&client.ListOptions{
Namespace: cr.Namespace,
LabelSelector: labels.SelectorFromSet(map[string]string{
naming.LabelKubernetesName: "percona-server-mongodb",
naming.LabelKubernetesInstance: cr.Name,
naming.LabelKubernetesReplset: rs.Name,
naming.LabelKubernetesManagedBy: "percona-server-mongodb-operator",
naming.LabelKubernetesPartOf: "percona-server-mongodb",
}),
Namespace: cr.Namespace,
LabelSelector: labels.SelectorFromSet(naming.RSLabels(cr, rs)),
},
)
if err != nil {
Expand Down
4 changes: 4 additions & 0 deletions pkg/naming/labels.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ func ClusterLabels(cr *api.PerconaServerMongoDB) map[string]string {
}

func ServiceLabels(cr *api.PerconaServerMongoDB, replset *api.ReplsetSpec) map[string]string {
return RSLabels(cr, replset)
}

func ExternalServiceLabels(cr *api.PerconaServerMongoDB, replset *api.ReplsetSpec) map[string]string {
ls := RSLabels(cr, replset)
ls[LabelKubernetesComponent] = "external-service"

Expand Down
10 changes: 2 additions & 8 deletions pkg/psmdb/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,7 @@ import (

// Service returns a core/v1 API Service
func Service(cr *api.PerconaServerMongoDB, replset *api.ReplsetSpec) *corev1.Service {
ls := map[string]string{
naming.LabelKubernetesName: "percona-server-mongodb",
naming.LabelKubernetesInstance: cr.Name,
naming.LabelKubernetesReplset: replset.Name,
naming.LabelKubernetesManagedBy: "percona-server-mongodb-operator",
naming.LabelKubernetesPartOf: "percona-server-mongodb",
}
ls := naming.ServiceLabels(cr, replset)

svc := &corev1.Service{
TypeMeta: metav1.TypeMeta{
Expand Down Expand Up @@ -82,7 +76,7 @@ func ExternalService(cr *api.PerconaServerMongoDB, replset *api.ReplsetSpec, pod
},
}

svc.Labels = naming.ServiceLabels(cr, replset)
svc.Labels = naming.ExternalServiceLabels(cr, replset)

for k, v := range replset.Expose.ServiceLabels {
if _, ok := svc.Labels[k]; !ok {
Expand Down

0 comments on commit 726f0c6

Please sign in to comment.