Skip to content

Commit 498dc3f

Browse files
committed
Change validity / refresh for some certs which should not be affected by
dev cycle rotation change
1 parent 4950dc3 commit 498dc3f

File tree

1 file changed

+25
-16
lines changed

1 file changed

+25
-16
lines changed

pkg/operator/certrotationcontroller/certrotationcontroller.go

Lines changed: 25 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -124,9 +124,15 @@ func newCertRotationController(
124124
// This must be reverted before we ship
125125
rotationDay = rotationDay / 60
126126

127-
monthPeriod := rotationDay * 30
128-
yearPeriod := monthPeriod * 12
129-
tenMonthPeriod := monthPeriod * 10
127+
// Some certificates should not be affected by development cycle rotation
128+
devRotationExceptionDay := 24 * time.Hour
129+
130+
monthPeriod := 30 * rotationDay
131+
devRotationExceptionMonth := 30 * devRotationExceptionDay
132+
yearPeriod := 365 * rotationDay
133+
devRotationExceptionYear := 365 * devRotationExceptionDay
134+
tenMonthPeriod := 292 * rotationDay
135+
devRotationExceptionTenMonth := 292 * devRotationExceptionDay
130136

131137
// Set custom rotation duration when FeatureShortCertRotation is enabled
132138
featureGates, err := featureGateAccessor.CurrentFeatureGates()
@@ -136,8 +142,11 @@ func newCertRotationController(
136142

137143
if featureGates.Enabled(features.FeatureShortCertRotation) {
138144
monthPeriod = 2 * time.Hour
145+
devRotationExceptionMonth = monthPeriod
139146
yearPeriod = 3 * time.Hour
147+
devRotationExceptionYear = yearPeriod
140148
tenMonthPeriod = 150 * time.Minute
149+
devRotationExceptionTenMonth = tenMonthPeriod
141150
}
142151
klog.Infof("Setting monthPeriod to %v, yearPeriod to %v, tenMonthPeriod to %v", monthPeriod, yearPeriod, tenMonthPeriod)
143152

@@ -206,10 +215,10 @@ func newCertRotationController(
206215
AutoRegenerateAfterOfflineExpiry: "https://github.com/openshift/cluster-kube-apiserver-operator/pull/1631,'[sig-cli] Kubectl logs logs should be able to retrieve and filter logs [Conformance] [Suite:openshift/conformance/parallel/minimal] [Suite:k8s]'",
207216
Description: "Signer for the kube-apiserver-to-kubelet-client so kubelets can recognize the kube-apiserver.",
208217
},
209-
Validity: monthPeriod * 2, // this comes from the installer
218+
Validity: devRotationExceptionYear, // this comes from the installer
210219
// Refresh set to 80% of the validity.
211220
// This range is consistent with most other signers defined in this pkg.
212-
Refresh: monthPeriod,
221+
Refresh: devRotationExceptionMonth,
213222
RefreshOnlyWhenExpired: refreshOnlyWhenExpired,
214223
Informer: kubeInformersForNamespaces.InformersFor(operatorclient.OperatorNamespace).Core().V1().Secrets(),
215224
Lister: kubeInformersForNamespaces.InformersFor(operatorclient.OperatorNamespace).Core().V1().Secrets().Lister(),
@@ -552,8 +561,8 @@ func newCertRotationController(
552561
AutoRegenerateAfterOfflineExpiry: "https://github.com/openshift/cluster-kube-apiserver-operator/pull/1631,'operator conditions kube-apiserver'",
553562
Description: "Signer for kube-controller-manager and kube-scheduler client certificates.",
554563
},
555-
Validity: 2 * monthPeriod,
556-
Refresh: monthPeriod,
564+
Validity: 2 * devRotationExceptionMonth,
565+
Refresh: devRotationExceptionMonth,
557566
RefreshOnlyWhenExpired: refreshOnlyWhenExpired,
558567
Informer: kubeInformersForNamespaces.InformersFor(operatorclient.OperatorNamespace).Core().V1().Secrets(),
559568
Lister: kubeInformersForNamespaces.InformersFor(operatorclient.OperatorNamespace).Core().V1().Secrets().Lister(),
@@ -607,8 +616,8 @@ func newCertRotationController(
607616
AutoRegenerateAfterOfflineExpiry: "https://github.com/openshift/cluster-kube-apiserver-operator/pull/1631,'operator conditions kube-apiserver'",
608617
Description: "Signer for kube-controller-manager and kube-scheduler client certificates.",
609618
},
610-
Validity: 2 * monthPeriod,
611-
Refresh: monthPeriod,
619+
Validity: 2 * devRotationExceptionMonth,
620+
Refresh: devRotationExceptionMonth,
612621
RefreshOnlyWhenExpired: refreshOnlyWhenExpired,
613622
Informer: kubeInformersForNamespaces.InformersFor(operatorclient.OperatorNamespace).Core().V1().Secrets(),
614623
Lister: kubeInformersForNamespaces.InformersFor(operatorclient.OperatorNamespace).Core().V1().Secrets().Lister(),
@@ -662,8 +671,8 @@ func newCertRotationController(
662671
AutoRegenerateAfterOfflineExpiry: "https://github.com/openshift/cluster-kube-apiserver-operator/pull/1631,'operator conditions kube-apiserver'",
663672
Description: "Signer for kube-controller-manager and kube-scheduler client certificates.",
664673
},
665-
Validity: 2 * monthPeriod,
666-
Refresh: monthPeriod,
674+
Validity: 2 * devRotationExceptionMonth,
675+
Refresh: devRotationExceptionMonth,
667676
RefreshOnlyWhenExpired: refreshOnlyWhenExpired,
668677
Informer: kubeInformersForNamespaces.InformersFor(operatorclient.OperatorNamespace).Core().V1().Secrets(),
669678
Lister: kubeInformersForNamespaces.InformersFor(operatorclient.OperatorNamespace).Core().V1().Secrets().Lister(),
@@ -716,8 +725,8 @@ func newCertRotationController(
716725
AutoRegenerateAfterOfflineExpiry: "https://github.com/openshift/cluster-kube-apiserver-operator/pull/1631,'operator conditions kube-apiserver'",
717726
Description: "Signer for kube-controller-manager and kube-scheduler client certificates.",
718727
},
719-
Validity: 2 * monthPeriod,
720-
Refresh: monthPeriod,
728+
Validity: 2 * devRotationExceptionMonth,
729+
Refresh: devRotationExceptionMonth,
721730
RefreshOnlyWhenExpired: refreshOnlyWhenExpired,
722731
Informer: kubeInformersForNamespaces.InformersFor(operatorclient.OperatorNamespace).Core().V1().Secrets(),
723732
Lister: kubeInformersForNamespaces.InformersFor(operatorclient.OperatorNamespace).Core().V1().Secrets().Lister(),
@@ -771,10 +780,10 @@ func newCertRotationController(
771780
AutoRegenerateAfterOfflineExpiry: "https://github.com/openshift/cluster-kube-apiserver-operator/pull/1631,'operator conditions kube-apiserver'",
772781
Description: "Signer for the per-master-debugging-client.",
773782
},
774-
Validity: yearPeriod,
783+
Validity: devRotationExceptionYear,
775784
// Refresh set to 80% of the validity.
776785
// This range is consistent with most other signers defined in this pkg.
777-
Refresh: tenMonthPeriod,
786+
Refresh: devRotationExceptionTenMonth,
778787
RefreshOnlyWhenExpired: refreshOnlyWhenExpired,
779788
Informer: kubeInformersForNamespaces.InformersFor(operatorclient.OperatorNamespace).Core().V1().Secrets(),
780789
Lister: kubeInformersForNamespaces.InformersFor(operatorclient.OperatorNamespace).Core().V1().Secrets().Lister(),
@@ -805,7 +814,7 @@ func newCertRotationController(
805814
// This needs to live longer then control plane certs so there is high chance that if a cluster breaks
806815
// because of expired certs these are still valid to use for collecting data using localhost-recovery
807816
// endpoint with long lived serving certs for localhost.
808-
Validity: 2 * yearPeriod,
817+
Validity: 2 * devRotationExceptionYear,
809818
// We rotate sooner so certs are always valid for 90 days (30 days more then kube-control-plane-signer)
810819
Refresh: monthPeriod,
811820
RefreshOnlyWhenExpired: refreshOnlyWhenExpired,

0 commit comments

Comments
 (0)