Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions pkg/features/kube_features.go
Original file line number Diff line number Diff line change
Expand Up @@ -987,6 +987,13 @@ const (
//
// Enables the image volume source.
ImageVolume featuregate.Feature = "ImageVolume"

// TODO(cnvergence): Remove when not applicable
// owner: @cnvergence
// alpha: v1.31
//
// GlobalServiceAccount is a feature gate that enables the cross-workspace service accounts feature.
GlobalServiceAccount featuregate.Feature = "GlobalServiceAccount"
)

func init() {
Expand Down Expand Up @@ -1333,4 +1340,5 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
StorageNamespaceIndex: {Default: true, PreRelease: featuregate.Beta},

RecursiveReadOnlyMounts: {Default: true, PreRelease: featuregate.Beta},
GlobalServiceAccount: {Default: false, PreRelease: featuregate.Alpha},
}
5 changes: 4 additions & 1 deletion pkg/registry/rbac/validation/kcp.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,8 @@ import (
authserviceaccount "k8s.io/apiserver/pkg/authentication/serviceaccount"
"k8s.io/apiserver/pkg/authentication/user"
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
utilfeature "k8s.io/apiserver/pkg/util/feature"
"k8s.io/kubernetes/pkg/features"
)

const (
Expand Down Expand Up @@ -88,6 +90,7 @@ func EffectiveUsers(clusterName logicalcluster.Name, u user.Info) []user.Info {

var wantAuthenticated bool
var wantUnauthenticated bool
globalsa := utilfeature.DefaultFeatureGate.Enabled(features.GlobalServiceAccount)

var recursive func(u user.Info)
recursive = func(u user.Info) {
Expand All @@ -105,7 +108,7 @@ func EffectiveUsers(clusterName logicalcluster.Name, u user.Info) []user.Info {
wantUnauthenticated = wantUnauthenticated || !found
}

if IsServiceAccount(u) {
if IsServiceAccount(u) && globalsa {
if clusters := u.GetExtra()[authserviceaccount.ClusterNameKey]; len(clusters) == 1 {
nsNameSuffix := strings.TrimPrefix(u.GetName(), "system:serviceaccount:")
rewritten := &user.DefaultInfo{
Expand Down