Skip to content

Commit 6dfe381

Browse files
authored
Merge pull request #6193 from jabellard/leaf-cert-validatity-imp
Add Support to Configure Leaf Certificate Validity Period in Karmada Operator
2 parents 63ad83d + b192c9c commit 6dfe381

File tree

5 files changed

+32
-0
lines changed

5 files changed

+32
-0
lines changed

charts/karmada-operator/crds/operator.karmada.io_karmadas.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -5197,6 +5197,13 @@ spec:
51975197
referenced.
51985198
type: string
51995199
type: object
5200+
leafCertValidityDays:
5201+
description: |-
5202+
LeafCertValidityDays specifies the validity period of leaf certificates (e.g., API Server certificate) in days.
5203+
If not specified, the default validity period of 1 year will be used.
5204+
format: int32
5205+
minimum: 1
5206+
type: integer
52005207
type: object
52015208
featureGates:
52025209
additionalProperties:

operator/config/crds/operator.karmada.io_karmadas.yaml

+7
Original file line numberDiff line numberDiff line change
@@ -5197,6 +5197,13 @@ spec:
51975197
referenced.
51985198
type: string
51995199
type: object
5200+
leafCertValidityDays:
5201+
description: |-
5202+
LeafCertValidityDays specifies the validity period of leaf certificates (e.g., API Server certificate) in days.
5203+
If not specified, the default validity period of 1 year will be used.
5204+
format: int32
5205+
minimum: 1
5206+
type: integer
52005207
type: object
52015208
featureGates:
52025209
additionalProperties:

operator/pkg/apis/operator/v1alpha1/type.go

+6
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,12 @@ type CustomCertificate struct {
133133
// all components that access the APIServer as clients.
134134
// +optional
135135
APIServerCACert *LocalSecretReference `json:"apiServerCACert,omitempty"`
136+
137+
// LeafCertValidityDays specifies the validity period of leaf certificates (e.g., API Server certificate) in days.
138+
// If not specified, the default validity period of 1 year will be used.
139+
// +kubebuilder:validation:Minimum=1
140+
// +optional
141+
LeafCertValidityDays *int32 `json:"leafCertValidityDays,omitempty"`
136142
}
137143

138144
// ImageRegistry represents an image registry as well as the

operator/pkg/apis/operator/v1alpha1/zz_generated.deepcopy.go

+5
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

operator/pkg/tasks/init/cert.go

+7
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@ import (
2020
"context"
2121
"errors"
2222
"fmt"
23+
"time"
2324

2425
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
2526
clientset "k8s.io/client-go/kubernetes"
@@ -200,5 +201,11 @@ func mutateCertConfig(data InitData, cc *certs.CertConfig) error {
200201
}
201202
}
202203

204+
if data.CustomCertificate().LeafCertValidityDays != nil {
205+
certValidityDuration := time.Hour * 24 * time.Duration(*data.CustomCertificate().LeafCertValidityDays)
206+
notAfter := time.Now().Add(certValidityDuration).UTC()
207+
cc.NotAfter = &notAfter
208+
}
209+
203210
return nil
204211
}

0 commit comments

Comments
 (0)