@@ -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.
3341pub 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