|
4 | 4 | "context" |
5 | 5 | "fmt" |
6 | 6 |
|
| 7 | + certmgrv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1" |
| 8 | + "github.com/openstack-k8s-operators/lib-common/modules/certmanager" |
| 9 | + "github.com/openstack-k8s-operators/lib-common/modules/common/clusterdns" |
7 | 10 | "github.com/openstack-k8s-operators/lib-common/modules/common/condition" |
8 | 11 | "github.com/openstack-k8s-operators/lib-common/modules/common/helper" |
9 | 12 | "github.com/openstack-k8s-operators/lib-common/modules/common/service" |
@@ -122,6 +125,44 @@ func ReconcileIronic(ctx context.Context, instance *corev1beta1.OpenStackControl |
122 | 125 | if instance.Spec.TLS.PodLevel.Enabled { |
123 | 126 | instance.Spec.Ironic.Template.IronicAPI.TLS = ironic.Spec.IronicAPI.TLS |
124 | 127 | instance.Spec.Ironic.Template.IronicInspector.TLS = ironic.Spec.IronicInspector.TLS |
| 128 | + instance.Spec.Ironic.Template.IronicNeutronAgent.TLS = ironic.Spec.IronicNeutronAgent.TLS |
| 129 | + |
| 130 | + serviceName := "ironic" |
| 131 | + clusterDomain := clusterdns.GetDNSClusterDomain() |
| 132 | + // create ovndb client certificate for ironic-neutron-agent |
| 133 | + certRequest := certmanager.CertificateRequest{ |
| 134 | + IssuerName: instance.GetOvnIssuer(), |
| 135 | + CertName: fmt.Sprintf("%s-ovndbs", serviceName), |
| 136 | + Hostnames: []string{ |
| 137 | + fmt.Sprintf("%s.%s.svc", serviceName, instance.Namespace), |
| 138 | + fmt.Sprintf("%s.%s.svc.%s", serviceName, instance.Namespace, clusterDomain), |
| 139 | + }, |
| 140 | + Ips: nil, |
| 141 | + Usages: []certmgrv1.KeyUsage{ |
| 142 | + certmgrv1.UsageKeyEncipherment, |
| 143 | + certmgrv1.UsageDigitalSignature, |
| 144 | + certmgrv1.UsageClientAuth, |
| 145 | + }, |
| 146 | + Labels: map[string]string{ServiceCertSelector: ""}, |
| 147 | + } |
| 148 | + if instance.Spec.TLS.PodLevel.Ovn.Cert.Duration != nil { |
| 149 | + certRequest.Duration = &instance.Spec.TLS.PodLevel.Ovn.Cert.Duration.Duration |
| 150 | + } |
| 151 | + if instance.Spec.TLS.PodLevel.Ovn.Cert.RenewBefore != nil { |
| 152 | + certRequest.RenewBefore = &instance.Spec.TLS.PodLevel.Ovn.Cert.RenewBefore.Duration |
| 153 | + } |
| 154 | + certSecret, ctrlResult, err := certmanager.EnsureCert( |
| 155 | + ctx, |
| 156 | + helper, |
| 157 | + certRequest, |
| 158 | + nil) |
| 159 | + if err != nil { |
| 160 | + return ctrl.Result{}, err |
| 161 | + } else if (ctrlResult != ctrl.Result{}) { |
| 162 | + return ctrl.Result{}, nil |
| 163 | + } |
| 164 | + |
| 165 | + instance.Spec.Ironic.Template.IronicNeutronAgent.TLS.Ovn.SecretName = &certSecret.Name |
125 | 166 | } |
126 | 167 | instance.Spec.Ironic.Template.IronicAPI.TLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName |
127 | 168 | instance.Spec.Ironic.Template.IronicInspector.TLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName |
|
0 commit comments