Skip to content

Commit a08323d

Browse files
Merge pull request #1873 from vrutkovs/cert-annotations-not-before-not-after-v2
OCPBUGS-44842: Set not-before/not-after annotations
2 parents 7e89682 + 80afb73 commit a08323d

File tree

11 files changed

+402
-132
lines changed

11 files changed

+402
-132
lines changed

go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ require (
1515
github.com/openshift/api v0.0.0-20250710004639-926605d3338b
1616
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee
1717
github.com/openshift/client-go v0.0.0-20250710075018-396b36f983ee
18-
github.com/openshift/library-go v0.0.0-20250710130336-73c7662bc565
18+
github.com/openshift/library-go v0.0.0-20250724123005-03d85c4e997c
1919
github.com/pkg/profile v1.7.0 // indirect
2020
github.com/prometheus/client_golang v1.22.0
2121
github.com/spf13/cobra v1.8.1

go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,8 +166,8 @@ github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee h1:+S
166166
github.com/openshift/build-machinery-go v0.0.0-20250530140348-dc5b2804eeee/go.mod h1:8jcm8UPtg2mCAsxfqKil1xrmRMI3a+XU2TZ9fF8A7TE=
167167
github.com/openshift/client-go v0.0.0-20250710075018-396b36f983ee h1:tOtrrxfDEW8hK3eEsHqxsXurq/D6LcINGfprkQC3hqY=
168168
github.com/openshift/client-go v0.0.0-20250710075018-396b36f983ee/go.mod h1:zhRiYyNMk89llof2qEuGPWPD+joQPhCRUc2IK0SB510=
169-
github.com/openshift/library-go v0.0.0-20250710130336-73c7662bc565 h1:DtyzonCpVZxqYp4rp2cCRwBTEXZWw5fX9YE0tCM5hi8=
170-
github.com/openshift/library-go v0.0.0-20250710130336-73c7662bc565/go.mod h1:tptKNust9MdRI0p90DoBSPHIrBa9oh+Rok59tF0vT8c=
169+
github.com/openshift/library-go v0.0.0-20250724123005-03d85c4e997c h1:KG1U3r4ocDe39/Mvc6oxgDoi9YlCrWAor6n+uvJzRok=
170+
github.com/openshift/library-go v0.0.0-20250724123005-03d85c4e997c/go.mod h1:tptKNust9MdRI0p90DoBSPHIrBa9oh+Rok59tF0vT8c=
171171
github.com/orisano/pixelmatch v0.0.0-20220722002657-fb0b55479cde/go.mod h1:nZgzbfBr3hhjoZnS66nKrHmduYNpc34ny7RK4z5/HM0=
172172
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
173173
github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINEl0=

pkg/operator/nodekubeconfigcontroller/nodekubeconfigcontroller.go

Lines changed: 18 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@ import (
1414
"github.com/openshift/cluster-kube-apiserver-operator/bindata"
1515
"github.com/openshift/cluster-kube-apiserver-operator/pkg/operator/operatorclient"
1616
"github.com/openshift/library-go/pkg/controller/factory"
17+
"github.com/openshift/library-go/pkg/operator/certrotation"
1718
"github.com/openshift/library-go/pkg/operator/events"
1819
"github.com/openshift/library-go/pkg/operator/resource/resourceapply"
1920
"github.com/openshift/library-go/pkg/operator/resource/resourceread"
@@ -29,10 +30,10 @@ const workQueueKey = "key"
2930
type NodeKubeconfigController struct {
3031
operatorClient v1helpers.StaticPodOperatorClient
3132

32-
kubeClient kubernetes.Interface
33-
configMapLister corev1listers.ConfigMapLister
34-
secretLister corev1listers.SecretLister
35-
infrastuctureLister configv1listers.InfrastructureLister
33+
kubeClient kubernetes.Interface
34+
configMapLister corev1listers.ConfigMapLister
35+
secretLister corev1listers.SecretLister
36+
infrastructureLister configv1listers.InfrastructureLister
3637
}
3738

3839
func NewNodeKubeconfigController(
@@ -43,11 +44,11 @@ func NewNodeKubeconfigController(
4344
eventRecorder events.Recorder,
4445
) factory.Controller {
4546
c := &NodeKubeconfigController{
46-
operatorClient: operatorClient,
47-
kubeClient: kubeClient,
48-
configMapLister: kubeInformersForNamespaces.ConfigMapLister(),
49-
secretLister: kubeInformersForNamespaces.SecretLister(),
50-
infrastuctureLister: infrastuctureInformer.Lister(),
47+
operatorClient: operatorClient,
48+
kubeClient: kubeClient,
49+
configMapLister: kubeInformersForNamespaces.ConfigMapLister(),
50+
secretLister: kubeInformersForNamespaces.SecretLister(),
51+
infrastructureLister: infrastuctureInformer.Lister(),
5152
}
5253

5354
return factory.New().WithInformers(
@@ -85,7 +86,7 @@ func (c NodeKubeconfigController) sync(ctx context.Context, syncContext factory.
8586
c.kubeClient.CoreV1(),
8687
c.secretLister,
8788
c.configMapLister,
88-
c.infrastuctureLister,
89+
c.infrastructureLister,
8990
syncContext.Recorder(),
9091
)
9192
if err != nil {
@@ -152,6 +153,13 @@ func ensureNodeKubeconfigs(ctx context.Context, client coreclientv1.CoreV1Interf
152153
requiredSecret.Annotations = map[string]string{}
153154
}
154155
requiredSecret.Annotations[annotations.OpenShiftComponent] = "kube-apiserver"
156+
// Copy not-before/not-after annotations from systemAdminClientCert
157+
if len(systemAdminCredsSecret.Annotations[certrotation.CertificateNotBeforeAnnotation]) > 0 {
158+
requiredSecret.Annotations[certrotation.CertificateNotBeforeAnnotation] = systemAdminCredsSecret.Annotations[certrotation.CertificateNotBeforeAnnotation]
159+
}
160+
if len(systemAdminCredsSecret.Annotations[certrotation.CertificateNotAfterAnnotation]) > 0 {
161+
requiredSecret.Annotations[certrotation.CertificateNotAfterAnnotation] = systemAdminCredsSecret.Annotations[certrotation.CertificateNotAfterAnnotation]
162+
}
155163

156164
_, _, err = resourceapply.ApplySecret(ctx, client, recorder, requiredSecret)
157165
if err != nil {

0 commit comments

Comments
 (0)