mirror of
https://github.com/k3s-io/kubernetes.git
synced 2025-07-19 09:52:49 +00:00
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.
This commit is contained in:
parent
56062f7f4f
commit
e29ac0f8be
2
api/openapi-spec/swagger.json
generated
2
api/openapi-spec/swagger.json
generated
@ -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"
|
||||
},
|
||||
|
@ -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"
|
||||
},
|
||||
|
@ -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
|
||||
|
||||
|
@ -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
|
||||
}
|
||||
|
@ -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)
|
||||
})
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -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},
|
||||
|
4
pkg/generated/openapi/zz_generated.openapi.go
generated
4
pkg/generated/openapi/zz_generated.openapi.go
generated
@ -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",
|
||||
},
|
||||
|
@ -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
|
||||
|
@ -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{}
|
||||
|
@ -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{}
|
||||
|
@ -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) {
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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"`
|
||||
|
||||
|
@ -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.",
|
||||
|
@ -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;
|
||||
|
||||
|
@ -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"`
|
||||
|
||||
|
@ -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.",
|
||||
|
@ -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})
|
||||
|
Loading…
Reference in New Issue
Block a user