From e29ac0f8bee21134db100cd4cc68e755e7cc43fa Mon Sep 17 00:00:00 2001 From: Ryan Richard Date: Thu, 17 Mar 2022 15:11:37 -0700 Subject: [PATCH] Promote CertificateSigningRequest's Spec.ExpirationSeconds field to GA Remove the comment "As of v1.22, this field is beta and is controlled via the CSRDuration feature gate" from the expirationSeconds field's godoc. Mark the "CSRDuration" feature gate as GA in 1.24, lock its value to "true", and remove the various logic which handled when the gate was "false". Update conformance test to check that the CertificateSigningRequest's Spec.ExpirationSeconds field is stored, but do not check if the field is honored since this functionality is optional. --- api/openapi-spec/swagger.json | 2 +- ...apis__certificates.k8s.io__v1_openapi.json | 2 +- pkg/apis/certificates/types.go | 2 - pkg/controller/certificates/signer/signer.go | 6 --- .../certificates/signer/signer_test.go | 49 +++++-------------- pkg/features/kube_features.go | 3 +- pkg/generated/openapi/zz_generated.openapi.go | 4 +- .../certificates/storage/metrics.go | 6 --- .../certificates/storage/metrics_test.go | 30 +----------- .../certificates/certificates/strategy.go | 6 --- .../certificates/strategy_test.go | 30 ++---------- .../api/certificates/v1/generated.proto | 2 - .../src/k8s.io/api/certificates/v1/types.go | 2 - .../v1/types_swagger_doc_generated.go | 2 +- .../api/certificates/v1beta1/generated.proto | 2 - .../k8s.io/api/certificates/v1beta1/types.go | 2 - .../v1beta1/types_swagger_doc_generated.go | 2 +- test/e2e/auth/certificates.go | 12 ++--- 18 files changed, 31 insertions(+), 133 deletions(-) diff --git a/api/openapi-spec/swagger.json b/api/openapi-spec/swagger.json index 97881d3269b..d8a52e32c3d 100644 --- a/api/openapi-spec/swagger.json +++ b/api/openapi-spec/swagger.json @@ -4606,7 +4606,7 @@ "description": "CertificateSigningRequestSpec contains the certificate request.", "properties": { "expirationSeconds": { - "description": "expirationSeconds is the requested duration of validity of the issued certificate. The certificate signer may issue a certificate with a different validity duration so a client must check the delta between the notBefore and and notAfter fields in the issued certificate to determine the actual duration.\n\nThe v1.22+ in-tree implementations of the well-known Kubernetes signers will honor this field as long as the requested duration is not greater than the maximum duration they will honor per the --cluster-signing-duration CLI flag to the Kubernetes controller manager.\n\nCertificate signers may not honor this field for various reasons:\n\n 1. Old signer that is unaware of the field (such as the in-tree\n implementations prior to v1.22)\n 2. Signer whose configured maximum is shorter than the requested duration\n 3. Signer whose configured minimum is longer than the requested duration\n\nThe minimum valid value for expirationSeconds is 600, i.e. 10 minutes.\n\nAs of v1.22, this field is beta and is controlled via the CSRDuration feature gate.", + "description": "expirationSeconds is the requested duration of validity of the issued certificate. The certificate signer may issue a certificate with a different validity duration so a client must check the delta between the notBefore and and notAfter fields in the issued certificate to determine the actual duration.\n\nThe v1.22+ in-tree implementations of the well-known Kubernetes signers will honor this field as long as the requested duration is not greater than the maximum duration they will honor per the --cluster-signing-duration CLI flag to the Kubernetes controller manager.\n\nCertificate signers may not honor this field for various reasons:\n\n 1. Old signer that is unaware of the field (such as the in-tree\n implementations prior to v1.22)\n 2. Signer whose configured maximum is shorter than the requested duration\n 3. Signer whose configured minimum is longer than the requested duration\n\nThe minimum valid value for expirationSeconds is 600, i.e. 10 minutes.", "format": "int32", "type": "integer" }, diff --git a/api/openapi-spec/v3/apis__certificates.k8s.io__v1_openapi.json b/api/openapi-spec/v3/apis__certificates.k8s.io__v1_openapi.json index b792382672f..b945ad569b9 100644 --- a/api/openapi-spec/v3/apis__certificates.k8s.io__v1_openapi.json +++ b/api/openapi-spec/v3/apis__certificates.k8s.io__v1_openapi.json @@ -122,7 +122,7 @@ "description": "CertificateSigningRequestSpec contains the certificate request.", "properties": { "expirationSeconds": { - "description": "expirationSeconds is the requested duration of validity of the issued certificate. The certificate signer may issue a certificate with a different validity duration so a client must check the delta between the notBefore and and notAfter fields in the issued certificate to determine the actual duration.\n\nThe v1.22+ in-tree implementations of the well-known Kubernetes signers will honor this field as long as the requested duration is not greater than the maximum duration they will honor per the --cluster-signing-duration CLI flag to the Kubernetes controller manager.\n\nCertificate signers may not honor this field for various reasons:\n\n 1. Old signer that is unaware of the field (such as the in-tree\n implementations prior to v1.22)\n 2. Signer whose configured maximum is shorter than the requested duration\n 3. Signer whose configured minimum is longer than the requested duration\n\nThe minimum valid value for expirationSeconds is 600, i.e. 10 minutes.\n\nAs of v1.22, this field is beta and is controlled via the CSRDuration feature gate.", + "description": "expirationSeconds is the requested duration of validity of the issued certificate. The certificate signer may issue a certificate with a different validity duration so a client must check the delta between the notBefore and and notAfter fields in the issued certificate to determine the actual duration.\n\nThe v1.22+ in-tree implementations of the well-known Kubernetes signers will honor this field as long as the requested duration is not greater than the maximum duration they will honor per the --cluster-signing-duration CLI flag to the Kubernetes controller manager.\n\nCertificate signers may not honor this field for various reasons:\n\n 1. Old signer that is unaware of the field (such as the in-tree\n implementations prior to v1.22)\n 2. Signer whose configured maximum is shorter than the requested duration\n 3. Signer whose configured minimum is longer than the requested duration\n\nThe minimum valid value for expirationSeconds is 600, i.e. 10 minutes.", "format": "int32", "type": "integer" }, diff --git a/pkg/apis/certificates/types.go b/pkg/apis/certificates/types.go index 7a7b71f21ef..a8a9c837c16 100644 --- a/pkg/apis/certificates/types.go +++ b/pkg/apis/certificates/types.go @@ -87,8 +87,6 @@ type CertificateSigningRequestSpec struct { // // The minimum valid value for expirationSeconds is 600, i.e. 10 minutes. // - // As of v1.22, this field is beta and is controlled via the CSRDuration feature gate. - // // +optional ExpirationSeconds *int32 diff --git a/pkg/controller/certificates/signer/signer.go b/pkg/controller/certificates/signer/signer.go index d4799a0fdd4..b3d726378ae 100644 --- a/pkg/controller/certificates/signer/signer.go +++ b/pkg/controller/certificates/signer/signer.go @@ -30,14 +30,12 @@ import ( metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/util/sets" "k8s.io/apiserver/pkg/server/dynamiccertificates" - utilfeature "k8s.io/apiserver/pkg/util/feature" certificatesinformers "k8s.io/client-go/informers/certificates/v1" clientset "k8s.io/client-go/kubernetes" "k8s.io/client-go/util/certificate/csr" capihelper "k8s.io/kubernetes/pkg/apis/certificates" "k8s.io/kubernetes/pkg/controller/certificates" "k8s.io/kubernetes/pkg/controller/certificates/authority" - "k8s.io/kubernetes/pkg/features" ) type CSRSigningController struct { @@ -207,10 +205,6 @@ func (s *signer) sign(x509cr *x509.CertificateRequest, usages []capi.KeyUsage, e } func (s *signer) duration(expirationSeconds *int32) time.Duration { - if !utilfeature.DefaultFeatureGate.Enabled(features.CSRDuration) { - return s.certTTL - } - if expirationSeconds == nil { return s.certTTL } diff --git a/pkg/controller/certificates/signer/signer_test.go b/pkg/controller/certificates/signer/signer_test.go index af5ec3e546c..557a44173ed 100644 --- a/pkg/controller/certificates/signer/signer_test.go +++ b/pkg/controller/certificates/signer/signer_test.go @@ -31,15 +31,12 @@ import ( capi "k8s.io/api/certificates/v1" "k8s.io/apimachinery/pkg/util/diff" - utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/client-go/kubernetes/fake" testclient "k8s.io/client-go/testing" "k8s.io/client-go/util/cert" "k8s.io/client-go/util/certificate/csr" - featuregatetesting "k8s.io/component-base/featuregate/testing" capihelper "k8s.io/kubernetes/pkg/apis/certificates/v1" "k8s.io/kubernetes/pkg/controller/certificates" - "k8s.io/kubernetes/pkg/features" testingclock "k8s.io/utils/clock/testing" ) @@ -360,83 +357,63 @@ func Test_signer_duration(t *testing.T) { name string certTTL time.Duration expirationSeconds *int32 - wantGateEnabled time.Duration - wantGateDisabled time.Duration + want time.Duration }{ { name: "can request shorter duration than TTL", certTTL: time.Hour, expirationSeconds: csr.DurationToExpirationSeconds(30 * time.Minute), - wantGateEnabled: 30 * time.Minute, - wantGateDisabled: time.Hour, + want: 30 * time.Minute, }, { name: "cannot request longer duration than TTL", certTTL: time.Hour, expirationSeconds: csr.DurationToExpirationSeconds(3 * time.Hour), - wantGateEnabled: time.Hour, - wantGateDisabled: time.Hour, + want: time.Hour, }, { name: "cannot request negative duration", certTTL: time.Hour, expirationSeconds: csr.DurationToExpirationSeconds(-time.Minute), - wantGateEnabled: 10 * time.Minute, - wantGateDisabled: time.Hour, + want: 10 * time.Minute, }, { name: "cannot request duration less than 10 mins", certTTL: time.Hour, expirationSeconds: csr.DurationToExpirationSeconds(10*time.Minute - time.Second), - wantGateEnabled: 10 * time.Minute, - wantGateDisabled: time.Hour, + want: 10 * time.Minute, }, { name: "can request duration of exactly 10 mins", certTTL: time.Hour, expirationSeconds: csr.DurationToExpirationSeconds(10 * time.Minute), - wantGateEnabled: 10 * time.Minute, - wantGateDisabled: time.Hour, + want: 10 * time.Minute, }, { name: "can request duration equal to the default", certTTL: time.Hour, expirationSeconds: csr.DurationToExpirationSeconds(time.Hour), - wantGateEnabled: time.Hour, - wantGateDisabled: time.Hour, + want: time.Hour, }, { name: "can choose not to request a duration to get the default", certTTL: time.Hour, expirationSeconds: nil, - wantGateEnabled: time.Hour, - wantGateDisabled: time.Hour, + want: time.Hour, }, } for _, tt := range tests { tt := tt - f := func(t *testing.T, want time.Duration) { + t.Run(tt.name, func(t *testing.T) { + t.Parallel() + s := &signer{ certTTL: tt.certTTL, } - if got := s.duration(tt.expirationSeconds); got != want { - t.Errorf("duration() = %v, want %v", got, want) + if got := s.duration(tt.expirationSeconds); got != tt.want { + t.Errorf("duration() = %v, want %v", got, tt.want) } - } - - // regular tests - t.Run(tt.name, func(t *testing.T) { - t.Parallel() // these are safe to run in parallel but not the feature gate disabled tests - - f(t, tt.wantGateEnabled) }) - - // same tests with the feature gate disabled - t.Run("feature gate disabled - "+tt.name, func(t *testing.T) { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSRDuration, false)() - f(t, tt.wantGateDisabled) - }) - } } diff --git a/pkg/features/kube_features.go b/pkg/features/kube_features.go index aff0f83ef0e..90c3934c2dd 100644 --- a/pkg/features/kube_features.go +++ b/pkg/features/kube_features.go @@ -723,6 +723,7 @@ const ( // owner: @enj // beta: v1.22 + // ga: v1.24 // // Allows clients to request a duration for certificates issued via the Kubernetes CSR API. CSRDuration featuregate.Feature = "CSRDuration" @@ -941,7 +942,7 @@ var defaultKubernetesFeatureGates = map[featuregate.Feature]featuregate.FeatureS SeccompDefault: {Default: false, PreRelease: featuregate.Alpha}, PodSecurity: {Default: true, PreRelease: featuregate.Beta}, ReadWriteOncePod: {Default: false, PreRelease: featuregate.Alpha}, - CSRDuration: {Default: true, PreRelease: featuregate.Beta}, + CSRDuration: {Default: true, PreRelease: featuregate.GA, LockToDefault: true}, // remove in 1.26 DelegateFSGroupToCSIDriver: {Default: true, PreRelease: featuregate.Beta}, KubeletInUserNamespace: {Default: false, PreRelease: featuregate.Alpha}, MemoryQoS: {Default: false, PreRelease: featuregate.Alpha}, diff --git a/pkg/generated/openapi/zz_generated.openapi.go b/pkg/generated/openapi/zz_generated.openapi.go index 3695c0c967a..e0de927f823 100644 --- a/pkg/generated/openapi/zz_generated.openapi.go +++ b/pkg/generated/openapi/zz_generated.openapi.go @@ -13641,7 +13641,7 @@ func schema_k8sio_api_certificates_v1_CertificateSigningRequestSpec(ref common.R }, "expirationSeconds": { SchemaProps: spec.SchemaProps{ - Description: "expirationSeconds is the requested duration of validity of the issued certificate. The certificate signer may issue a certificate with a different validity duration so a client must check the delta between the notBefore and and notAfter fields in the issued certificate to determine the actual duration.\n\nThe v1.22+ in-tree implementations of the well-known Kubernetes signers will honor this field as long as the requested duration is not greater than the maximum duration they will honor per the --cluster-signing-duration CLI flag to the Kubernetes controller manager.\n\nCertificate signers may not honor this field for various reasons:\n\n 1. Old signer that is unaware of the field (such as the in-tree\n implementations prior to v1.22)\n 2. Signer whose configured maximum is shorter than the requested duration\n 3. Signer whose configured minimum is longer than the requested duration\n\nThe minimum valid value for expirationSeconds is 600, i.e. 10 minutes.\n\nAs of v1.22, this field is beta and is controlled via the CSRDuration feature gate.", + Description: "expirationSeconds is the requested duration of validity of the issued certificate. The certificate signer may issue a certificate with a different validity duration so a client must check the delta between the notBefore and and notAfter fields in the issued certificate to determine the actual duration.\n\nThe v1.22+ in-tree implementations of the well-known Kubernetes signers will honor this field as long as the requested duration is not greater than the maximum duration they will honor per the --cluster-signing-duration CLI flag to the Kubernetes controller manager.\n\nCertificate signers may not honor this field for various reasons:\n\n 1. Old signer that is unaware of the field (such as the in-tree\n implementations prior to v1.22)\n 2. Signer whose configured maximum is shorter than the requested duration\n 3. Signer whose configured minimum is longer than the requested duration\n\nThe minimum valid value for expirationSeconds is 600, i.e. 10 minutes.", Type: []string{"integer"}, Format: "int32", }, @@ -13964,7 +13964,7 @@ func schema_k8sio_api_certificates_v1beta1_CertificateSigningRequestSpec(ref com }, "expirationSeconds": { SchemaProps: spec.SchemaProps{ - Description: "expirationSeconds is the requested duration of validity of the issued certificate. The certificate signer may issue a certificate with a different validity duration so a client must check the delta between the notBefore and and notAfter fields in the issued certificate to determine the actual duration.\n\nThe v1.22+ in-tree implementations of the well-known Kubernetes signers will honor this field as long as the requested duration is not greater than the maximum duration they will honor per the --cluster-signing-duration CLI flag to the Kubernetes controller manager.\n\nCertificate signers may not honor this field for various reasons:\n\n 1. Old signer that is unaware of the field (such as the in-tree\n implementations prior to v1.22)\n 2. Signer whose configured maximum is shorter than the requested duration\n 3. Signer whose configured minimum is longer than the requested duration\n\nThe minimum valid value for expirationSeconds is 600, i.e. 10 minutes.\n\nAs of v1.22, this field is beta and is controlled via the CSRDuration feature gate.", + Description: "expirationSeconds is the requested duration of validity of the issued certificate. The certificate signer may issue a certificate with a different validity duration so a client must check the delta between the notBefore and and notAfter fields in the issued certificate to determine the actual duration.\n\nThe v1.22+ in-tree implementations of the well-known Kubernetes signers will honor this field as long as the requested duration is not greater than the maximum duration they will honor per the --cluster-signing-duration CLI flag to the Kubernetes controller manager.\n\nCertificate signers may not honor this field for various reasons:\n\n 1. Old signer that is unaware of the field (such as the in-tree\n implementations prior to v1.22)\n 2. Signer whose configured maximum is shorter than the requested duration\n 3. Signer whose configured minimum is longer than the requested duration\n\nThe minimum valid value for expirationSeconds is 600, i.e. 10 minutes.", Type: []string{"integer"}, Format: "int32", }, diff --git a/pkg/registry/certificates/certificates/storage/metrics.go b/pkg/registry/certificates/certificates/storage/metrics.go index 26ede25b839..c1551d9059e 100644 --- a/pkg/registry/certificates/certificates/storage/metrics.go +++ b/pkg/registry/certificates/certificates/storage/metrics.go @@ -28,13 +28,11 @@ import ( utilruntime "k8s.io/apimachinery/pkg/util/runtime" genericregistry "k8s.io/apiserver/pkg/registry/generic/registry" "k8s.io/apiserver/pkg/util/dryrun" - utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/client-go/util/cert" "k8s.io/client-go/util/certificate/csr" "k8s.io/component-base/metrics" "k8s.io/component-base/metrics/legacyregistry" "k8s.io/kubernetes/pkg/apis/certificates" - "k8s.io/kubernetes/pkg/features" ) const ( @@ -92,10 +90,6 @@ func countCSRDurationMetric(requested, honored counterVecMetric) genericregistry return // ignore things that would not get persisted } - if !utilfeature.DefaultFeatureGate.Enabled(features.CSRDuration) { - return - } - oldCSR, ok := old.(*certificates.CertificateSigningRequest) if !ok { return diff --git a/pkg/registry/certificates/certificates/storage/metrics_test.go b/pkg/registry/certificates/certificates/storage/metrics_test.go index 57d6b87f220..3841b01b59f 100644 --- a/pkg/registry/certificates/certificates/storage/metrics_test.go +++ b/pkg/registry/certificates/certificates/storage/metrics_test.go @@ -30,13 +30,10 @@ import ( corev1 "k8s.io/api/core/v1" metav1 "k8s.io/apimachinery/pkg/apis/meta/v1" "k8s.io/apimachinery/pkg/runtime" - utilfeature "k8s.io/apiserver/pkg/util/feature" certutil "k8s.io/client-go/util/cert" "k8s.io/client-go/util/certificate/csr" - featuregatetesting "k8s.io/component-base/featuregate/testing" "k8s.io/component-base/metrics" "k8s.io/kubernetes/pkg/apis/certificates" - "k8s.io/kubernetes/pkg/features" "k8s.io/utils/pointer" ) @@ -52,7 +49,6 @@ func Test_countCSRDurationMetric(t *testing.T) { tests := []struct { name string - disableFeatureGate bool success bool obj, old runtime.Object options *metav1.UpdateOptions @@ -268,26 +264,6 @@ func Test_countCSRDurationMetric(t *testing.T) { wantRequested: false, wantHonored: false, }, - { - name: "no metrics when feature gate is turned off", - disableFeatureGate: true, - success: true, - obj: &certificates.CertificateSigningRequest{ - Status: certificates.CertificateSigningRequestStatus{ - Certificate: createCert(t, time.Hour, caPrivateKey, caCert), - }, - }, - old: &certificates.CertificateSigningRequest{ - Spec: certificates.CertificateSigningRequestSpec{ - SignerName: "pandas", - ExpirationSeconds: csr.DurationToExpirationSeconds(time.Hour), - }, - }, - options: &metav1.UpdateOptions{}, - wantSigner: "", - wantRequested: false, - wantHonored: false, - }, { name: "old CSR already has a cert so it is ignored", success: true, @@ -410,11 +386,7 @@ func Test_countCSRDurationMetric(t *testing.T) { for _, tt := range tests { tt := tt t.Run(tt.name, func(t *testing.T) { - if tt.disableFeatureGate { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSRDuration, false)() - } else { - t.Parallel() - } + t.Parallel() testReq := &testCounterVecMetric{} testHon := &testCounterVecMetric{} diff --git a/pkg/registry/certificates/certificates/strategy.go b/pkg/registry/certificates/certificates/strategy.go index 95450358e6a..3f63ac528b9 100644 --- a/pkg/registry/certificates/certificates/strategy.go +++ b/pkg/registry/certificates/certificates/strategy.go @@ -28,11 +28,9 @@ import ( genericapirequest "k8s.io/apiserver/pkg/endpoints/request" "k8s.io/apiserver/pkg/registry/generic" "k8s.io/apiserver/pkg/storage/names" - utilfeature "k8s.io/apiserver/pkg/util/feature" "k8s.io/kubernetes/pkg/api/legacyscheme" "k8s.io/kubernetes/pkg/apis/certificates" "k8s.io/kubernetes/pkg/apis/certificates/validation" - "k8s.io/kubernetes/pkg/features" "sigs.k8s.io/structured-merge-diff/v4/fieldpath" ) @@ -95,10 +93,6 @@ func (csrStrategy) PrepareForCreate(ctx context.Context, obj runtime.Object) { } } } - // clear expirationSeconds if the CSRDuration feature is disabled - if !utilfeature.DefaultFeatureGate.Enabled(features.CSRDuration) { - csr.Spec.ExpirationSeconds = nil - } // Be explicit that users cannot create pre-approved certificate requests. csr.Status = certificates.CertificateSigningRequestStatus{} diff --git a/pkg/registry/certificates/certificates/strategy_test.go b/pkg/registry/certificates/certificates/strategy_test.go index c34c0af9b31..454295d3319 100644 --- a/pkg/registry/certificates/certificates/strategy_test.go +++ b/pkg/registry/certificates/certificates/strategy_test.go @@ -27,19 +27,15 @@ import ( "k8s.io/apimachinery/pkg/util/diff" "k8s.io/apiserver/pkg/authentication/user" genericapirequest "k8s.io/apiserver/pkg/endpoints/request" - utilfeature "k8s.io/apiserver/pkg/util/feature" - featuregatetesting "k8s.io/component-base/featuregate/testing" certapi "k8s.io/kubernetes/pkg/apis/certificates" - "k8s.io/kubernetes/pkg/features" "k8s.io/utils/pointer" ) func TestStrategyCreate(t *testing.T) { tests := map[string]struct { - ctx context.Context - disableFeatureGate bool - obj runtime.Object - expectedObj runtime.Object + ctx context.Context + obj runtime.Object + expectedObj runtime.Object }{ "no user in context, no user in obj": { ctx: genericapirequest.NewContext(), @@ -119,7 +115,7 @@ func TestStrategyCreate(t *testing.T) { Status: certapi.CertificateSigningRequestStatus{Conditions: []certapi.CertificateSigningRequestCondition{}}, }, }, - "expirationSeconds set with gate enabled": { + "expirationSeconds set": { ctx: genericapirequest.NewContext(), obj: &certapi.CertificateSigningRequest{ Spec: certapi.CertificateSigningRequestSpec{ @@ -133,29 +129,11 @@ func TestStrategyCreate(t *testing.T) { Status: certapi.CertificateSigningRequestStatus{Conditions: []certapi.CertificateSigningRequestCondition{}}, }, }, - "expirationSeconds set with gate disabled": { - ctx: genericapirequest.NewContext(), - disableFeatureGate: true, - obj: &certapi.CertificateSigningRequest{ - Spec: certapi.CertificateSigningRequestSpec{ - ExpirationSeconds: pointer.Int32(5678), - }, - }, - expectedObj: &certapi.CertificateSigningRequest{ - Spec: certapi.CertificateSigningRequestSpec{ - ExpirationSeconds: nil, - }, - Status: certapi.CertificateSigningRequestStatus{Conditions: []certapi.CertificateSigningRequestCondition{}}, - }, - }, } for k, tc := range tests { tc := tc t.Run(k, func(t *testing.T) { - if tc.disableFeatureGate { - defer featuregatetesting.SetFeatureGateDuringTest(t, utilfeature.DefaultFeatureGate, features.CSRDuration, false)() - } obj := tc.obj Strategy.PrepareForCreate(tc.ctx, obj) if !reflect.DeepEqual(obj, tc.expectedObj) { diff --git a/staging/src/k8s.io/api/certificates/v1/generated.proto b/staging/src/k8s.io/api/certificates/v1/generated.proto index 78c5f28bc45..968cc2564c1 100644 --- a/staging/src/k8s.io/api/certificates/v1/generated.proto +++ b/staging/src/k8s.io/api/certificates/v1/generated.proto @@ -154,8 +154,6 @@ message CertificateSigningRequestSpec { // // The minimum valid value for expirationSeconds is 600, i.e. 10 minutes. // - // As of v1.22, this field is beta and is controlled via the CSRDuration feature gate. - // // +optional optional int32 expirationSeconds = 8; diff --git a/staging/src/k8s.io/api/certificates/v1/types.go b/staging/src/k8s.io/api/certificates/v1/types.go index a3900e1dca4..317d1d9be31 100644 --- a/staging/src/k8s.io/api/certificates/v1/types.go +++ b/staging/src/k8s.io/api/certificates/v1/types.go @@ -103,8 +103,6 @@ type CertificateSigningRequestSpec struct { // // The minimum valid value for expirationSeconds is 600, i.e. 10 minutes. // - // As of v1.22, this field is beta and is controlled via the CSRDuration feature gate. - // // +optional ExpirationSeconds *int32 `json:"expirationSeconds,omitempty" protobuf:"varint,8,opt,name=expirationSeconds"` diff --git a/staging/src/k8s.io/api/certificates/v1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/certificates/v1/types_swagger_doc_generated.go index 2714584eda5..0dc8a4c69b3 100644 --- a/staging/src/k8s.io/api/certificates/v1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/certificates/v1/types_swagger_doc_generated.go @@ -64,7 +64,7 @@ var map_CertificateSigningRequestSpec = map[string]string{ "": "CertificateSigningRequestSpec contains the certificate request.", "request": "request contains an x509 certificate signing request encoded in a \"CERTIFICATE REQUEST\" PEM block. When serialized as JSON or YAML, the data is additionally base64-encoded.", "signerName": "signerName indicates the requested signer, and is a qualified name.\n\nList/watch requests for CertificateSigningRequests can filter on this field using a \"spec.signerName=NAME\" fieldSelector.\n\nWell-known Kubernetes signers are:\n 1. \"kubernetes.io/kube-apiserver-client\": issues client certificates that can be used to authenticate to kube-apiserver.\n Requests for this signer are never auto-approved by kube-controller-manager, can be issued by the \"csrsigning\" controller in kube-controller-manager.\n 2. \"kubernetes.io/kube-apiserver-client-kubelet\": issues client certificates that kubelets use to authenticate to kube-apiserver.\n Requests for this signer can be auto-approved by the \"csrapproving\" controller in kube-controller-manager, and can be issued by the \"csrsigning\" controller in kube-controller-manager.\n 3. \"kubernetes.io/kubelet-serving\" issues serving certificates that kubelets use to serve TLS endpoints, which kube-apiserver can connect to securely.\n Requests for this signer are never auto-approved by kube-controller-manager, and can be issued by the \"csrsigning\" controller in kube-controller-manager.\n\nMore details are available at https://k8s.io/docs/reference/access-authn-authz/certificate-signing-requests/#kubernetes-signers\n\nCustom signerNames can also be specified. The signer defines:\n 1. Trust distribution: how trust (CA bundles) are distributed.\n 2. Permitted subjects: and behavior when a disallowed subject is requested.\n 3. Required, permitted, or forbidden x509 extensions in the request (including whether subjectAltNames are allowed, which types, restrictions on allowed values) and behavior when a disallowed extension is requested.\n 4. Required, permitted, or forbidden key usages / extended key usages.\n 5. Expiration/certificate lifetime: whether it is fixed by the signer, configurable by the admin.\n 6. Whether or not requests for CA certificates are allowed.", - "expirationSeconds": "expirationSeconds is the requested duration of validity of the issued certificate. The certificate signer may issue a certificate with a different validity duration so a client must check the delta between the notBefore and and notAfter fields in the issued certificate to determine the actual duration.\n\nThe v1.22+ in-tree implementations of the well-known Kubernetes signers will honor this field as long as the requested duration is not greater than the maximum duration they will honor per the --cluster-signing-duration CLI flag to the Kubernetes controller manager.\n\nCertificate signers may not honor this field for various reasons:\n\n 1. Old signer that is unaware of the field (such as the in-tree\n implementations prior to v1.22)\n 2. Signer whose configured maximum is shorter than the requested duration\n 3. Signer whose configured minimum is longer than the requested duration\n\nThe minimum valid value for expirationSeconds is 600, i.e. 10 minutes.\n\nAs of v1.22, this field is beta and is controlled via the CSRDuration feature gate.", + "expirationSeconds": "expirationSeconds is the requested duration of validity of the issued certificate. The certificate signer may issue a certificate with a different validity duration so a client must check the delta between the notBefore and and notAfter fields in the issued certificate to determine the actual duration.\n\nThe v1.22+ in-tree implementations of the well-known Kubernetes signers will honor this field as long as the requested duration is not greater than the maximum duration they will honor per the --cluster-signing-duration CLI flag to the Kubernetes controller manager.\n\nCertificate signers may not honor this field for various reasons:\n\n 1. Old signer that is unaware of the field (such as the in-tree\n implementations prior to v1.22)\n 2. Signer whose configured maximum is shorter than the requested duration\n 3. Signer whose configured minimum is longer than the requested duration\n\nThe minimum valid value for expirationSeconds is 600, i.e. 10 minutes.", "usages": "usages specifies a set of key usages requested in the issued certificate.\n\nRequests for TLS client certificates typically request: \"digital signature\", \"key encipherment\", \"client auth\".\n\nRequests for TLS serving certificates typically request: \"key encipherment\", \"digital signature\", \"server auth\".\n\nValid values are:\n \"signing\", \"digital signature\", \"content commitment\",\n \"key encipherment\", \"key agreement\", \"data encipherment\",\n \"cert sign\", \"crl sign\", \"encipher only\", \"decipher only\", \"any\",\n \"server auth\", \"client auth\",\n \"code signing\", \"email protection\", \"s/mime\",\n \"ipsec end system\", \"ipsec tunnel\", \"ipsec user\",\n \"timestamping\", \"ocsp signing\", \"microsoft sgc\", \"netscape sgc\"", "username": "username contains the name of the user that created the CertificateSigningRequest. Populated by the API server on creation and immutable.", "uid": "uid contains the uid of the user that created the CertificateSigningRequest. Populated by the API server on creation and immutable.", diff --git a/staging/src/k8s.io/api/certificates/v1beta1/generated.proto b/staging/src/k8s.io/api/certificates/v1beta1/generated.proto index 9f167a774af..e246fba021c 100644 --- a/staging/src/k8s.io/api/certificates/v1beta1/generated.proto +++ b/staging/src/k8s.io/api/certificates/v1beta1/generated.proto @@ -119,8 +119,6 @@ message CertificateSigningRequestSpec { // // The minimum valid value for expirationSeconds is 600, i.e. 10 minutes. // - // As of v1.22, this field is beta and is controlled via the CSRDuration feature gate. - // // +optional optional int32 expirationSeconds = 8; diff --git a/staging/src/k8s.io/api/certificates/v1beta1/types.go b/staging/src/k8s.io/api/certificates/v1beta1/types.go index 031ef77550b..877312d97e3 100644 --- a/staging/src/k8s.io/api/certificates/v1beta1/types.go +++ b/staging/src/k8s.io/api/certificates/v1beta1/types.go @@ -84,8 +84,6 @@ type CertificateSigningRequestSpec struct { // // The minimum valid value for expirationSeconds is 600, i.e. 10 minutes. // - // As of v1.22, this field is beta and is controlled via the CSRDuration feature gate. - // // +optional ExpirationSeconds *int32 `json:"expirationSeconds,omitempty" protobuf:"varint,8,opt,name=expirationSeconds"` diff --git a/staging/src/k8s.io/api/certificates/v1beta1/types_swagger_doc_generated.go b/staging/src/k8s.io/api/certificates/v1beta1/types_swagger_doc_generated.go index 816a618cb9e..d3f318150cb 100644 --- a/staging/src/k8s.io/api/certificates/v1beta1/types_swagger_doc_generated.go +++ b/staging/src/k8s.io/api/certificates/v1beta1/types_swagger_doc_generated.go @@ -54,7 +54,7 @@ var map_CertificateSigningRequestSpec = map[string]string{ "": "CertificateSigningRequestSpec contains the certificate request.", "request": "Base64-encoded PKCS#10 CSR data", "signerName": "Requested signer for the request. It is a qualified name in the form: `scope-hostname.io/name`. If empty, it will be defaulted:\n 1. If it's a kubelet client certificate, it is assigned\n \"kubernetes.io/kube-apiserver-client-kubelet\".\n 2. If it's a kubelet serving certificate, it is assigned\n \"kubernetes.io/kubelet-serving\".\n 3. Otherwise, it is assigned \"kubernetes.io/legacy-unknown\".\nDistribution of trust for signers happens out of band. You can select on this field using `spec.signerName`.", - "expirationSeconds": "expirationSeconds is the requested duration of validity of the issued certificate. The certificate signer may issue a certificate with a different validity duration so a client must check the delta between the notBefore and and notAfter fields in the issued certificate to determine the actual duration.\n\nThe v1.22+ in-tree implementations of the well-known Kubernetes signers will honor this field as long as the requested duration is not greater than the maximum duration they will honor per the --cluster-signing-duration CLI flag to the Kubernetes controller manager.\n\nCertificate signers may not honor this field for various reasons:\n\n 1. Old signer that is unaware of the field (such as the in-tree\n implementations prior to v1.22)\n 2. Signer whose configured maximum is shorter than the requested duration\n 3. Signer whose configured minimum is longer than the requested duration\n\nThe minimum valid value for expirationSeconds is 600, i.e. 10 minutes.\n\nAs of v1.22, this field is beta and is controlled via the CSRDuration feature gate.", + "expirationSeconds": "expirationSeconds is the requested duration of validity of the issued certificate. The certificate signer may issue a certificate with a different validity duration so a client must check the delta between the notBefore and and notAfter fields in the issued certificate to determine the actual duration.\n\nThe v1.22+ in-tree implementations of the well-known Kubernetes signers will honor this field as long as the requested duration is not greater than the maximum duration they will honor per the --cluster-signing-duration CLI flag to the Kubernetes controller manager.\n\nCertificate signers may not honor this field for various reasons:\n\n 1. Old signer that is unaware of the field (such as the in-tree\n implementations prior to v1.22)\n 2. Signer whose configured maximum is shorter than the requested duration\n 3. Signer whose configured minimum is longer than the requested duration\n\nThe minimum valid value for expirationSeconds is 600, i.e. 10 minutes.", "usages": "allowedUsages specifies a set of usage contexts the key will be valid for. See: https://tools.ietf.org/html/rfc5280#section-4.2.1.3\n https://tools.ietf.org/html/rfc5280#section-4.2.1.12\nValid values are:\n \"signing\",\n \"digital signature\",\n \"content commitment\",\n \"key encipherment\",\n \"key agreement\",\n \"data encipherment\",\n \"cert sign\",\n \"crl sign\",\n \"encipher only\",\n \"decipher only\",\n \"any\",\n \"server auth\",\n \"client auth\",\n \"code signing\",\n \"email protection\",\n \"s/mime\",\n \"ipsec end system\",\n \"ipsec tunnel\",\n \"ipsec user\",\n \"timestamping\",\n \"ocsp signing\",\n \"microsoft sgc\",\n \"netscape sgc\"", "username": "Information about the requesting user. See user.Info interface for details.", "uid": "UID information about the requesting user. See user.Info interface for details.", diff --git a/test/e2e/auth/certificates.go b/test/e2e/auth/certificates.go index ba1be96573b..26c0d9b6706 100644 --- a/test/e2e/auth/certificates.go +++ b/test/e2e/auth/certificates.go @@ -217,11 +217,10 @@ var _ = SIGDescribe("Certificates API [Privileged:ClusterAdmin]", func() { csrTemplate := &certificatesv1.CertificateSigningRequest{ ObjectMeta: metav1.ObjectMeta{GenerateName: "e2e-example-csr-"}, Spec: certificatesv1.CertificateSigningRequestSpec{ - Request: csrData, - SignerName: signerName, - // TODO(enj): check for expirationSeconds field persistence once the feature is GA - // ExpirationSeconds: csr.DurationToExpirationSeconds(time.Hour), - Usages: []certificatesv1.KeyUsage{certificatesv1.UsageDigitalSignature, certificatesv1.UsageKeyEncipherment, certificatesv1.UsageServerAuth}, + Request: csrData, + SignerName: signerName, + ExpirationSeconds: csr.DurationToExpirationSeconds(time.Hour), + Usages: []certificatesv1.KeyUsage{certificatesv1.UsageDigitalSignature, certificatesv1.UsageKeyEncipherment, certificatesv1.UsageServerAuth}, }, } @@ -294,8 +293,7 @@ var _ = SIGDescribe("Certificates API [Privileged:ClusterAdmin]", func() { gottenCSR, err := csrClient.Get(context.TODO(), createdCSR.Name, metav1.GetOptions{}) framework.ExpectNoError(err) framework.ExpectEqual(gottenCSR.UID, createdCSR.UID) - // TODO(enj): check for expirationSeconds field persistence once the feature is GA - // framework.ExpectEqual(gottenCSR.Spec.ExpirationSeconds, csr.DurationToExpirationSeconds(time.Hour)) + framework.ExpectEqual(gottenCSR.Spec.ExpirationSeconds, csr.DurationToExpirationSeconds(time.Hour)) ginkgo.By("listing") csrs, err := csrClient.List(context.TODO(), metav1.ListOptions{FieldSelector: "spec.signerName=" + signerName})