fix(user): remove pod-security labels for admin namespace (#6609)

Signed-off-by: cuisongliu <cuisongliu@qq.com>
This commit is contained in:
cuisongliu
2026-01-27 15:15:31 +08:00
committed by GitHub
parent ddf45a9d96
commit 3027fa8ff3
@@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"strconv"
"strings"
"time"
"github.com/go-logr/logr"
@@ -305,6 +306,12 @@ func (r *UserReconciler) syncNamespace(
ns.Annotations[userAnnotationOwnerKey] = user.Annotations[userAnnotationOwnerKey]
if ns.Name != "admin" {
ns.Labels = config.SetPodSecurity(ns.Labels)
} else {
for k := range ns.Labels {
if strings.HasPrefix(k, "pod-security.") {
delete(ns.Labels, k)
}
}
}
// add label for namespace to filter
ns.Labels[userLabelOwnerKey] = user.Annotations[userAnnotationOwnerKey]