Skip to content

Commit b7fd394

Browse files
committed
fix labels
Signed-off-by: Ashima-Ashima1 <[email protected]>
1 parent 9f7681f commit b7fd394

File tree

4 files changed

+33
-51
lines changed

4 files changed

+33
-51
lines changed

config/samples/csi_v1alpha1_ibmobjectcsi.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ spec:
1313
# and csi-provisioner, csi-attacher, csi-snapshotter and livenessprobe sidecars.
1414
controller:
1515
repository: icr.io/ibm/ibm-object-csi-driver
16-
tag: "v1.0.3-alpha"
16+
tag: "v1.0.4-alpha"
1717
imagePullPolicy: IfNotPresent
1818
resources:
1919
limits:
@@ -36,7 +36,7 @@ spec:
3636
# and csi-node-driver-registrar and livenessprobe sidecars.
3737
node:
3838
repository: icr.io/ibm/ibm-object-csi-driver
39-
tag: "v1.0.3-alpha"
39+
tag: "v1.0.4-alpha"
4040
imagePullPolicy: Always
4141
resources:
4242
limits:

controllers/internal/crutils/ibmobjectcsi.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,8 +34,8 @@ func (c *IBMObjectCSI) GetLabels() labels.Set {
3434
"app.kubernetes.io/name": config.ProductName,
3535
"app.kubernetes.io/instance": c.Name,
3636
"app.kubernetes.io/version": csiversion.Version,
37-
"app.kubernetes.io/part-of": config.Name,
38-
"app.kubernetes.io/managed-by": "addon",
37+
"app.kubernetes.io/part-of": config.CSIDriverName,
38+
"app.kubernetes.io/managed-by": config.CSIOperatorName,
3939
"product": config.ProductName,
4040
"release": fmt.Sprintf("v%s", csiversion.Version),
4141
}

controllers/internal/crutils/static_resource_generator.go

Lines changed: 18 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@ func (c *IBMObjectCSI) GenerateCSIDriver() *storagev1.CSIDriver {
1818
Name: config.DriverName,
1919
Labels: map[string]string{
2020
"app.kubernetes.io/name": "ibm-object-csi",
21-
"app.kubernetes.io/part-of": config.Name,
22-
"app.kubernetes.io/managed-by": "addon",
21+
"app.kubernetes.io/part-of": config.CSIDriverName,
22+
"app.kubernetes.io/managed-by": config.CSIOperatorName,
2323
},
2424
},
2525
Spec: storagev1.CSIDriverSpec{
@@ -56,11 +56,8 @@ func getServiceAccount(c *IBMObjectCSI, serviceAccountResourceName config.Resour
5656
func (c *IBMObjectCSI) GenerateExternalProvisionerClusterRole() *rbacv1.ClusterRole {
5757
return &rbacv1.ClusterRole{
5858
ObjectMeta: metav1.ObjectMeta{
59-
Name: config.GetNameForResource(config.ExternalProvisionerClusterRole, c.Name),
60-
Labels: map[string]string{
61-
"app.kubernetes.io/part-of": config.Name,
62-
"app.kubernetes.io/managed-by": "addon",
63-
},
59+
Name: config.GetNameForResource(config.ExternalProvisionerClusterRole, c.Name),
60+
Labels: config.CommonCSIResourceLabels,
6461
},
6562
Rules: []rbacv1.PolicyRule{
6663
{
@@ -106,11 +103,8 @@ func (c *IBMObjectCSI) GenerateExternalProvisionerClusterRole() *rbacv1.ClusterR
106103
func (c *IBMObjectCSI) GenerateExternalProvisionerClusterRoleBinding() *rbacv1.ClusterRoleBinding {
107104
return &rbacv1.ClusterRoleBinding{
108105
ObjectMeta: metav1.ObjectMeta{
109-
Name: config.GetNameForResource(config.ExternalProvisionerClusterRoleBinding, c.Name),
110-
Labels: map[string]string{
111-
"app.kubernetes.io/part-of": config.Name,
112-
"app.kubernetes.io/managed-by": "addon",
113-
},
106+
Name: config.GetNameForResource(config.ExternalProvisionerClusterRoleBinding, c.Name),
107+
Labels: config.CommonCSIResourceLabels,
114108
},
115109
Subjects: []rbacv1.Subject{
116110
{
@@ -131,11 +125,8 @@ func (c *IBMObjectCSI) GenerateExternalProvisionerClusterRoleBinding() *rbacv1.C
131125
func (c *IBMObjectCSI) GenerateSCCForControllerClusterRole() *rbacv1.ClusterRole {
132126
return &rbacv1.ClusterRole{
133127
ObjectMeta: metav1.ObjectMeta{
134-
Name: config.GetNameForResource(config.CSIControllerSCCClusterRole, c.Name),
135-
Labels: map[string]string{
136-
"app.kubernetes.io/part-of": config.Name,
137-
"app.kubernetes.io/managed-by": "addon",
138-
},
128+
Name: config.GetNameForResource(config.CSIControllerSCCClusterRole, c.Name),
129+
Labels: config.CommonCSIResourceLabels,
139130
},
140131
Rules: []rbacv1.PolicyRule{
141132
{
@@ -152,11 +143,8 @@ func (c *IBMObjectCSI) GenerateSCCForControllerClusterRole() *rbacv1.ClusterRole
152143
func (c *IBMObjectCSI) GenerateSCCForControllerClusterRoleBinding() *rbacv1.ClusterRoleBinding {
153144
return &rbacv1.ClusterRoleBinding{
154145
ObjectMeta: metav1.ObjectMeta{
155-
Name: config.GetNameForResource(config.CSIControllerSCCClusterRoleBinding, c.Name),
156-
Labels: map[string]string{
157-
"app.kubernetes.io/part-of": config.Name,
158-
"app.kubernetes.io/managed-by": "addon",
159-
},
146+
Name: config.GetNameForResource(config.CSIControllerSCCClusterRoleBinding, c.Name),
147+
Labels: config.CommonCSIResourceLabels,
160148
},
161149
Subjects: []rbacv1.Subject{
162150
{
@@ -177,11 +165,8 @@ func (c *IBMObjectCSI) GenerateSCCForControllerClusterRoleBinding() *rbacv1.Clus
177165
func (c *IBMObjectCSI) GenerateSCCForNodeClusterRole() *rbacv1.ClusterRole {
178166
return &rbacv1.ClusterRole{
179167
ObjectMeta: metav1.ObjectMeta{
180-
Name: config.GetNameForResource(config.CSINodeSCCClusterRole, c.Name),
181-
Labels: map[string]string{
182-
"app.kubernetes.io/part-of": config.Name,
183-
"app.kubernetes.io/managed-by": "addon",
184-
},
168+
Name: config.GetNameForResource(config.CSINodeSCCClusterRole, c.Name),
169+
Labels: config.CommonCSIResourceLabels,
185170
},
186171
Rules: []rbacv1.PolicyRule{
187172
{
@@ -210,11 +195,8 @@ func (c *IBMObjectCSI) GenerateSCCForNodeClusterRole() *rbacv1.ClusterRole {
210195
func (c *IBMObjectCSI) GenerateSCCForNodeClusterRoleBinding() *rbacv1.ClusterRoleBinding {
211196
return &rbacv1.ClusterRoleBinding{
212197
ObjectMeta: metav1.ObjectMeta{
213-
Name: config.GetNameForResource(config.CSINodeSCCClusterRoleBinding, c.Name),
214-
Labels: map[string]string{
215-
"app.kubernetes.io/part-of": config.Name,
216-
"app.kubernetes.io/managed-by": "addon",
217-
},
198+
Name: config.GetNameForResource(config.CSINodeSCCClusterRoleBinding, c.Name),
199+
Labels: config.CommonCSIResourceLabels,
218200
},
219201
Subjects: []rbacv1.Subject{
220202
{
@@ -236,11 +218,8 @@ func (c *IBMObjectCSI) Generates3fsSC() *storagev1.StorageClass {
236218
reclaimPolicy := corev1.PersistentVolumeReclaimRetain
237219
return &storagev1.StorageClass{
238220
ObjectMeta: metav1.ObjectMeta{
239-
Name: config.GetNameForResource(config.S3fsStorageClass, c.Name),
240-
Labels: map[string]string{
241-
"app.kubernetes.io/part-of": config.Name,
242-
"app.kubernetes.io/managed-by": "addon",
243-
},
221+
Name: config.GetNameForResource(config.S3fsStorageClass, c.Name),
222+
Labels: config.CommonCSIResourceLabels,
244223
},
245224
Provisioner: config.DriverName,
246225
ReclaimPolicy: &reclaimPolicy,
@@ -268,11 +247,8 @@ func (c *IBMObjectCSI) GenerateRcloneSC() *storagev1.StorageClass {
268247
reclaimPolicy := corev1.PersistentVolumeReclaimRetain
269248
return &storagev1.StorageClass{
270249
ObjectMeta: metav1.ObjectMeta{
271-
Name: config.GetNameForResource(config.RcloneStorageClass, c.Name),
272-
Labels: map[string]string{
273-
"app.kubernetes.io/part-of": config.Name,
274-
"app.kubernetes.io/managed-by": "addon",
275-
},
250+
Name: config.GetNameForResource(config.RcloneStorageClass, c.Name),
251+
Labels: config.CommonCSIResourceLabels,
276252
},
277253
Provisioner: config.DriverName,
278254
ReclaimPolicy: &reclaimPolicy,

pkg/config/constants.go

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,12 @@ package config
33

44
// Add a field here if it never changes, if it changes over time, put it to settings.go
55
const (
6-
APIGroup = "objectdriver.csi.ibm.com"
7-
APIVersion = "v1"
8-
Name = "ibm-object-csi-driver-operator"
9-
DriverName = "cos.s3.csi.ibm.io"
10-
ProductName = "ibm-object-csi-driver"
6+
APIGroup = "objectdriver.csi.ibm.com"
7+
APIVersion = "v1"
8+
CSIOperatorName = "ibm-object-csi-driver-operator"
9+
CSIDriverName = "ibm-object-csi-driver"
10+
DriverName = "cos.s3.csi.ibm.io"
11+
ProductName = "ibm-object-csi-driver"
1112

1213
RbacAuthorizationAPIGroup = "rbac.authorization.k8s.io"
1314
SecurityOpenshiftAPIGroup = "security.openshift.io"
@@ -43,3 +44,8 @@ const (
4344
CSIEndpoint = "unix:///var/lib/csi/sockets/pluginproxy/csi.sock"
4445
CSINodeEndpoint = "unix:///csi/csi.sock"
4546
)
47+
48+
var CommonCSIResourceLabels = map[string]string{
49+
"app.kubernetes.io/part-of": CSIDriverName,
50+
"app.kubernetes.io/managed-by": CSIOperatorName,
51+
}

0 commit comments

Comments
 (0)