Skip to content

Commit 4816e66

Browse files
committed
fix: remove role binding to legacy service account name
1 parent c0c928f commit 4816e66

File tree

1 file changed

+12
-28
lines changed
  • crates/stackable-operator/src/commons

1 file changed

+12
-28
lines changed

crates/stackable-operator/src/commons/rbac.rs

Lines changed: 12 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,18 @@ pub enum Error {
2828
}
2929

3030
/// Build RBAC objects for the product workloads.
31-
/// The `product_name` is meant to be the product name, for example: zookeeper, airflow, etc.
32-
/// and it is a assumed that a ClusterRole named `{product_name}-clusterrole` exists.
31+
/// The names of the service account and role binding match the following templates:
32+
/// - `{resource_name}-serviceaccount`
33+
/// - `{resource_name}-rolebinding`
34+
///
35+
/// The service account is bound to a cluster role named `{product_name}-clusterrole` which
36+
/// must already exist.
3337
pub fn build_rbac_resources<T: Clone + Resource<DynamicType = ()>>(
3438
resource: &T,
35-
// 'product_name' is not used to build the names of the serviceAccount and roleBinding objects,
36-
// as this caused problems with multiple clusters of the same product within the same namespace
37-
// see <https://stackable.atlassian.net/browse/SUP-148> for more details.
38-
// Instead the names for these objects are created by reading the name from the cluster object
39-
// and appending [-rolebinding|-serviceaccount] to create unique names instead of using the
40-
// same objects for multiple clusters.
4139
product_name: &str,
4240
labels: Labels,
4341
) -> Result<(ServiceAccount, RoleBinding)> {
4442
let sa_name = service_account_name(&resource.name_any());
45-
// We add the legacy serviceAccount name to the binding here for at least one
46-
// release cycle, so that the switchover during the upgrade can be smoother.
47-
// To be removed in v24.3+1.
48-
let legacy_sa_name = service_account_name(product_name);
4943
let service_account = ServiceAccount {
5044
metadata: ObjectMetaBuilder::new()
5145
.name_and_namespace(resource)
@@ -74,22 +68,12 @@ pub fn build_rbac_resources<T: Clone + Resource<DynamicType = ()>>(
7468
name: format!("{product_name}-clusterrole"),
7569
api_group: "rbac.authorization.k8s.io".to_string(),
7670
},
77-
subjects: Some(vec![
78-
Subject {
79-
kind: "ServiceAccount".to_string(),
80-
name: sa_name,
81-
namespace: resource.namespace(),
82-
..Subject::default()
83-
},
84-
// We add the legacy serviceAccount name to the binding here for at least one
85-
// release cycle, so that the switchover during the upgrade can be smoother.
86-
Subject {
87-
kind: "ServiceAccount".to_string(),
88-
name: legacy_sa_name,
89-
namespace: resource.namespace(),
90-
..Subject::default()
91-
},
92-
]),
71+
subjects: Some(vec![Subject {
72+
kind: "ServiceAccount".to_string(),
73+
name: sa_name,
74+
namespace: resource.namespace(),
75+
..Subject::default()
76+
}]),
9377
};
9478

9579
Ok((service_account, role_binding))

0 commit comments

Comments
 (0)