@@ -168,24 +168,16 @@ func (r *EtcdClusterReconciler) ensureClusterService(ctx context.Context, cluste
168
168
ObjectMeta : metav1.ObjectMeta {
169
169
Name : cluster .Name ,
170
170
Namespace : cluster .Namespace ,
171
- Labels : map [string ]string {
172
- "app.kubernetes.io/name" : "etcd" ,
173
- "app.kubernetes.io/instance" : cluster .Name ,
174
- "app.kubernetes.io/managed-by" : "etcd-operator" ,
175
- },
171
+ Labels : factory .NewLabelsBuilder ().WithName ().WithInstance (cluster .Name ).WithManagedBy (),
176
172
},
177
173
Spec : corev1.ServiceSpec {
178
174
Ports : []corev1.ServicePort {
179
175
{Name : "peer" , TargetPort : intstr .FromInt32 (2380 ), Port : 2380 , Protocol : corev1 .ProtocolTCP },
180
176
{Name : "client" , TargetPort : intstr .FromInt32 (2379 ), Port : 2379 , Protocol : corev1 .ProtocolTCP },
181
177
},
182
- Type : corev1 .ServiceTypeClusterIP ,
183
- ClusterIP : "None" ,
184
- Selector : map [string ]string {
185
- "app.kubernetes.io/name" : "etcd" ,
186
- "app.kubernetes.io/instance" : cluster .Name ,
187
- "app.kubernetes.io/managed-by" : "etcd-operator" ,
188
- },
178
+ Type : corev1 .ServiceTypeClusterIP ,
179
+ ClusterIP : "None" ,
180
+ Selector : factory .NewLabelsBuilder ().WithName ().WithInstance (cluster .Name ).WithManagedBy (),
189
181
PublishNotReadyAddresses : true ,
190
182
},
191
183
}
@@ -216,22 +208,14 @@ func (r *EtcdClusterReconciler) ensureClusterClientService(ctx context.Context,
216
208
ObjectMeta : metav1.ObjectMeta {
217
209
Name : r .getClientServiceName (cluster ),
218
210
Namespace : cluster .Namespace ,
219
- Labels : map [string ]string {
220
- "app.kubernetes.io/name" : "etcd" ,
221
- "app.kubernetes.io/instance" : cluster .Name ,
222
- "app.kubernetes.io/managed-by" : "etcd-operator" ,
223
- },
211
+ Labels : factory .NewLabelsBuilder ().WithName ().WithInstance (cluster .Name ).WithManagedBy (),
224
212
},
225
213
Spec : corev1.ServiceSpec {
226
214
Ports : []corev1.ServicePort {
227
215
{Name : "client" , TargetPort : intstr .FromInt32 (2379 ), Port : 2379 , Protocol : corev1 .ProtocolTCP },
228
216
},
229
- Type : corev1 .ServiceTypeClusterIP ,
230
- Selector : map [string ]string {
231
- "app.kubernetes.io/name" : "etcd" ,
232
- "app.kubernetes.io/instance" : cluster .Name ,
233
- "app.kubernetes.io/managed-by" : "etcd-operator" ,
234
- },
217
+ Type : corev1 .ServiceTypeClusterIP ,
218
+ Selector : factory .NewLabelsBuilder ().WithName ().WithInstance (cluster .Name ).WithManagedBy (),
235
219
},
236
220
}
237
221
if err = ctrl .SetControllerReference (cluster , svc , r .Scheme ); err != nil {
0 commit comments