@@ -28,24 +28,22 @@ pub enum Error {
28
28
}
29
29
30
30
/// 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.
33
41
pub fn build_rbac_resources < T : Clone + Resource < DynamicType = ( ) > > (
34
42
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.
41
43
product_name : & str ,
42
44
labels : Labels ,
43
45
) -> Result < ( ServiceAccount , RoleBinding ) > {
44
46
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) ;
49
47
let service_account = ServiceAccount {
50
48
metadata : ObjectMetaBuilder :: new ( )
51
49
. name_and_namespace ( resource)
@@ -74,22 +72,12 @@ pub fn build_rbac_resources<T: Clone + Resource<DynamicType = ()>>(
74
72
name : format ! ( "{product_name}-clusterrole" ) ,
75
73
api_group : "rbac.authorization.k8s.io" . to_string ( ) ,
76
74
} ,
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
+ } ] ) ,
93
81
} ;
94
82
95
83
Ok ( ( service_account, role_binding) )
0 commit comments