Skip to content

Commit e327b4e

Browse files
committed
[tls] add labels to ca/service cert
1 parent 2687c69 commit e327b4e

9 files changed

Lines changed: 30 additions & 9 deletions

File tree

‎pkg/openstack/ca.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -551,6 +551,11 @@ func createRootCACertAndIssuer(
551551
},
552552
Duration: caCfg.Duration,
553553
RenewBefore: caCfg.RenewBefore,
554+
SecretTemplate: &certmgrv1.CertificateSecretTemplate{
555+
Labels: map[string]string{
556+
caCertSelector: "",
557+
},
558+
},
554559
})
555560
cert := certmanager.NewCertificate(caCertReq, 5)
556561

‎pkg/openstack/common.go‎

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@ import (
2323
"github.com/openstack-k8s-operators/lib-common/modules/common/secret"
2424
"github.com/openstack-k8s-operators/lib-common/modules/common/service"
2525
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
26+
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
2627
manilav1 "github.com/openstack-k8s-operators/manila-operator/api/v1beta1"
2728
mariadbv1 "github.com/openstack-k8s-operators/mariadb-operator/api/v1beta1"
2829
neutronv1 "github.com/openstack-k8s-operators/neutron-operator/api/v1beta1"
@@ -57,6 +58,12 @@ const (
5758

5859
// ClusterInternalDomain - cluster internal dns domain
5960
ClusterInternalDomain = "cluster.local"
61+
62+
// serviceCertSelector selector passed to cert-manager to set on the service cert secret
63+
serviceCertSelector = "service-cert"
64+
65+
// caCertSelector selector passed to cert-manager to set on the ca cert secret
66+
caCertSelector = "ca-cert"
6067
)
6168

6269
// GetLog returns a logger object with a prefix of "controller.name" and aditional controller context fields
@@ -288,7 +295,7 @@ func EnsureEndpointConfig(
288295
},
289296
Ips: nil,
290297
Annotations: ed.Annotations,
291-
Labels: ed.Labels,
298+
Labels: util.MergeMaps(ed.Labels, map[string]string{serviceCertSelector: ""}),
292299
Usages: nil,
293300
}
294301
if instance.Spec.TLS.Ingress.Cert.Duration != nil {
@@ -333,7 +340,7 @@ func EnsureEndpointConfig(
333340
},
334341
Ips: nil,
335342
Annotations: ed.Annotations,
336-
Labels: ed.Labels,
343+
Labels: util.MergeMaps(ed.Labels, map[string]string{serviceCertSelector: ""}),
337344
Usages: nil,
338345
}
339346
if instance.Spec.TLS.PodLevel.Internal.Cert.Duration != nil {
@@ -554,7 +561,7 @@ func (ed *EndpointDetail) CreateRoute(
554561
Hostnames: []string{*ed.Hostname},
555562
Ips: nil,
556563
Annotations: ed.Annotations,
557-
Labels: ed.Labels,
564+
Labels: util.MergeMaps(ed.Labels, map[string]string{serviceCertSelector: ""}),
558565
Usages: nil,
559566
}
560567
if instance.Spec.TLS.Ingress.Cert.Duration != nil {

‎pkg/openstack/galera.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ func ReconcileGaleras(
6767
"server auth",
6868
"client auth",
6969
},
70+
Labels: map[string]string{serviceCertSelector: ""},
7071
}
7172
if instance.Spec.TLS.PodLevel.Internal.Cert.Duration != nil {
7273
certRequest.Duration = &instance.Spec.TLS.PodLevel.Internal.Cert.Duration.Duration

‎pkg/openstack/memcached.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ func reconcileMemcached(
169169
fmt.Sprintf("%s.%s.svc.%s", name, instance.Namespace, ClusterInternalDomain),
170170
fmt.Sprintf("*.%s.%s.svc.%s", name, instance.Namespace, ClusterInternalDomain),
171171
},
172+
Labels: map[string]string{serviceCertSelector: ""},
172173
}
173174
if instance.Spec.TLS.PodLevel.Internal.Cert.Duration != nil {
174175
certRequest.Duration = &instance.Spec.TLS.PodLevel.Internal.Cert.Duration.Duration

‎pkg/openstack/neutron.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ func ReconcileNeutron(ctx context.Context, instance *corev1beta1.OpenStackContro
7777
certmgrv1.UsageDigitalSignature,
7878
certmgrv1.UsageClientAuth,
7979
},
80+
Labels: map[string]string{serviceCertSelector: ""},
8081
}
8182
if instance.Spec.TLS.PodLevel.Ovn.Cert.Duration != nil {
8283
certRequest.Duration = &instance.Spec.TLS.PodLevel.Ovn.Cert.Duration.Duration

‎pkg/openstack/nova.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,7 @@ func ReconcileNova(ctx context.Context, instance *corev1beta1.OpenStackControlPl
274274
certmgrv1.UsageServerAuth,
275275
certmgrv1.UsageClientAuth,
276276
},
277+
Labels: map[string]string{serviceCertSelector: ""},
277278
}
278279
if instance.Spec.TLS.PodLevel.Libvirt.Cert.Duration != nil {
279280
certRequest.Duration = &instance.Spec.TLS.PodLevel.Libvirt.Cert.Duration.Duration

‎pkg/openstack/octavia.go‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -85,6 +85,7 @@ func ReconcileOctavia(ctx context.Context, instance *corev1beta1.OpenStackContro
8585
certmgrv1.UsageDigitalSignature,
8686
certmgrv1.UsageClientAuth,
8787
},
88+
Labels: map[string]string{serviceCertSelector: ""},
8889
}
8990
if instance.Spec.TLS.PodLevel.Ovn.Cert.Duration != nil {
9091
certRequest.Duration = &instance.Spec.TLS.PodLevel.Ovn.Cert.Duration.Duration

‎pkg/openstack/ovn.go‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@ func ReconcileOVNDbClusters(ctx context.Context, instance *corev1beta1.OpenStack
113113
certmgrv1.UsageServerAuth,
114114
certmgrv1.UsageClientAuth,
115115
},
116+
Labels: map[string]string{serviceCertSelector: ""},
116117
}
117118
if instance.Spec.TLS.PodLevel.Ovn.Cert.Duration != nil {
118119
certRequest.Duration = &instance.Spec.TLS.PodLevel.Ovn.Cert.Duration.Duration
@@ -224,6 +225,7 @@ func ReconcileOVNNorthd(ctx context.Context, instance *corev1beta1.OpenStackCont
224225
certmgrv1.UsageServerAuth,
225226
certmgrv1.UsageClientAuth,
226227
},
228+
Labels: map[string]string{serviceCertSelector: ""},
227229
}
228230
if instance.Spec.TLS.PodLevel.Ovn.Cert.Duration != nil {
229231
certRequest.Duration = &instance.Spec.TLS.PodLevel.Ovn.Cert.Duration.Duration
@@ -331,6 +333,7 @@ func ReconcileOVNController(ctx context.Context, instance *corev1beta1.OpenStack
331333
certmgrv1.UsageServerAuth,
332334
certmgrv1.UsageClientAuth,
333335
},
336+
Labels: map[string]string{serviceCertSelector: ""},
334337
}
335338
if instance.Spec.TLS.PodLevel.Ovn.Cert.Duration != nil {
336339
certRequest.Duration = &instance.Spec.TLS.PodLevel.Ovn.Cert.Duration.Duration

‎pkg/openstack/rabbitmq.go‎

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,13 +211,14 @@ func reconcileRabbitMQ(
211211
Organizations: []string{fmt.Sprintf("%s.%s", rabbitmq.Namespace, ClusterInternalDomain)},
212212
},
213213
Usages: []certmgrv1.KeyUsage{
214-
"key encipherment",
215-
"data encipherment",
216-
"digital signature",
217-
"server auth",
218-
"client auth",
219-
"content commitment",
214+
certmgrv1.UsageKeyEncipherment,
215+
certmgrv1.UsageDataEncipherment,
216+
certmgrv1.UsageDigitalSignature,
217+
certmgrv1.UsageServerAuth,
218+
certmgrv1.UsageClientAuth,
219+
certmgrv1.UsageContentCommitment,
220220
},
221+
Labels: map[string]string{serviceCertSelector: ""},
221222
}
222223
if instance.Spec.TLS.PodLevel.Internal.Cert.Duration != nil {
223224
certRequest.Duration = &instance.Spec.TLS.PodLevel.Internal.Cert.Duration.Duration

0 commit comments

Comments
 (0)