KEP-4193: promote ServiceAccountTokenNodeBinding feature to beta

This commit is contained in:
James Munnelly 2024-05-31 12:16:03 +01:00
parent 8565e37525
commit 5481e630de
3 changed files with 12 additions and 22 deletions

View File

@ -699,6 +699,7 @@ const (
// owner: @munnerz // owner: @munnerz
// kep: http://kep.k8s.io/4193 // kep: http://kep.k8s.io/4193
// alpha: v1.29 // alpha: v1.29
// beta: v1.31
// //
// Controls whether the apiserver supports binding service account tokens to Node objects. // Controls whether the apiserver supports binding service account tokens to Node objects.
ServiceAccountTokenNodeBinding featuregate.Feature = "ServiceAccountTokenNodeBinding" ServiceAccountTokenNodeBinding featuregate.Feature = "ServiceAccountTokenNodeBinding"
@ -1139,7 +1140,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS
ServiceAccountTokenPodNodeInfo: {Default: true, PreRelease: featuregate.Beta}, ServiceAccountTokenPodNodeInfo: {Default: true, PreRelease: featuregate.Beta},
ServiceAccountTokenNodeBinding: {Default: false, PreRelease: featuregate.Alpha}, ServiceAccountTokenNodeBinding: {Default: true, PreRelease: featuregate.Beta},
ServiceAccountTokenNodeBindingValidation: {Default: true, PreRelease: featuregate.Beta}, ServiceAccountTokenNodeBindingValidation: {Default: true, PreRelease: featuregate.Beta},

View File

@ -19,7 +19,6 @@ package create
import ( import (
"context" "context"
"fmt" "fmt"
"os"
"strings" "strings"
"time" "time"
@ -103,10 +102,9 @@ func boundObjectKindToAPIVersions() map[string]string {
kinds := map[string]string{ kinds := map[string]string{
"Pod": "v1", "Pod": "v1",
"Secret": "v1", "Secret": "v1",
"Node": "v1",
} }
if os.Getenv("KUBECTL_NODE_BOUND_TOKENS") == "true" {
kinds["Node"] = "v1"
}
return kinds return kinds
} }

View File

@ -21,7 +21,6 @@ import (
"encoding/json" "encoding/json"
"io" "io"
"net/http" "net/http"
"os"
"reflect" "reflect"
"testing" "testing"
"time" "time"
@ -54,8 +53,6 @@ func TestCreateToken(t *testing.T) {
audiences []string audiences []string
duration time.Duration duration time.Duration
enableNodeBindingFeature bool
serverResponseToken string serverResponseToken string
serverResponseError string serverResponseError string
@ -118,14 +115,13 @@ status:
test: "bad bound object kind", test: "bad bound object kind",
name: "mysa", name: "mysa",
boundObjectKind: "Foo", boundObjectKind: "Foo",
expectStderr: `error: supported --bound-object-kind values are Pod, Secret`, expectStderr: `error: supported --bound-object-kind values are Node, Pod, Secret`,
}, },
{ {
test: "bad bound object kind (node feature enabled)", test: "bad bound object kind (node feature enabled)",
name: "mysa", name: "mysa",
enableNodeBindingFeature: true, boundObjectKind: "Foo",
boundObjectKind: "Foo", expectStderr: `error: supported --bound-object-kind values are Node, Pod, Secret`,
expectStderr: `error: supported --bound-object-kind values are Node, Pod, Secret`,
}, },
{ {
test: "missing bound object name", test: "missing bound object name",
@ -172,10 +168,9 @@ status:
test: "valid bound object (Node)", test: "valid bound object (Node)",
name: "mysa", name: "mysa",
enableNodeBindingFeature: true, boundObjectKind: "Node",
boundObjectKind: "Node", boundObjectName: "mynode",
boundObjectName: "mynode", boundObjectUID: "myuid",
boundObjectUID: "myuid",
expectRequestPath: "/api/v1/namespaces/test/serviceaccounts/mysa/token", expectRequestPath: "/api/v1/namespaces/test/serviceaccounts/mysa/token",
expectTokenRequest: &authenticationv1.TokenRequest{ expectTokenRequest: &authenticationv1.TokenRequest{
@ -367,10 +362,6 @@ status:
if test.duration != 0 { if test.duration != 0 {
cmd.Flags().Set("duration", test.duration.String()) cmd.Flags().Set("duration", test.duration.String())
} }
if test.enableNodeBindingFeature {
os.Setenv("KUBECTL_NODE_BOUND_TOKENS", "true")
defer os.Unsetenv("KUBECTL_NODE_BOUND_TOKENS")
}
cmd.Run(cmd, []string{test.name}) cmd.Run(cmd, []string{test.name})
if !reflect.DeepEqual(tokenRequest, test.expectTokenRequest) { if !reflect.DeepEqual(tokenRequest, test.expectTokenRequest) {