Skip to content

Commit 7c6a2ba

Browse files
committed
fix tigera-operator permission error for egressgateway
1 parent aed7208 commit 7c6a2ba

File tree

1 file changed

+16
-5
lines changed

1 file changed

+16
-5
lines changed

pkg/render/egressgateway/egressgateway.go

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// Copyright (c) 2023-2024 Tigera, Inc. All rights reserved.
1+
// Copyright (c) 2023-2025 Tigera, Inc. All rights reserved.
22

33
// Licensed under the Apache License, Version 2.0 (the "License");
44
// you may not use this file except in compliance with the License.
@@ -100,10 +100,11 @@ func (c *component) SupportedOSType() rmeta.OSType {
100100
}
101101

102102
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())
107108

108109
var objectsToDelete []client.Object
109110
if c.config.OpenShift {
@@ -122,6 +123,16 @@ func (c *component) Objects() ([]client.Object, []client.Object) {
122123
return objectsToCreate, objectsToDelete
123124
}
124125

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+
125136
func (c *component) Ready() bool {
126137
return true
127138
}

0 commit comments

Comments
 (0)