1
- // Copyright (c) 2023-2024 Tigera, Inc. All rights reserved.
1
+ // Copyright (c) 2023-2025 Tigera, Inc. All rights reserved.
2
2
3
3
// Licensed under the Apache License, Version 2.0 (the "License");
4
4
// you may not use this file except in compliance with the License.
@@ -100,10 +100,11 @@ func (c *component) SupportedOSType() rmeta.OSType {
100
100
}
101
101
102
102
func (c * component ) Objects () ([]client.Object , []client.Object ) {
103
- objectsToCreate := append (
104
- secret .ToRuntimeObjects (c .egwPullSecrets ()... ),
105
- c .egwServiceAccount (),
106
- )
103
+
104
+ var objectsToCreate []client.Object
105
+ objectsToCreate = append (objectsToCreate , c .egwOperatorSecretsRoleBinding ())
106
+ objectsToCreate = append (objectsToCreate , secret .ToRuntimeObjects (c .egwPullSecrets ()... )... )
107
+ objectsToCreate = append (objectsToCreate , c .egwServiceAccount ())
107
108
108
109
var objectsToDelete []client.Object
109
110
if c .config .OpenShift {
@@ -122,6 +123,16 @@ func (c *component) Objects() ([]client.Object, []client.Object) {
122
123
return objectsToCreate , objectsToDelete
123
124
}
124
125
126
+ func (c * component ) egwOperatorSecretsRoleBinding () * rbacv1.RoleBinding {
127
+ operatorSecretRB := render .CreateOperatorSecretsRoleBinding (c .config .EgressGW .Namespace )
128
+ operatorSecretRB .ObjectMeta .Labels = common .MapExistsOrInitialize (operatorSecretRB .ObjectMeta .Labels )
129
+ // The tigera-operator-secrets RoleBinding is shared across all EGW CRs in this namespace.
130
+ // As such, we mark it as having multiple owners so that we maintain multiple owner references
131
+ // when creating the rolebinding so that it will only be GC'd when all of its owners have been deleted.
132
+ operatorSecretRB .ObjectMeta .Labels [common .MultipleOwnersLabel ] = "true"
133
+ return operatorSecretRB
134
+ }
135
+
125
136
func (c * component ) Ready () bool {
126
137
return true
127
138
}
0 commit comments