@@ -13,11 +13,16 @@ import (
13
13
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
14
14
)
15
15
16
+ var CommonLabels = map [string ]string {
17
+ "app.kubernetes.io/managed-by" : "grafana-operator" ,
18
+ }
19
+
16
20
func GetGrafanaConfigMap (cr * grafanav1beta1.Grafana , scheme * runtime.Scheme ) * v1.ConfigMap {
17
21
config := & v1.ConfigMap {
18
22
ObjectMeta : metav1.ObjectMeta {
19
23
Name : fmt .Sprintf ("%s-ini" , cr .Name ),
20
24
Namespace : cr .Namespace ,
25
+ Labels : CommonLabels ,
21
26
},
22
27
}
23
28
controllerutil .SetControllerReference (cr , config , scheme ) //nolint:errcheck
@@ -29,6 +34,7 @@ func GetGrafanaAdminSecret(cr *grafanav1beta1.Grafana, scheme *runtime.Scheme) *
29
34
ObjectMeta : metav1.ObjectMeta {
30
35
Name : fmt .Sprintf ("%s-admin-credentials" , cr .Name ),
31
36
Namespace : cr .Namespace ,
37
+ Labels : CommonLabels ,
32
38
},
33
39
}
34
40
@@ -43,6 +49,7 @@ func GetGrafanaDataPVC(cr *grafanav1beta1.Grafana, scheme *runtime.Scheme) *v1.P
43
49
ObjectMeta : metav1.ObjectMeta {
44
50
Name : fmt .Sprintf ("%s-pvc" , cr .Name ),
45
51
Namespace : cr .Namespace ,
52
+ Labels : CommonLabels ,
46
53
},
47
54
}
48
55
// using OwnerReference specifically here to allow admins to change storage variables without the operator complaining
@@ -55,6 +62,7 @@ func GetGrafanaServiceAccount(cr *grafanav1beta1.Grafana, scheme *runtime.Scheme
55
62
ObjectMeta : metav1.ObjectMeta {
56
63
Name : fmt .Sprintf ("%s-sa" , cr .Name ),
57
64
Namespace : cr .Namespace ,
65
+ Labels : CommonLabels ,
58
66
},
59
67
}
60
68
controllerutil .SetControllerReference (cr , sa , scheme ) //nolint:errcheck
@@ -66,6 +74,7 @@ func GetGrafanaService(cr *grafanav1beta1.Grafana, scheme *runtime.Scheme) *v1.S
66
74
ObjectMeta : metav1.ObjectMeta {
67
75
Name : fmt .Sprintf ("%s-service" , cr .Name ),
68
76
Namespace : cr .Namespace ,
77
+ Labels : CommonLabels ,
69
78
},
70
79
}
71
80
controllerutil .SetControllerReference (cr , service , scheme ) //nolint:errcheck
@@ -77,6 +86,7 @@ func GetGrafanaIngress(cr *grafanav1beta1.Grafana, scheme *runtime.Scheme) *v12.
77
86
ObjectMeta : metav1.ObjectMeta {
78
87
Name : fmt .Sprintf ("%s-ingress" , cr .Name ),
79
88
Namespace : cr .Namespace ,
89
+ Labels : CommonLabels ,
80
90
},
81
91
}
82
92
controllerutil .SetControllerReference (cr , ingress , scheme ) //nolint:errcheck
@@ -88,6 +98,7 @@ func GetGrafanaRoute(cr *grafanav1beta1.Grafana, scheme *runtime.Scheme) *routev
88
98
ObjectMeta : metav1.ObjectMeta {
89
99
Name : fmt .Sprintf ("%s-route" , cr .Name ),
90
100
Namespace : cr .Namespace ,
101
+ Labels : CommonLabels ,
91
102
},
92
103
}
93
104
controllerutil .SetControllerReference (cr , route , scheme ) //nolint:errcheck
@@ -99,6 +110,7 @@ func GetGrafanaDeployment(cr *grafanav1beta1.Grafana, scheme *runtime.Scheme) *v
99
110
ObjectMeta : metav1.ObjectMeta {
100
111
Name : fmt .Sprintf ("%s-deployment" , cr .Name ),
101
112
Namespace : cr .Namespace ,
113
+ Labels : CommonLabels ,
102
114
},
103
115
}
104
116
if scheme != nil {
0 commit comments