Skip to content

Commit c73a218

Browse files
Merge pull request #699 from olliewalsh/ovn_tls
[tlse] OVN TLS support
2 parents 1e57116 + f355bc7 commit c73a218

File tree

9 files changed

+199
-17
lines changed

9 files changed

+199
-17
lines changed

apis/bases/core.openstack.org_openstackcontrolplanes.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8627,6 +8627,11 @@ spec:
86278627
type: object
86288628
caBundleSecretName:
86298629
type: string
8630+
ovn:
8631+
properties:
8632+
secretName:
8633+
type: string
8634+
type: object
86308635
type: object
86318636
required:
86328637
- containerImage

apis/go.mod

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ require (
1818
github.com/openstack-k8s-operators/lib-common/modules/storage v0.3.1-0.20240306153230-dc65ab49ebc0
1919
github.com/openstack-k8s-operators/manila-operator/api v0.3.1-0.20240305194401-0fda28a84acb
2020
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240308170012-6b04e3e9b9ee
21-
github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20240305155525-acb164bd7d67
21+
github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20240308065128-4ba88761f83f
2222
github.com/openstack-k8s-operators/nova-operator/api v0.3.1-0.20240307151724-2fc1351673af
2323
github.com/openstack-k8s-operators/octavia-operator/api v0.3.1-0.20240305155754-2dcd200b721a
2424
github.com/openstack-k8s-operators/ovn-operator/api v0.3.1-0.20240307150054-826f3260f9aa

apis/go.sum

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -101,8 +101,8 @@ github.com/openstack-k8s-operators/manila-operator/api v0.3.1-0.20240305194401-0
101101
github.com/openstack-k8s-operators/manila-operator/api v0.3.1-0.20240305194401-0fda28a84acb/go.mod h1:WjZonBUlokd/WM3bzlGqW0KncogYyxUDmWmKvxSPlLE=
102102
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240308170012-6b04e3e9b9ee h1:UYxzWJ1HixHQ+jPoZ/PeTqCUxVr1+kha4YJpV/UwL64=
103103
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240308170012-6b04e3e9b9ee/go.mod h1:f9IIyWeoskWoeWaDFF3qmAJ2Kqyovfi0Ar/QUfk3qag=
104-
github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20240305155525-acb164bd7d67 h1:7BPdD7bAuzcl08/EiGDOJNBtfVnwuxm7F2acbC+kpuc=
105-
github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20240305155525-acb164bd7d67/go.mod h1:gOepjTKpq6rF0Lf69edviPOjFpjw4LHan/tWC4LB4Fs=
104+
github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20240308065128-4ba88761f83f h1:/a/+8/2zx+GAr5urESTrxac71BDjeG6vYNEScUyytFg=
105+
github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20240308065128-4ba88761f83f/go.mod h1:gOepjTKpq6rF0Lf69edviPOjFpjw4LHan/tWC4LB4Fs=
106106
github.com/openstack-k8s-operators/nova-operator/api v0.3.1-0.20240307151724-2fc1351673af h1:EuR34g9uahKG8YKp91FVvj5MNGR0Y+Q9aeu4Y3E8m+U=
107107
github.com/openstack-k8s-operators/nova-operator/api v0.3.1-0.20240307151724-2fc1351673af/go.mod h1:RCAltxGRZ+fJd1Ouo5gInELLubDg2BW9dacm7jw7pzk=
108108
github.com/openstack-k8s-operators/octavia-operator/api v0.3.1-0.20240305155754-2dcd200b721a h1:lyrp4n/ao9oVCmvzfE8dIKIQvJnPlRlYi1nRguDyqMs=

config/crd/bases/core.openstack.org_openstackcontrolplanes.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8627,6 +8627,11 @@ spec:
86278627
type: object
86288628
caBundleSecretName:
86298629
type: string
8630+
ovn:
8631+
properties:
8632+
secretName:
8633+
type: string
8634+
type: object
86308635
type: object
86318636
required:
86328637
- containerImage

go.mod

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ go 1.20
44

55
require (
66
github.com/blang/semver/v4 v4.0.0
7-
github.com/cert-manager/cert-manager v1.11.5
7+
github.com/cert-manager/cert-manager v1.13.4
88
github.com/ghodss/yaml v1.0.0
99
github.com/go-logr/logr v1.4.1
1010
github.com/google/uuid v1.6.0
@@ -27,7 +27,7 @@ require (
2727
github.com/openstack-k8s-operators/lib-common/modules/test v0.3.1-0.20240306153230-dc65ab49ebc0
2828
github.com/openstack-k8s-operators/manila-operator/api v0.3.1-0.20240305194401-0fda28a84acb
2929
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240308170012-6b04e3e9b9ee
30-
github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20240305155525-acb164bd7d67
30+
github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20240308065128-4ba88761f83f
3131
github.com/openstack-k8s-operators/nova-operator/api v0.3.1-0.20240307151724-2fc1351673af
3232
github.com/openstack-k8s-operators/octavia-operator/api v0.3.1-0.20240305155754-2dcd200b721a
3333
github.com/openstack-k8s-operators/openstack-ansibleee-operator/api v0.3.1-0.20240305134542-42210080a43a
@@ -87,7 +87,7 @@ require (
8787
github.com/rhobs/obo-prometheus-operator/pkg/apis/monitoring v0.64.1-rhobs3 // indirect
8888
github.com/rhobs/observability-operator v0.0.20 // indirect
8989
github.com/robfig/cron/v3 v3.0.1 // indirect
90-
github.com/sirupsen/logrus v1.9.2 // indirect
90+
github.com/sirupsen/logrus v1.9.3 // indirect
9191
github.com/spf13/pflag v1.0.5 // indirect
9292
go.uber.org/multierr v1.11.0 // indirect
9393
golang.org/x/mod v0.15.0 // indirect
@@ -108,7 +108,7 @@ require (
108108
k8s.io/component-base v0.28.7 // indirect
109109
k8s.io/klog/v2 v2.120.1 // indirect
110110
k8s.io/kube-openapi v0.0.0-20240228011516-70dd3763d340 // indirect
111-
sigs.k8s.io/gateway-api v0.6.0 // indirect
111+
sigs.k8s.io/gateway-api v0.8.0 // indirect
112112
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd // indirect
113113
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 // indirect
114114
sigs.k8s.io/yaml v1.4.0 // indirect

go.sum

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@ github.com/beorn7/perks v1.0.1 h1:VlbKKnNfV8bJzeqoa4cOKqO6bYr3WgKZxO8Z16+hsOM=
22
github.com/beorn7/perks v1.0.1/go.mod h1:G2ZrVWU2WbWT9wwq4/hrbKbnv/1ERSJQ0ibhJ6rlkpw=
33
github.com/blang/semver/v4 v4.0.0 h1:1PFHFE6yCCTv8C1TeyNNarDzntLi7wMI5i/pzqYIsAM=
44
github.com/blang/semver/v4 v4.0.0/go.mod h1:IbckMUScFkM3pff0VJDNKRiT6TG/YpiHIM2yvyW5YoQ=
5-
github.com/cert-manager/cert-manager v1.11.5 h1:K2LurvwIE4hIhODQZnkOW6ljYe3lVMAliS/to+gI05o=
6-
github.com/cert-manager/cert-manager v1.11.5/go.mod h1:zNOyoTEwdn9Rtj5Or2pjBY1Bqwtw4vBElP2fKSP8/g8=
5+
github.com/cert-manager/cert-manager v1.13.4 h1:4zJdlemXg84KFssuk4I781oBJo1CuAnD1m8ZF/zsRrY=
6+
github.com/cert-manager/cert-manager v1.13.4/go.mod h1:8F9nXyWuOP0Ziq77g0N5N/sTyfP1NBVs4C1GBjrDU1I=
77
github.com/cespare/xxhash/v2 v2.2.0 h1:DC2CZ1Ep5Y4k3ZQ899DldepgrayRUGE6BBZ/cd9Cj44=
88
github.com/cespare/xxhash/v2 v2.2.0/go.mod h1:VGX0DQ3Q6kWi7AoAeZDth3/j3BFtOZR5XLFGgcrjCOs=
99
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
@@ -119,8 +119,8 @@ github.com/openstack-k8s-operators/manila-operator/api v0.3.1-0.20240305194401-0
119119
github.com/openstack-k8s-operators/manila-operator/api v0.3.1-0.20240305194401-0fda28a84acb/go.mod h1:WjZonBUlokd/WM3bzlGqW0KncogYyxUDmWmKvxSPlLE=
120120
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240308170012-6b04e3e9b9ee h1:UYxzWJ1HixHQ+jPoZ/PeTqCUxVr1+kha4YJpV/UwL64=
121121
github.com/openstack-k8s-operators/mariadb-operator/api v0.3.1-0.20240308170012-6b04e3e9b9ee/go.mod h1:f9IIyWeoskWoeWaDFF3qmAJ2Kqyovfi0Ar/QUfk3qag=
122-
github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20240305155525-acb164bd7d67 h1:7BPdD7bAuzcl08/EiGDOJNBtfVnwuxm7F2acbC+kpuc=
123-
github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20240305155525-acb164bd7d67/go.mod h1:gOepjTKpq6rF0Lf69edviPOjFpjw4LHan/tWC4LB4Fs=
122+
github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20240308065128-4ba88761f83f h1:/a/+8/2zx+GAr5urESTrxac71BDjeG6vYNEScUyytFg=
123+
github.com/openstack-k8s-operators/neutron-operator/api v0.3.1-0.20240308065128-4ba88761f83f/go.mod h1:gOepjTKpq6rF0Lf69edviPOjFpjw4LHan/tWC4LB4Fs=
124124
github.com/openstack-k8s-operators/nova-operator/api v0.3.1-0.20240307151724-2fc1351673af h1:EuR34g9uahKG8YKp91FVvj5MNGR0Y+Q9aeu4Y3E8m+U=
125125
github.com/openstack-k8s-operators/nova-operator/api v0.3.1-0.20240307151724-2fc1351673af/go.mod h1:RCAltxGRZ+fJd1Ouo5gInELLubDg2BW9dacm7jw7pzk=
126126
github.com/openstack-k8s-operators/octavia-operator/api v0.3.1-0.20240305155754-2dcd200b721a h1:lyrp4n/ao9oVCmvzfE8dIKIQvJnPlRlYi1nRguDyqMs=
@@ -160,8 +160,8 @@ github.com/rhobs/observability-operator v0.0.20/go.mod h1:F+exF/48C17xz9Ci9WK9Ri
160160
github.com/robfig/cron/v3 v3.0.1 h1:WdRxkvbJztn8LMz/QEvLN5sBU+xKpSqwwUO1Pjr4qDs=
161161
github.com/robfig/cron/v3 v3.0.1/go.mod h1:eQICP3HwyT7UooqI/z+Ov+PtYAWygg1TEWWzGIFLtro=
162162
github.com/rogpeppe/go-internal v1.12.0 h1:exVL4IDcn6na9z1rAb56Vxr+CgyK3nn3O+epU5NdKM8=
163-
github.com/sirupsen/logrus v1.9.2 h1:oxx1eChJGI6Uks2ZC4W1zpLlVgqB8ner4EuQwV4Ik1Y=
164-
github.com/sirupsen/logrus v1.9.2/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
163+
github.com/sirupsen/logrus v1.9.3 h1:dueUQJ1C2q9oE3F7wvmSGAaVtTmUizReu6fjN8uqzbQ=
164+
github.com/sirupsen/logrus v1.9.3/go.mod h1:naHLuLoDiP4jHNo9R0sCBMtWGeIprob74mVsIT4qYEQ=
165165
github.com/spf13/pflag v1.0.5 h1:iy+VFUOCP1a+8yFto/drg2CJ5u0yRoB7fZw3DKv/JXA=
166166
github.com/spf13/pflag v1.0.5/go.mod h1:McXfInJRrz4CZXVZOBLb0bTZqETkiAhM9Iw0y3An2Bg=
167167
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
@@ -275,8 +275,8 @@ k8s.io/utils v0.0.0-20240102154912-e7106e64919e h1:eQ/4ljkx21sObifjzXwlPKpdGLrCf
275275
k8s.io/utils v0.0.0-20240102154912-e7106e64919e/go.mod h1:OLgZIPagt7ERELqWJFomSt595RzquPNLL48iOWgYOg0=
276276
sigs.k8s.io/controller-runtime v0.16.5 h1:yr1cEJbX08xsTW6XEIzT13KHHmIyX8Umvme2cULvFZw=
277277
sigs.k8s.io/controller-runtime v0.16.5/go.mod h1:j7bialYoSn142nv9sCOJmQgDXQXxnroFU4VnX/brVJ0=
278-
sigs.k8s.io/gateway-api v0.6.0 h1:v2FqrN2ROWZLrSnI2o91taHR8Sj3s+Eh3QU7gLNWIqA=
279-
sigs.k8s.io/gateway-api v0.6.0/go.mod h1:EYJT+jlPWTeNskjV0JTki/03WX1cyAnBhwBJfYHpV/0=
278+
sigs.k8s.io/gateway-api v0.8.0 h1:isQQ3Jx2qFP7vaA3ls0846F0Amp9Eq14P08xbSwVbQg=
279+
sigs.k8s.io/gateway-api v0.8.0/go.mod h1:okOnjPNBFbIS/Rw9kAhuIUaIkLhTKEu+ARIuXk2dgaM=
280280
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd h1:EDPBXCAspyGV4jQlpZSudPeMmr1bNJefnuqLsRAsHZo=
281281
sigs.k8s.io/json v0.0.0-20221116044647-bc3834ca7abd/go.mod h1:B8JuhiUyNFVKdsE8h686QcCxMaH6HrOAZj4vswFpcB0=
282282
sigs.k8s.io/structured-merge-diff/v4 v4.4.1 h1:150L+0vs/8DA78h1u02ooW1/fFq/Lwr+sGiqlzvrtq4=

pkg/openstack/ca.go

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ import (
2727
ctrl "sigs.k8s.io/controller-runtime"
2828
)
2929

30+
const (
31+
OvnDbCaName = tls.DefaultCAPrefix + "ovn"
32+
)
33+
3034
// ReconcileCAs -
3135
func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, helper *helper.Helper) (ctrl.Result, error) {
3236
Log := GetLogger(ctx)
@@ -136,7 +140,7 @@ func ReconcileCAs(ctx context.Context, instance *corev1.OpenStackControlPlane, h
136140
instance,
137141
helper,
138142
issuerReq,
139-
tls.DefaultCAPrefix+"ovn",
143+
OvnDbCaName,
140144
map[string]string{certmanager.RootCAIssuerOvnDBLabel: ""},
141145
bundle,
142146
caOnlyBundle,

pkg/openstack/neutron.go

Lines changed: 33 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,12 @@ import (
44
"context"
55
"fmt"
66

7+
certmgrv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
8+
"github.com/openstack-k8s-operators/lib-common/modules/certmanager"
79
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
810
"github.com/openstack-k8s-operators/lib-common/modules/common/helper"
911
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
12+
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
1013

1114
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
1215

@@ -58,6 +61,35 @@ func ReconcileNeutron(ctx context.Context, instance *corev1beta1.OpenStackContro
5861
// preserve any previously set TLS certs,set CA cert
5962
if instance.Spec.TLS.Enabled(service.EndpointInternal) {
6063
instance.Spec.Neutron.Template.TLS = neutronAPI.Spec.TLS
64+
65+
serviceName := "neutron"
66+
// create ovndb client certificate for neutron
67+
certRequest := certmanager.CertificateRequest{
68+
IssuerName: OvnDbCaName,
69+
CertName: fmt.Sprintf("%s-ovndbs", serviceName),
70+
Duration: nil,
71+
Hostnames: []string{
72+
fmt.Sprintf("%s.%s.svc", serviceName, instance.Namespace),
73+
fmt.Sprintf("%s.%s.svc.%s", serviceName, instance.Namespace, "cluster.local"),
74+
},
75+
Ips: nil,
76+
Usages: []certmgrv1.KeyUsage{
77+
certmgrv1.UsageKeyEncipherment,
78+
certmgrv1.UsageDigitalSignature,
79+
certmgrv1.UsageClientAuth,
80+
},
81+
}
82+
certSecret, ctrlResult, err := certmanager.EnsureCert(
83+
ctx,
84+
helper,
85+
certRequest)
86+
if err != nil {
87+
return ctrl.Result{}, err
88+
} else if (ctrlResult != ctrl.Result{}) {
89+
return ctrl.Result{}, nil
90+
}
91+
92+
instance.Spec.Neutron.Template.TLS.Ovn.SecretName = &certSecret.Name
6193
}
6294
instance.Spec.Neutron.Template.TLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName
6395

@@ -83,7 +115,7 @@ func ReconcileNeutron(ctx context.Context, instance *corev1beta1.OpenStackContro
83115
instance.Spec.Neutron.APIOverride,
84116
corev1beta1.OpenStackControlPlaneExposeNeutronReadyCondition,
85117
false, // TODO (mschuppert) could be removed when all integrated service support TLS
86-
instance.Spec.Neutron.Template.TLS,
118+
tls.API{API: instance.Spec.Neutron.Template.TLS.API},
87119
)
88120
if err != nil {
89121
return ctrlResult, err

pkg/openstack/ovn.go

Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,19 @@ import (
44
"context"
55
"fmt"
66

7+
"github.com/openstack-k8s-operators/lib-common/modules/certmanager"
78
"github.com/openstack-k8s-operators/lib-common/modules/common/condition"
89
"github.com/openstack-k8s-operators/lib-common/modules/common/helper"
10+
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
911

1012
"sigs.k8s.io/controller-runtime/pkg/controller/controllerutil"
1113

14+
certmgrv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
1215
corev1beta1 "github.com/openstack-k8s-operators/openstack-operator/apis/core/v1beta1"
1316
ovnv1 "github.com/openstack-k8s-operators/ovn-operator/api/v1beta1"
17+
k8s_errors "k8s.io/apimachinery/pkg/api/errors"
1418
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
19+
"k8s.io/apimachinery/pkg/types"
1520
ctrl "sigs.k8s.io/controller-runtime"
1621
)
1722

@@ -76,6 +81,51 @@ func ReconcileOVNDbClusters(ctx context.Context, instance *corev1beta1.OpenStack
7681
continue
7782
}
7883

84+
// preserve any previously set TLS certs, set CA cert
85+
if err := helper.GetClient().Get(ctx, types.NamespacedName{Name: name, Namespace: instance.Namespace}, OVNDBCluster); err != nil {
86+
if !k8s_errors.IsNotFound(err) {
87+
return false, err
88+
}
89+
}
90+
if instance.Spec.TLS.Enabled(service.EndpointInternal) {
91+
dbcluster.TLS = OVNDBCluster.Spec.TLS
92+
}
93+
dbcluster.TLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName
94+
95+
if OVNDBCluster.Status.Conditions.IsTrue(condition.ExposeServiceReadyCondition) {
96+
// create certificate for ovndbclusters
97+
certRequest := certmanager.CertificateRequest{
98+
IssuerName: OvnDbCaName,
99+
CertName: fmt.Sprintf("%s-ovndbs", name),
100+
Duration: nil,
101+
// Cert needs to be valid for the individual pods in the statefulset so make this a wildcard cert
102+
Hostnames: []string{
103+
fmt.Sprintf("*.%s.svc", instance.Namespace),
104+
fmt.Sprintf("*.%s.svc.%s", instance.Namespace, ovnv1.DNSSuffix),
105+
},
106+
Ips: nil,
107+
Usages: []certmgrv1.KeyUsage{
108+
certmgrv1.UsageKeyEncipherment,
109+
certmgrv1.UsageDigitalSignature,
110+
certmgrv1.UsageServerAuth,
111+
certmgrv1.UsageClientAuth,
112+
},
113+
}
114+
certSecret, ctrlResult, err := certmanager.EnsureCert(
115+
ctx,
116+
helper,
117+
certRequest)
118+
if err != nil {
119+
return false, err
120+
} else if (ctrlResult != ctrl.Result{}) {
121+
return false, nil
122+
}
123+
124+
if instance.Spec.TLS.Enabled(service.EndpointInternal) {
125+
dbcluster.TLS.SecretName = &certSecret.Name
126+
}
127+
}
128+
79129
Log.Info("Reconciling OVNDBCluster", "OVNDBCluster.Namespace", instance.Namespace, "OVNDBCluster.Name", name)
80130
op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), OVNDBCluster, func() error {
81131

@@ -123,6 +173,49 @@ func ReconcileOVNNorthd(ctx context.Context, instance *corev1beta1.OpenStackCont
123173
return false, nil
124174
}
125175

176+
ovnNorthdSpec := &instance.Spec.Ovn.Template.OVNNorthd
177+
178+
// preserve any previously set TLS certs, set CA cert
179+
if err := helper.GetClient().Get(ctx, types.NamespacedName{Name: "ovnnorthd", Namespace: instance.Namespace}, OVNNorthd); err != nil {
180+
if !k8s_errors.IsNotFound(err) {
181+
return false, err
182+
}
183+
}
184+
if instance.Spec.TLS.Enabled(service.EndpointInternal) {
185+
ovnNorthdSpec.TLS = OVNNorthd.Spec.TLS
186+
187+
serviceName := ovnv1.ServiceNameOvnNorthd
188+
// create certificate for ovnnorthd
189+
certRequest := certmanager.CertificateRequest{
190+
IssuerName: OvnDbCaName,
191+
CertName: fmt.Sprintf("%s-ovndbs", "ovnnorthd"),
192+
Duration: nil,
193+
Hostnames: []string{
194+
fmt.Sprintf("%s.%s.svc", serviceName, instance.Namespace),
195+
fmt.Sprintf("%s.%s.svc.%s", serviceName, instance.Namespace, ovnv1.DNSSuffix),
196+
},
197+
Ips: nil,
198+
Usages: []certmgrv1.KeyUsage{
199+
certmgrv1.UsageKeyEncipherment,
200+
certmgrv1.UsageDigitalSignature,
201+
certmgrv1.UsageServerAuth,
202+
certmgrv1.UsageClientAuth,
203+
},
204+
}
205+
certSecret, ctrlResult, err := certmanager.EnsureCert(
206+
ctx,
207+
helper,
208+
certRequest)
209+
if err != nil {
210+
return false, err
211+
} else if (ctrlResult != ctrl.Result{}) {
212+
return false, nil
213+
}
214+
215+
ovnNorthdSpec.TLS.SecretName = &certSecret.Name
216+
}
217+
ovnNorthdSpec.TLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName
218+
126219
Log.Info("Reconciling OVNNorthd", "OVNNorthd.Namespace", instance.Namespace, "OVNNorthd.Name", "ovnnorthd")
127220
op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), OVNNorthd, func() error {
128221

@@ -171,6 +264,49 @@ func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStack
171264
return false, nil
172265
}
173266

267+
ovnControllerSpec := &instance.Spec.Ovn.Template.OVNController
268+
269+
// preserve any previously set TLS certs, set CA cert
270+
if err := helper.GetClient().Get(ctx, types.NamespacedName{Name: "ovncontroller", Namespace: instance.Namespace}, OVNController); err != nil {
271+
if !k8s_errors.IsNotFound(err) {
272+
return false, err
273+
}
274+
}
275+
if instance.Spec.TLS.Enabled(service.EndpointInternal) {
276+
ovnControllerSpec.TLS = OVNController.Spec.TLS
277+
278+
serviceName := ovnv1.ServiceNameOvnController
279+
// create certificate for ovncontroller
280+
certRequest := certmanager.CertificateRequest{
281+
IssuerName: OvnDbCaName,
282+
CertName: fmt.Sprintf("%s-ovndbs", "ovncontroller"),
283+
Duration: nil,
284+
Hostnames: []string{
285+
fmt.Sprintf("%s.%s.svc", serviceName, instance.Namespace),
286+
fmt.Sprintf("%s.%s.svc.%s", serviceName, instance.Namespace, ovnv1.DNSSuffix),
287+
},
288+
Ips: nil,
289+
Usages: []certmgrv1.KeyUsage{
290+
certmgrv1.UsageKeyEncipherment,
291+
certmgrv1.UsageDigitalSignature,
292+
certmgrv1.UsageServerAuth,
293+
certmgrv1.UsageClientAuth,
294+
},
295+
}
296+
certSecret, ctrlResult, err := certmanager.EnsureCert(
297+
ctx,
298+
helper,
299+
certRequest)
300+
if err != nil {
301+
return false, err
302+
} else if (ctrlResult != ctrl.Result{}) {
303+
return false, nil
304+
}
305+
306+
ovnControllerSpec.TLS.SecretName = &certSecret.Name
307+
}
308+
ovnControllerSpec.TLS.CaBundleSecretName = instance.Status.TLS.CaBundleSecretName
309+
174310
Log.Info("Reconciling OVNController", "OVNController.Namespace", instance.Namespace, "OVNController.Name", "ovncontroller")
175311
op, err := controllerutil.CreateOrPatch(ctx, helper.GetClient(), OVNController, func() error {
176312

0 commit comments

Comments
 (0)