@@ -29,6 +29,7 @@ import (
2929
3030 "sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
3131
32+ certmgrv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
3233 novav1 "github.com/openstack-k8s-operators/nova-operator/api/v1beta1"
3334 corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1"
3435 k8s_errors "k8s.io/apimachinery/pkg/api/errors"
@@ -240,7 +241,7 @@ func ReconcileNova(ctx context.Context, instance *corev1beta1.OpenStackControlPl
240241 tls.API {
241242 API : tls.APIService {
242243 Public : tls.GenericService {
243- SecretName : cellTemplate .NoVNCProxyServiceTemplate .TLS .SecretName ,
244+ SecretName : cellTemplate .NoVNCProxyServiceTemplate .TLS .Service . SecretName ,
244245 },
245246 },
246247 },
@@ -254,8 +255,44 @@ func ReconcileNova(ctx context.Context, instance *corev1beta1.OpenStackControlPl
254255 routedOverrideSpec := endpointDetails .GetEndpointServiceOverrides ()
255256 cellTemplate .NoVNCProxyServiceTemplate .Override .Service = ptr .To (routedOverrideSpec [service .EndpointPublic ])
256257 // update NoVNCProxy cert secret
257- cellTemplate .NoVNCProxyServiceTemplate .TLS .SecretName =
258+ cellTemplate .NoVNCProxyServiceTemplate .TLS .Service . SecretName =
258259 endpointDetails .GetEndptCertSecret (service .EndpointPublic )
260+
261+ // create novncproxy vencrypt cert
262+ if instance .Spec .TLS .PodLevel .Enabled {
263+ serviceName := endpointDetails .EndpointDetails [service .EndpointPublic ].Service .Spec .Name
264+ certRequest := certmanager.CertificateRequest {
265+ IssuerName : instance .GetLibvirtIssuer (),
266+ CertName : nova .Name + "-novncproxy-" + cellName + "-vencrypt" ,
267+ CommonName : ptr .To (fmt .Sprintf ("%s.%s.svc" , serviceName , instance .Namespace )),
268+ Subject : & certmgrv1.X509Subject {
269+ Organizations : []string {fmt .Sprintf ("%s.%s" , instance .Namespace , ClusterInternalDomain )},
270+ },
271+ Usages : []certmgrv1.KeyUsage {
272+ certmgrv1 .UsageKeyEncipherment ,
273+ certmgrv1 .UsageDigitalSignature ,
274+ certmgrv1 .UsageServerAuth ,
275+ certmgrv1 .UsageClientAuth ,
276+ },
277+ }
278+ if instance .Spec .TLS .PodLevel .Libvirt .Cert .Duration != nil {
279+ certRequest .Duration = & instance .Spec .TLS .PodLevel .Libvirt .Cert .Duration .Duration
280+ }
281+ if instance .Spec .TLS .PodLevel .Libvirt .Cert .RenewBefore != nil {
282+ certRequest .RenewBefore = & instance .Spec .TLS .PodLevel .Libvirt .Cert .RenewBefore .Duration
283+ }
284+ certSecret , ctrlResult , err := certmanager .EnsureCert (
285+ ctx ,
286+ helper ,
287+ certRequest ,
288+ nil )
289+ if err != nil {
290+ return ctrlResult , err
291+ } else if (ctrlResult != ctrl.Result {}) {
292+ return ctrlResult , nil
293+ }
294+ cellTemplate .NoVNCProxyServiceTemplate .TLS .Vencrypt .SecretName = & certSecret .Name
295+ }
259296 }
260297 }
261298
0 commit comments