Skip to content

Commit 7d5a43e

Browse files
authored
fix: remove role binding to legacy service account name (#1060)
* fix: remove role binding to legacy service account name * update changelog * fix typo * review feedback
1 parent f23f35a commit 7d5a43e

File tree

2 files changed

+18
-28
lines changed

2 files changed

+18
-28
lines changed

crates/stackable-operator/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,12 @@ All notable changes to this project will be documented in this file.
1212
### Removed
1313

1414
- BREAKING: Removed `last_update_time` from CRD ClusterCondition status ([#1054]).
15+
- BREAKING: Removed role binding to legacy service accounts ([#1060]).
1516

1617
[#1049]: https://github.com/stackabletech/operator-rs/pull/1049
1718
[#1054]: https://github.com/stackabletech/operator-rs/pull/1054
1819
[#1058]: https://github.com/stackabletech/operator-rs/pull/1058
20+
[#1060]: https://github.com/stackabletech/operator-rs/pull/1060
1921

2022
## [0.93.2] - 2025-05-26
2123

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

Lines changed: 16 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,22 @@ 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 patterns:
32+
/// - `{resource_name}-serviceaccount`
33+
/// - `{resource_name}-rolebinding`
34+
///
35+
/// A previous version of this function used the `product_name` instead of the `resource_name`,
36+
/// but this caused conflicts when deploying multiple instances of a product in the same namespace.
37+
/// See <https://stackable.atlassian.net/browse/SUP-148> for more details.
38+
///
39+
/// The service account is bound to a cluster role named `{product_name}-clusterrole` which
40+
/// must already exist.
3341
pub fn build_rbac_resources<T: Clone + Resource<DynamicType = ()>>(
3442
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.
4143
product_name: &str,
4244
labels: Labels,
4345
) -> Result<(ServiceAccount, RoleBinding)> {
4446
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);
4947
let service_account = ServiceAccount {
5048
metadata: ObjectMetaBuilder::new()
5149
.name_and_namespace(resource)
@@ -74,22 +72,12 @@ pub fn build_rbac_resources<T: Clone + Resource<DynamicType = ()>>(
7472
name: format!("{product_name}-clusterrole"),
7573
api_group: "rbac.authorization.k8s.io".to_string(),
7674
},
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-
]),
75+
subjects: Some(vec![Subject {
76+
kind: "ServiceAccount".to_string(),
77+
name: sa_name,
78+
namespace: resource.namespace(),
79+
..Subject::default()
80+
}]),
9381
};
9482

9583
Ok((service_account, role_binding))

0 commit comments

Comments
 (0)