@@ -41,9 +41,8 @@ import (
4141 "sigs.k8s.io/controller-runtime/pkg/reconcile"
4242
4343 keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
44- "github.com/openstack-k8s-operators/lib-common/modules/certmanager"
4544 "github.com/openstack-k8s-operators/lib-common/modules/common"
46- "github.com/openstack-k8s-operators/lib-common/modules/common/clusterdns "
45+ "github.com/openstack-k8s-operators/lib-common/modules/common/endpoint "
4746 condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
4847 "github.com/openstack-k8s-operators/lib-common/modules/common/configmap"
4948 "github.com/openstack-k8s-operators/lib-common/modules/common/env"
@@ -217,7 +216,8 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
217216 }
218217
219218 clientLabels := map [string ]string {
220- common .AppSelector : "openstackclient" ,
219+ common .AppSelector : "openstackclient" ,
220+ common .OwnerSelector : instance .Name ,
221221 }
222222
223223 configVars := make (map [string ]env.Setter )
@@ -312,53 +312,28 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
312312 instance .Status .Conditions .MarkTrue (condition .TLSInputReadyCondition , condition .InputReadyMessage )
313313
314314 // Reconcile MCP sidecar resources when enabled
315- mcpTLSSecretName := ""
316315 if instance .Spec .MCP != nil && instance .Spec .MCP .Enabled {
317- mcpTLSEnabled := instance .Spec .CaBundleSecretName != ""
318-
319- if mcpTLSEnabled {
320- issuer , err := certmanager .GetIssuerByLabels (
321- ctx , helper ,
322- instance .Namespace ,
323- map [string ]string {certmanager .RootCAIssuerInternalLabel : "" },
324- )
325- if err != nil {
326- instance .Status .Conditions .Set (condition .FalseCondition (
327- clientv1 .OpenStackClientReadyCondition ,
328- condition .ErrorReason ,
329- condition .SeverityWarning ,
330- clientv1 .OpenStackClientReadyErrorMessage ,
331- err .Error ()))
332- return ctrl.Result {}, err
333- }
334-
335- clusterDomain := clusterdns .GetDNSClusterDomain ()
336- mcpSvcName := instance .Name + "-mcp"
337- certRequest := certmanager.CertificateRequest {
338- IssuerName : issuer .Name ,
339- CertName : mcpSvcName + "-tls" ,
340- Hostnames : []string {
341- fmt .Sprintf ("%s.%s.svc" , mcpSvcName , instance .Namespace ),
342- fmt .Sprintf ("%s.%s.svc.%s" , mcpSvcName , instance .Namespace , clusterDomain ),
343- },
344- Labels : map [string ]string {},
345- }
346- certSecret , ctrlResult , err := certmanager .EnsureCert (ctx , helper , certRequest , instance )
347- if err != nil {
348- instance .Status .Conditions .Set (condition .FalseCondition (
349- clientv1 .OpenStackClientReadyCondition ,
350- condition .ErrorReason ,
351- condition .SeverityWarning ,
352- clientv1 .OpenStackClientReadyErrorMessage ,
353- err .Error ()))
354- return ctrlResult , err
355- } else if (ctrlResult != ctrl.Result {}) {
356- return ctrlResult , nil
357- }
358- mcpTLSSecretName = certSecret .Name
359- configVars [mcpTLSSecretName ] = env .SetValue (certSecret .ResourceVersion )
316+ // Use the internal Keystone endpoint for the MCP sidecar's clouds.yaml
317+ // so it connects directly to the in-cluster service and avoids
318+ // TLS issues with the public OCP route.
319+ internalAuthURL , err := keystoneAPI .GetEndpoint (endpoint .EndpointInternal )
320+ if err != nil {
321+ instance .Status .Conditions .Set (condition .FalseCondition (
322+ clientv1 .OpenStackClientReadyCondition ,
323+ condition .RequestedReason ,
324+ condition .SeverityInfo ,
325+ "waiting for internal Keystone endpoint" ))
326+ return ctrl.Result {RequeueAfter : time .Duration (5 ) * time .Second }, nil
360327 }
361328
329+ mcpCloudsYAML := openstackclient .MCPCloudsYAML (
330+ internalAuthURL ,
331+ keystoneAPI .Spec .AdminProject ,
332+ keystoneAPI .Spec .AdminUser ,
333+ keystoneAPI .Spec .Region ,
334+ instance .Spec .CaBundleSecretName ,
335+ )
336+
362337 mcpConfigCM := & corev1.ConfigMap {
363338 ObjectMeta : metav1.ObjectMeta {
364339 Name : instance .Name + "-mcp-config" ,
@@ -367,14 +342,15 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
367342 }
368343 _ , err = controllerutil .CreateOrPatch (ctx , r .Client , mcpConfigCM , func () error {
369344 mcpConfigCM .Data = map [string ]string {
370- "config.yaml" : openstackclient .MCPConfigYAML (instance .Spec .CaBundleSecretName , mcpTLSEnabled ),
345+ "config.yaml" : openstackclient .MCPConfigYAML (instance .Spec .CaBundleSecretName ),
346+ "clouds.yaml" : mcpCloudsYAML ,
371347 }
372348 return controllerutil .SetControllerReference (instance , mcpConfigCM , r .Scheme )
373349 })
374350 if err != nil {
375351 return ctrl.Result {}, fmt .Errorf ("error creating MCP config ConfigMap: %w" , err )
376352 }
377- configVars [instance .Name + "-mcp-config" ] = env .SetValue (openstackclient .MCPConfigYAML (instance .Spec .CaBundleSecretName , mcpTLSEnabled ) )
353+ configVars [instance .Name + "-mcp-config" ] = env .SetValue (openstackclient .MCPConfigYAML (instance .Spec .CaBundleSecretName ) + mcpCloudsYAML )
378354
379355 }
380356
@@ -394,7 +370,6 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
394370 mcpServiceHash , err := util .ObjectHash (map [string ]interface {}{
395371 "containerImage" : instance .Spec .ContainerImage ,
396372 "mcpContainerImage" : instance .Spec .MCP .ContainerImage ,
397- "mcpConfig" : openstackclient .MCPConfigYAML (instance .Spec .CaBundleSecretName , instance .Spec .CaBundleSecretName != "" ),
398373 "configVarsHash" : configVarsHash ,
399374 })
400375 if err != nil {
@@ -428,7 +403,7 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
428403 },
429404 }
430405
431- spec := openstackclient .ClientPodSpec (ctx , instance , helper , configVarsHash , mcpTLSSecretName )
406+ spec := openstackclient .ClientPodSpec (ctx , instance , helper , configVarsHash )
432407
433408 podSpecHash , err := util .ObjectHash (spec )
434409 if err != nil {
0 commit comments