Skip to content

Commit d2ce90e

Browse files
cnvergencentnn
authored andcommitted
UPSTREAM: <carry>: Add kube feature gate for global service account
TODO: this commit may be dropped once kcp-dev/kcp#3274 and related issues are done Signed-off-by: Karol Szwaj <karol.szwaj@gmail.com> On-behalf-of: @SAP karol.szwaj@sap.com Signed-off-by: Nelo-T. Wallus <n.wallus@sap.com>
1 parent 679b240 commit d2ce90e

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

pkg/features/kube_features.go

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -990,6 +990,13 @@ const (
990990
// operation when scheduling a Pod by setting the `metadata.labels` field on the submitted Binding,
991991
// similar to how `metadata.annotations` behaves.
992992
PodTopologyLabelsAdmission featuregate.Feature = "PodTopologyLabelsAdmission"
993+
994+
// TODO(cnvergence): Remove when not applicable
995+
// owner: @cnvergence
996+
// alpha: v1.31
997+
//
998+
// GlobalServiceAccount is a feature gate that enables the cross-workspace service accounts feature.
999+
GlobalServiceAccount featuregate.Feature = "GlobalServiceAccount"
9931000
)
9941001

9951002
// defaultVersionedKubernetesFeatureGates consists of all known Kubernetes-specific feature keys with VersionedSpecs.

pkg/registry/rbac/validation/kcp.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ import (
1212
authserviceaccount "k8s.io/apiserver/pkg/authentication/serviceaccount"
1313
"k8s.io/apiserver/pkg/authentication/user"
1414
genericapirequest "k8s.io/apiserver/pkg/endpoints/request"
15+
utilfeature "k8s.io/apiserver/pkg/util/feature"
16+
"k8s.io/kubernetes/pkg/features"
1517
)
1618

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

8991
var wantAuthenticated bool
9092
var wantUnauthenticated bool
93+
globalsa := utilfeature.DefaultFeatureGate.Enabled(features.GlobalServiceAccount)
9194

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

108-
if IsServiceAccount(u) {
111+
if IsServiceAccount(u) && globalsa {
109112
if clusters := u.GetExtra()[authserviceaccount.ClusterNameKey]; len(clusters) == 1 {
110113
nsNameSuffix := strings.TrimPrefix(u.GetName(), "system:serviceaccount:")
111114
rewritten := &user.DefaultInfo{

0 commit comments

Comments
 (0)