@@ -18,6 +18,7 @@ package kubernetes
18
18
import (
19
19
"errors"
20
20
"fmt"
21
+ "maps"
21
22
"strings"
22
23
"time"
23
24
@@ -167,15 +168,12 @@ func validateServices(clusterName string, services []svc.Service, manifest inter
167
168
return append (header , []byte (fmt .Sprintf ("## Number of services included in this manifest for cluster '%s' is: %d\n \n " , clusterName , serviceToAppendCounter ))... ), nil
168
169
}
169
170
170
- func combineLabels (a , b map [string ]string ) map [string ]string {
171
- c := make ( map [string ]string , len ( a ) + len ( b ))
172
- for k , v := range a {
173
- c [ k ] = v
171
+ func combineLabels (labels ... map [string ]string ) map [string ]string {
172
+ res := map [string ]string {}
173
+ for _ , l := range labels {
174
+ maps . Copy ( res , l )
174
175
}
175
- for k , v := range b {
176
- c [k ] = v
177
- }
178
- return c
176
+ return res
179
177
}
180
178
181
179
func makeConfigMap (
@@ -205,7 +203,8 @@ func makeService(service svc.Service) (k8sService apiv1.Service) {
205
203
serviceGraphNodeLabels ,
206
204
map [string ]string {
207
205
"app" : service .Name ,
208
- })
206
+ },
207
+ service .Labels )
209
208
timestamp (& k8sService .ObjectMeta )
210
209
k8sService .Spec .Ports = []apiv1.ServicePort {{Port : consts .ServicePort , Name : consts .ServicePortName }}
211
210
k8sService .Spec .Selector = map [string ]string {"name" : service .Name }
@@ -224,7 +223,8 @@ func makeDeployment(
224
223
serviceGraphNodeLabels ,
225
224
map [string ]string {
226
225
"app" : service .Name ,
227
- })
226
+ },
227
+ service .Labels )
228
228
timestamp (& k8sDeployment .ObjectMeta )
229
229
k8sDeployment .Spec = appsv1.DeploymentSpec {
230
230
Replicas : & service .NumReplicas ,
@@ -239,7 +239,8 @@ func makeDeployment(
239
239
serviceGraphNodeLabels ,
240
240
map [string ]string {
241
241
"name" : service .Name ,
242
- }),
242
+ },
243
+ service .Labels ),
243
244
Annotations : prometheusScrapeAnnotations ,
244
245
},
245
246
Spec : apiv1.PodSpec {
0 commit comments