Skip to content

Commit e32734c

Browse files
fmountclaude
andcommitted
Inherit the cluster TLS security profile
This patch represents the first step toward OCPSTRAT-2611. The openstack-operator reads the TLSSecurityProfile from the OpenShift APIServer CR and publish it in a well-known ConfigMap that is used to inject global defaults to the underlying OpenStack services. This ConfigMap contains the Apache httpd directives (SSLCipherSuite and SSLProtocol), plus MinTLSVersion in neutral form for the services that are not httpd based. lib-common merges that ConfigMap with global TLS defaults underneath the ConfigOptions of every Template it renders. Sharing the constant with lib-common keeps producer and consumer from drifting on the object name. Acting on the keys stays opt-in per service: a Service asks for the common template it wants (e.g. ssl.conf in this case) and the service's httpd config has to Include the rendered file. This fearure is currently off by default, and gated on spec.tls.profile, so a minor update does not change the TLS behavior. When the flag is set to None, the inheritance mechanism is not executed, and the TLSProfileReady condition is neither initialised nor set in the Status of the control plane CR. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com> Signed-off-by: Francesco Pantano <fpantano@redhat.com>
1 parent f3a5bdb commit e32734c

11 files changed

Lines changed: 835 additions & 4 deletions

File tree

‎api/bases/core.openstack.org_openstackcontrolplanes.yaml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18814,6 +18814,14 @@ spec:
1881418814
type: object
1881518815
type: object
1881618816
type: object
18817+
profile:
18818+
default: None
18819+
enum:
18820+
- None
18821+
- Inherit
18822+
- Intermediate
18823+
- Modern
18824+
type: string
1881718825
type: object
1881818826
topologyRef:
1881918827
properties:

‎api/core/v1beta1/conditions.go‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -108,6 +108,9 @@ const (
108108
// OpenStackControlPlaneCustomTLSReadyCondition Status=True condition which indicates if custom TLS certificate secrets are configured and operational
109109
OpenStackControlPlaneCustomTLSReadyCondition condition.Type = "OpenStackControlPlaneCustomTLSReadyCondition"
110110

111+
// OpenStackControlPlaneTLSProfileReadyCondition Status=True condition which indicates if the APIServer TLS profile has been resolved and the SSL profile ConfigMap created
112+
OpenStackControlPlaneTLSProfileReadyCondition condition.Type = "OpenStackControlPlaneTLSProfileReady"
113+
111114
// OpenStackControlPlaneTelemetryReadyCondition Status=True condition which indicates if OpenStack Telemetry service is configured and operational
112115
OpenStackControlPlaneTelemetryReadyCondition condition.Type = "OpenStackControlPlaneTelemetryReady"
113116

@@ -483,6 +486,18 @@ const (
483486
// OpenStackControlPlaneCAReadyErrorMessage
484487
OpenStackControlPlaneCustomTLSReadyErrorMessage = "OpenStackControlPlane custom TLS cert secret %s error occured %s"
485488

489+
// OpenStackControlPlaneTLSProfileReadyInitMessage
490+
OpenStackControlPlaneTLSProfileReadyInitMessage = "OpenStackControlPlane TLS profile not started"
491+
492+
// OpenStackControlPlaneTLSProfileReadyMessage
493+
OpenStackControlPlaneTLSProfileReadyMessage = "OpenStackControlPlane TLS profile ConfigMap created"
494+
495+
// OpenStackControlPlaneTLSProfileReadyNoProfileMessage
496+
OpenStackControlPlaneTLSProfileReadyNoProfileMessage = "OpenStackControlPlane TLS profile not declared by the cluster, using built-in defaults"
497+
498+
// OpenStackControlPlaneTLSProfileReadyErrorMessage
499+
OpenStackControlPlaneTLSProfileReadyErrorMessage = "OpenStackControlPlane TLS profile error occurred %s"
500+
486501
// OpenStackControlPlaneTestCMReadyErrorMessage
487502
OpenStackControlPlaneTestCMReadyErrorMessage = "OpenStackControlPlane Test Operator CM error occured %s"
488503

‎api/core/v1beta1/openstackcontrolplane_types.go‎

Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -266,6 +266,16 @@ type TLSSection struct {
266266
// +kubebuilder:default={enabled: true, internal:{ca: {duration: "87600h"}, cert: {duration: "43800h"}}, libvirt: {ca: {duration: "87600h"}, cert: {duration: "43800h"}}, ovn: {ca: {duration: "87600h"}, cert: {duration: "43800h"}}}
267267
PodLevel TLSPodLevelConfig `json:"podLevel,omitempty"`
268268

269+
// +kubebuilder:validation:optional
270+
// +operator-sdk:csv:customresourcedefinitions:type=spec
271+
// Profile - The TLS security profile the OpenStack services are
272+
// configured with. "None" (the default) publishes nothing, so the services
273+
// keep lib-common's built-in defaults. "Inherit" follows whatever the
274+
// cluster declares on the OpenShift APIServer CR. "Intermediate" and
275+
// "Modern" pin that profile regardless of what the cluster declares.
276+
// +kubebuilder:default=None
277+
Profile TLSProfileType `json:"profile,omitempty"`
278+
269279
// +kubebuilder:validation:optional
270280
// +operator-sdk:csv:customresourcedefinitions:type=spec
271281
// Secret containing any additional CA certificates, which should be added to deployment pods.
@@ -274,6 +284,37 @@ type TLSSection struct {
274284
tls.Ca `json:",inline"`
275285
}
276286

287+
// TLSProfileType - the TLS security profile the OpenStack services are
288+
// configured with, either sourced from the cluster or named here directly.
289+
// The named values are spelled out rather than taken from configv1 so this
290+
// module keeps openshift/api indirect; the functional tests pin the spelling.
291+
// "Old" is not offered, but stays reachable through "Inherit" when the
292+
// cluster itself declares it.
293+
// +kubebuilder:validation:Enum=None;Inherit;Intermediate;Modern
294+
type TLSProfileType string
295+
296+
const (
297+
// TLSProfileNone - publish nothing; the services keep lib-common's defaults.
298+
TLSProfileNone TLSProfileType = "None"
299+
300+
// TLSProfileInherit - follow the profile the cluster declares on the APIServer CR.
301+
TLSProfileInherit TLSProfileType = "Inherit"
302+
303+
// TLSProfileIntermediate - pin the OpenShift Intermediate profile.
304+
TLSProfileIntermediate TLSProfileType = "Intermediate"
305+
306+
// TLSProfileModern - pin the OpenShift Modern profile.
307+
TLSProfileModern TLSProfileType = "Modern"
308+
)
309+
310+
// IsEnabled - whether a profile is requested at all. InitConditions and
311+
// ReconcileTLSProfile have to agree on this, or an early-returning reconcile
312+
// leaves an Unknown condition behind for a feature that is off. An unset
313+
// value counts as None.
314+
func (p TLSProfileType) IsEnabled() bool {
315+
return p != TLSProfileNone && p != ""
316+
}
317+
277318
// TLSIngressConfig defines the desired state of the TLS configuration for the ingress configuration (route)
278319
type TLSIngressConfig struct {
279320
// +kubebuilder:validation:Optional
@@ -1244,6 +1285,14 @@ func (instance *OpenStackControlPlane) InitConditions() {
12441285
cl.Set(condition.UnknownCondition(OpenStackControlPlaneWatcherReadyCondition, condition.InitReason, OpenStackControlPlaneWatcherReadyInitMessage))
12451286
}
12461287

1288+
// Only register the condition when a profile is requested: in None mode
1289+
// ReconcileTLSProfile removes it again, but an early return (minor update
1290+
// staging, CA requeue, first-pass finalizer) never gets that far and would
1291+
// persist an Unknown for a feature that is off.
1292+
if instance.Spec.TLS.Profile.IsEnabled() {
1293+
cl.Set(condition.UnknownCondition(OpenStackControlPlaneTLSProfileReadyCondition, condition.InitReason, OpenStackControlPlaneTLSProfileReadyInitMessage))
1294+
}
1295+
12471296
// Init Topology condition if there's a reference
12481297
if instance.Spec.TopologyRef != nil {
12491298
cl.Set(condition.UnknownCondition(condition.TopologyReadyCondition, condition.InitReason, condition.TopologyReadyInitMessage))

‎bindata/crds/crds.yaml‎

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19843,6 +19843,14 @@ spec:
1984319843
type: object
1984419844
type: object
1984519845
type: object
19846+
profile:
19847+
default: None
19848+
enum:
19849+
- None
19850+
- Inherit
19851+
- Intermediate
19852+
- Modern
19853+
type: string
1984619854
type: object
1984719855
topologyRef:
1984819856
properties:

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

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18814,6 +18814,14 @@ spec:
1881418814
type: object
1881518815
type: object
1881618816
type: object
18817+
profile:
18818+
default: None
18819+
enum:
18820+
- None
18821+
- Inherit
18822+
- Intermediate
18823+
- Modern
18824+
type: string
1881718825
type: object
1881818826
topologyRef:
1881918827
properties:

‎config/rbac/role.yaml‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -318,6 +318,7 @@ rules:
318318
- apiGroups:
319319
- config.openshift.io
320320
resources:
321+
- apiservers
321322
- clusterimagepolicies
322323
- clusteroperators
323324
- clusterversions

‎go.mod‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -179,3 +179,7 @@ replace k8s.io/component-base => k8s.io/component-base v0.33.13 //allow-merging
179179
replace k8s.io/kube-openapi => k8s.io/kube-openapi v0.0.0-20250627150254-e9823e99808e //allow-merging
180180

181181
replace github.com/cert-manager/cmctl/v2 => github.com/cert-manager/cmctl/v2 v2.3.0 //allow-merging
182+
183+
replace github.com/openstack-k8s-operators/lib-common/modules/common => github.com/fmount/lib-common/modules/common v0.0.0-20260929084206-28305ffbcb79
184+
185+
replace github.com/openstack-k8s-operators/lib-common/modules/test => github.com/fmount/lib-common/modules/test v0.0.0-20260929084206-28305ffbcb79

‎go.sum‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,10 @@ github.com/evanphx/json-patch/v5 v5.9.11 h1:/8HVnzMq13/3x9TPvjG08wUGqBTmZBsCWzjT
2727
github.com/evanphx/json-patch/v5 v5.9.11/go.mod h1:3j+LviiESTElxA4p3EMKAB9HXj3/XEtnUf6OZxqIQTM=
2828
github.com/felixge/httpsnoop v1.0.4 h1:NFTV2Zj1bL4mc9sqWACXbQFVBBg2W3GPvqp8/ESS2Wg=
2929
github.com/felixge/httpsnoop v1.0.4/go.mod h1:m8KPJKqk1gH5J9DgRY2ASl2lWCfGKXixSwevea8zH2U=
30+
github.com/fmount/lib-common/modules/common v0.0.0-20260929084206-28305ffbcb79 h1:WoF885AJhvvwnKLB8wbdWgYE4JASraK7SsOSqsZYgMo=
31+
github.com/fmount/lib-common/modules/common v0.0.0-20260929084206-28305ffbcb79/go.mod h1:HqF1PQbKmgDVsmSk+c9TGmusD4TrlV049qft+SLVTcI=
32+
github.com/fmount/lib-common/modules/test v0.0.0-20260929084206-28305ffbcb79 h1:8sQw7SPjPnZWvVnoe08tCPzZSpLUY8kyjj6ZPiJVkLY=
33+
github.com/fmount/lib-common/modules/test v0.0.0-20260929084206-28305ffbcb79/go.mod h1:jQx5uMv2KKxv+vGATQYEqFs+oaojQYyCi1ZG3ipUk1c=
3034
github.com/fsnotify/fsnotify v1.9.0 h1:2Ml+OJNzbYCTzsxtv8vKSFD9PbJjmhYF14k/jKC7S9k=
3135
github.com/fsnotify/fsnotify v1.9.0/go.mod h1:8jBTzvmWwFyi3Pb8djgCCO5IBqzKJ/Jwo8TRcHyHii0=
3236
github.com/fxamacker/cbor/v2 v2.9.0 h1:NpKPmjDBgUfBms6tr6JZkTHtfFGcMKsw3eGcmD/sapM=
@@ -180,14 +184,10 @@ github.com/openstack-k8s-operators/lib-common/modules/ansible v0.6.1-0.202609290
180184
github.com/openstack-k8s-operators/lib-common/modules/ansible v0.6.1-0.20260929064559-6520773c7041/go.mod h1:TkZgZE92VUKHHNKXwuV8b7tT9toaxsZkcGffRafKCSA=
181185
github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.6.1-0.20260929064559-6520773c7041 h1:59G+tlnSYeXo4znK5EqJPwcCjMOyIRnUQTWLI3Q0Bus=
182186
github.com/openstack-k8s-operators/lib-common/modules/certmanager v0.6.1-0.20260929064559-6520773c7041/go.mod h1:uosB8wDiCmIDU8HJqx3k6sKbTjKAlPybJaZ9YdE1TGY=
183-
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260929064559-6520773c7041 h1:9LQVnrh9GdnxKdmyP4gv+ru16AbppKWgAC4DMpkOKjk=
184-
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.1-0.20260929064559-6520773c7041/go.mod h1:HsTiW0fVqBtJWS+jsfJV3M2i3x7ZXQcXwZU7a07n1AA=
185187
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20260919144046-f1cdd9f36e9f h1:fkaNqgQvzxbRJ4TVHcY7SDH7f9uU1ePFjbbIqY/MaFs=
186188
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.1-0.20260919144046-f1cdd9f36e9f/go.mod h1:WitFUr5xE1+vYzTM/Q5CMjAUtz8xQlh8zzHox6mCfH4=
187189
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20260929064559-6520773c7041 h1:85S7wxzlFsYnzeaX1W1WPS7uSWBIuJYR10AFhkQKLGs=
188190
github.com/openstack-k8s-operators/lib-common/modules/storage v0.6.1-0.20260929064559-6520773c7041/go.mod h1:4bZ0o4bujdOUaHXt8NyjJLgl1mgkb3JmdqGmLlEoai0=
189-
github.com/openstack-k8s-operators/lib-common/modules/test v0.6.1-0.20260929064559-6520773c7041 h1:SZlkGwZ1sJVNGime3kSGNNAJS59azLNxsdqpdZAJJjg=
190-
github.com/openstack-k8s-operators/lib-common/modules/test v0.6.1-0.20260929064559-6520773c7041/go.mod h1:L808YAudxgGbL7B0aPq6UBtKCtF/DCDs3rny7KkPRpc=
191191
github.com/openstack-k8s-operators/lib-common/modules/users v0.0.0-20260929064559-6520773c7041 h1:nmXHRBlsSSd7LdUBPT4DR0Llq6AlYfYVeJXvgb296xw=
192192
github.com/openstack-k8s-operators/lib-common/modules/users v0.0.0-20260929064559-6520773c7041/go.mod h1:jmVVRfwuFQ3fHLIOAkUrtLgOwEL6j45POzS3PBJuwyM=
193193
github.com/openstack-k8s-operators/manila-operator/api v0.6.1-0.20260927113347-e2db2aea3d19 h1:B3KaQmOUsZIcFEguRQFvK1fujVXA+mXog0Qe5N+dZLY=

‎internal/controller/core/openstackcontrolplane_controller.go‎

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import (
2424
"time"
2525

2626
certmgrv1 "github.com/cert-manager/cert-manager/pkg/apis/certmanager/v1"
27+
configv1 "github.com/openshift/api/config/v1"
2728
routev1 "github.com/openshift/api/route/v1"
2829
barbicanv1 "github.com/openstack-k8s-operators/barbican-operator/api/v1beta1"
2930
cinderv1 "github.com/openstack-k8s-operators/cinder-operator/api/v1beta1"
@@ -39,6 +40,7 @@ import (
3940
"github.com/openstack-k8s-operators/lib-common/modules/common/backup"
4041
condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
4142
common_helper "github.com/openstack-k8s-operators/lib-common/modules/common/helper"
43+
"github.com/openstack-k8s-operators/lib-common/modules/common/util"
4244
"github.com/openstack-k8s-operators/lib-common/modules/common/webhook"
4345
corev1 "k8s.io/api/core/v1"
4446

@@ -125,9 +127,11 @@ func (r *OpenStackControlPlaneReconciler) GetLogger(ctx context.Context) logr.Lo
125127
// +kubebuilder:rbac:groups=route.openshift.io,resources=routes/custom-host,verbs=create;update;patch
126128
// +kubebuilder:rbac:groups=core,resources=services,verbs=get;list;
127129
// +kubebuilder:rbac:groups=core,resources=secrets,verbs=get;list;watch;create;update;patch;delete;
130+
// +kubebuilder:rbac:groups=core,resources=configmaps,verbs=get;list;watch;create;update;patch;delete;
128131
// +kubebuilder:rbac:groups=cert-manager.io,resources=issuers,verbs=get;list;watch;create;update;patch;delete;
129132
// +kubebuilder:rbac:groups=cert-manager.io,resources=certificates,verbs=get;list;watch;create;update;patch;delete;
130133
// +kubebuilder:rbac:groups=config.openshift.io,resources=networks,verbs=get;list;watch;
134+
// +kubebuilder:rbac:groups=config.openshift.io,resources=apiservers,verbs=get;list;watch;
131135
// +kubebuilder:rbac:groups=topology.openstack.org,resources=topologies,verbs=get;list;watch;update
132136
// +kubebuilder:rbac:groups=watcher.openstack.org,resources=watchers,verbs=get;list;watch;create;update;patch;delete
133137

@@ -529,6 +533,13 @@ func (r *OpenStackControlPlaneReconciler) reconcileNormal(ctx context.Context, i
529533
return ctrlResult, nil
530534
}
531535

536+
ctrlResult, err = openstack.ReconcileTLSProfile(ctx, instance, helper)
537+
if err != nil {
538+
return ctrl.Result{}, err
539+
} else if (ctrlResult != ctrl.Result{}) {
540+
return ctrlResult, nil
541+
}
542+
532543
ctrlResult, err = openstack.ReconcileDNSMasqs(ctx, instance, version, helper)
533544
if err != nil {
534545
return ctrl.Result{}, err
@@ -916,6 +927,23 @@ func (r *OpenStackControlPlaneReconciler) SetupWithManager(
916927
handler.EnqueueRequestsFromMapFunc(r.findControlPlaneForSrc),
917928
builder.WithPredicates(backup.AnnotationChangedPredicate(openstack.ServiceCertSelector)),
918929
).
930+
Watches(
931+
&configv1.APIServer{},
932+
handler.EnqueueRequestsFromMapFunc(r.findControlPlaneForSrc),
933+
builder.WithPredicates(predicate.ResourceVersionChangedPredicate{}),
934+
).
935+
// The operator owns the full lifecycle of the TLS profile ConfigMap:
936+
// if it is deleted or edited out from under it, a reconcile has to
937+
// put it back. Without this watch, a removed ConfigMap would stay
938+
// gone until some unrelated event happened to reconcile the
939+
// control plane again.
940+
Watches(
941+
&corev1.ConfigMap{},
942+
handler.EnqueueRequestsFromMapFunc(r.findControlPlaneForSrc),
943+
builder.WithPredicates(predicate.NewPredicateFuncs(func(obj client.Object) bool {
944+
return obj.GetName() == util.TLSProfileConfigMap
945+
})),
946+
).
919947
Complete(r)
920948
}
921949

0 commit comments

Comments
 (0)