@@ -98,6 +98,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
9898 instance .Status .TLS .CAList = []corev1.TLSCAStatus {}
9999 // create CA for ingress and public podLevel termination
100100 issuerLabels := map [string ]string {certmanager .RootCAIssuerPublicLabel : "" }
101+ issuerAnnotations := getIssuerAnnotations (& instance .Spec .TLS .Ingress .Cert )
101102 if ! instance .Spec .TLS .Ingress .Ca .IsCustomIssuer () {
102103 ctrlResult , err = ensureRootCA (
103104 ctx ,
@@ -106,6 +107,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
106107 issuerReq ,
107108 tls .DefaultCAPrefix + string (service .EndpointPublic ),
108109 issuerLabels ,
110+ issuerAnnotations ,
109111 bundle ,
110112 caOnlyBundle ,
111113 instance .Spec .TLS .Ingress .Ca ,
@@ -119,7 +121,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
119121 customIssuer := * instance .Spec .TLS .Ingress .Ca .CustomIssuer
120122
121123 // add CA labelselector to issuer
122- caCertSecretName , err := addIssuerLabel (ctx , helper , customIssuer , instance .Namespace , issuerLabels )
124+ caCertSecretName , err := addIssuerLabelAnnotation (ctx , helper , customIssuer , instance .Namespace , issuerLabels , issuerAnnotations )
123125 if err != nil {
124126 instance .Status .Conditions .Set (condition .FalseCondition (
125127 corev1 .OpenStackControlPlaneCAReadyCondition ,
@@ -162,6 +164,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
162164
163165 // create CA for internal podLevel termination
164166 issuerLabels = map [string ]string {certmanager .RootCAIssuerInternalLabel : "" }
167+ issuerAnnotations = getIssuerAnnotations (& instance .Spec .TLS .PodLevel .Internal .Cert )
165168 if ! instance .Spec .TLS .PodLevel .Internal .Ca .IsCustomIssuer () {
166169 ctrlResult , err = ensureRootCA (
167170 ctx ,
@@ -170,6 +173,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
170173 issuerReq ,
171174 tls .DefaultCAPrefix + string (service .EndpointInternal ),
172175 issuerLabels ,
176+ issuerAnnotations ,
173177 bundle ,
174178 caOnlyBundle ,
175179 instance .Spec .TLS .PodLevel .Internal .Ca ,
@@ -182,7 +186,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
182186 } else {
183187 customIssuer := * instance .Spec .TLS .PodLevel .Internal .Ca .CustomIssuer
184188 // add CA labelselector to issuer
185- caCertSecretName , err := addIssuerLabel (ctx , helper , customIssuer , instance .Namespace , issuerLabels )
189+ caCertSecretName , err := addIssuerLabelAnnotation (ctx , helper , customIssuer , instance .Namespace , issuerLabels , issuerAnnotations )
186190 if err != nil {
187191 instance .Status .Conditions .Set (condition .FalseCondition (
188192 corev1 .OpenStackControlPlaneCAReadyCondition ,
@@ -226,6 +230,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
226230
227231 // create CA for libvirt
228232 issuerLabels = map [string ]string {certmanager .RootCAIssuerLibvirtLabel : "" }
233+ issuerAnnotations = getIssuerAnnotations (& instance .Spec .TLS .PodLevel .Libvirt .Cert )
229234 if ! instance .Spec .TLS .PodLevel .Libvirt .Ca .IsCustomIssuer () {
230235 ctrlResult , err = ensureRootCA (
231236 ctx ,
@@ -234,6 +239,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
234239 issuerReq ,
235240 corev1 .LibvirtCaName ,
236241 issuerLabels ,
242+ issuerAnnotations ,
237243 bundle ,
238244 caOnlyBundle ,
239245 instance .Spec .TLS .PodLevel .Libvirt .Ca ,
@@ -246,7 +252,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
246252 } else {
247253 customIssuer := * instance .Spec .TLS .PodLevel .Libvirt .Ca .CustomIssuer
248254 // add CA labelselector to issuer
249- caCertSecretName , err := addIssuerLabel (ctx , helper , customIssuer , instance .Namespace , issuerLabels )
255+ caCertSecretName , err := addIssuerLabelAnnotation (ctx , helper , customIssuer , instance .Namespace , issuerLabels , issuerAnnotations )
250256 if err != nil {
251257 instance .Status .Conditions .Set (condition .FalseCondition (
252258 corev1 .OpenStackControlPlaneCAReadyCondition ,
@@ -289,6 +295,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
289295
290296 // create CA for ovn
291297 issuerLabels = map [string ]string {certmanager .RootCAIssuerOvnDBLabel : "" }
298+ issuerAnnotations = getIssuerAnnotations (& instance .Spec .TLS .PodLevel .Ovn .Cert )
292299 if ! instance .Spec .TLS .PodLevel .Ovn .Ca .IsCustomIssuer () {
293300 ctrlResult , err = ensureRootCA (
294301 ctx ,
@@ -297,6 +304,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
297304 issuerReq ,
298305 corev1 .OvnDbCaName ,
299306 issuerLabels ,
307+ issuerAnnotations ,
300308 bundle ,
301309 caOnlyBundle ,
302310 instance .Spec .TLS .PodLevel .Ovn .Ca ,
@@ -309,7 +317,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
309317 } else {
310318 customIssuer := * instance .Spec .TLS .PodLevel .Ovn .Ca .CustomIssuer
311319 // add CA labelselector to issuer
312- caCertSecretName , err := addIssuerLabel (ctx , helper , customIssuer , instance .Namespace , issuerLabels )
320+ caCertSecretName , err := addIssuerLabelAnnotation (ctx , helper , customIssuer , instance .Namespace , issuerLabels , issuerAnnotations )
313321 if err != nil {
314322 instance .Status .Conditions .Set (condition .FalseCondition (
315323 corev1 .OpenStackControlPlaneCAReadyCondition ,
@@ -448,6 +456,7 @@ func ensureRootCA(
448456 issuerReq * certmgrv1.Issuer ,
449457 caName string ,
450458 labels map [string ]string ,
459+ annotations map [string ]string ,
451460 bundle * caBundle ,
452461 caOnlyBundle * caBundle ,
453462 caCfg corev1.CACertConfig ,
@@ -462,6 +471,7 @@ func ensureRootCA(
462471 issuerReq ,
463472 caName ,
464473 labels ,
474+ annotations ,
465475 caCfg ,
466476 )
467477 if err != nil {
@@ -518,6 +528,7 @@ func createRootCACertAndIssuer(
518528 selfsignedIssuerReq * certmgrv1.Issuer ,
519529 caName string ,
520530 labels map [string ]string ,
531+ annotations map [string ]string ,
521532 caCfg corev1.CACertConfig ,
522533) ([]byte , ctrl.Result , error ) {
523534 // create RootCA Certificate used to sign certificates
@@ -570,6 +581,7 @@ func createRootCACertAndIssuer(
570581 caCertReq .Name ,
571582 instance .GetNamespace (),
572583 labels ,
584+ annotations ,
573585 caCertReq .Name ,
574586 )
575587
@@ -740,12 +752,13 @@ func (cab *caBundle) getBundlePEM() string {
740752 return bundleData
741753}
742754
743- func addIssuerLabel (
755+ func addIssuerLabelAnnotation (
744756 ctx context.Context ,
745757 helper * helper.Helper ,
746758 name string ,
747759 namespace string ,
748760 labels map [string ]string ,
761+ annotations map [string ]string ,
749762) (string , error ) {
750763 var caCertSecretName string
751764 // get issuer
@@ -764,6 +777,8 @@ func addIssuerLabel(
764777 beforeIssuer := issuer .DeepCopyObject ().(client.Object )
765778 // merge labels
766779 issuer .Labels = util .MergeMaps (issuer .Labels , labels )
780+ // merge annotations
781+ issuer .Annotations = util .MergeMaps (issuer .Annotations , annotations )
767782
768783 // patch issuer
769784 patch := client .MergeFrom (beforeIssuer )
@@ -791,3 +806,19 @@ func addIssuerLabel(
791806
792807 return caCertSecretName , nil
793808}
809+
810+ func getIssuerAnnotations (certConfig * corev1.CertConfig ) map [string ]string {
811+ annotations := map [string ]string {}
812+ certDuration := certConfig .GetDurationHours ()
813+ if certDuration == "" {
814+ certDuration = certmanager .CertDefaultDuration
815+ }
816+ annotations [certmanager .CertDurationAnnotation ] = certDuration
817+
818+ certRenewBefore := certConfig .GetRenewBeforeHours ()
819+ if certRenewBefore != "" {
820+ annotations [certmanager .CertRenewBeforeAnnotation ] = certRenewBefore
821+ }
822+
823+ return annotations
824+ }
0 commit comments