Skip to content

Commit cf860ef

Browse files
cuisongliugithub-actions[bot]
authored andcommitted
fix(user): remove pod-security labels for admin namespace (#6609)
Signed-off-by: cuisongliu <cuisongliu@qq.com>
1 parent 48d3887 commit cf860ef

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

controllers/user/controllers/user_controller.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"errors"
2222
"fmt"
2323
"strconv"
24+
"strings"
2425
"time"
2526

2627
"github.com/go-logr/logr"
@@ -305,6 +306,12 @@ func (r *UserReconciler) syncNamespace(
305306
ns.Annotations[userAnnotationOwnerKey] = user.Annotations[userAnnotationOwnerKey]
306307
if ns.Name != "admin" {
307308
ns.Labels = config.SetPodSecurity(ns.Labels)
309+
} else {
310+
for k := range ns.Labels {
311+
if strings.HasPrefix(k, "pod-security.") {
312+
delete(ns.Labels, k)
313+
}
314+
}
308315
}
309316
// add label for namespace to filter
310317
ns.Labels[userLabelOwnerKey] = user.Annotations[userAnnotationOwnerKey]

0 commit comments

Comments
 (0)