@@ -43,6 +43,7 @@ import (
4343 keystonev1 "github.com/openstack-k8s-operators/keystone-operator/api/v1beta1"
4444 "github.com/openstack-k8s-operators/lib-common/modules/certmanager"
4545 "github.com/openstack-k8s-operators/lib-common/modules/common"
46+ "github.com/openstack-k8s-operators/lib-common/modules/common/endpoint"
4647 "github.com/openstack-k8s-operators/lib-common/modules/common/clusterdns"
4748 condition "github.com/openstack-k8s-operators/lib-common/modules/common/condition"
4849 "github.com/openstack-k8s-operators/lib-common/modules/common/configmap"
@@ -217,7 +218,8 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
217218 }
218219
219220 clientLabels := map [string ]string {
220- common .AppSelector : "openstackclient" ,
221+ common .AppSelector : "openstackclient" ,
222+ common .OwnerSelector : instance .Name ,
221223 }
222224
223225 configVars := make (map [string ]env.Setter )
@@ -359,6 +361,27 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
359361 configVars [mcpTLSSecretName ] = env .SetValue (certSecret .ResourceVersion )
360362 }
361363
364+ // Use the internal Keystone endpoint for the MCP sidecar's clouds.yaml
365+ // so it connects directly to the in-cluster service and avoids
366+ // TLS issues with the public OCP route.
367+ internalAuthURL , err := keystoneAPI .GetEndpoint (endpoint .EndpointInternal )
368+ if err != nil {
369+ instance .Status .Conditions .Set (condition .FalseCondition (
370+ clientv1 .OpenStackClientReadyCondition ,
371+ condition .RequestedReason ,
372+ condition .SeverityInfo ,
373+ "waiting for internal Keystone endpoint" ))
374+ return ctrl.Result {RequeueAfter : time .Duration (5 ) * time .Second }, nil
375+ }
376+
377+ mcpCloudsYAML := openstackclient .MCPCloudsYAML (
378+ internalAuthURL ,
379+ keystoneAPI .Spec .AdminProject ,
380+ keystoneAPI .Spec .AdminUser ,
381+ keystoneAPI .Spec .Region ,
382+ instance .Spec .CaBundleSecretName ,
383+ )
384+
362385 mcpConfigCM := & corev1.ConfigMap {
363386 ObjectMeta : metav1.ObjectMeta {
364387 Name : instance .Name + "-mcp-config" ,
@@ -368,13 +391,14 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
368391 _ , err = controllerutil .CreateOrPatch (ctx , r .Client , mcpConfigCM , func () error {
369392 mcpConfigCM .Data = map [string ]string {
370393 "config.yaml" : openstackclient .MCPConfigYAML (instance .Spec .CaBundleSecretName , mcpTLSEnabled ),
394+ "clouds.yaml" : mcpCloudsYAML ,
371395 }
372396 return controllerutil .SetControllerReference (instance , mcpConfigCM , r .Scheme )
373397 })
374398 if err != nil {
375399 return ctrl.Result {}, fmt .Errorf ("error creating MCP config ConfigMap: %w" , err )
376400 }
377- configVars [instance .Name + "-mcp-config" ] = env .SetValue (openstackclient .MCPConfigYAML (instance .Spec .CaBundleSecretName , mcpTLSEnabled ))
401+ configVars [instance .Name + "-mcp-config" ] = env .SetValue (openstackclient .MCPConfigYAML (instance .Spec .CaBundleSecretName , mcpTLSEnabled ) + mcpCloudsYAML )
378402
379403 }
380404
@@ -394,7 +418,6 @@ func (r *OpenStackClientReconciler) Reconcile(ctx context.Context, req ctrl.Requ
394418 mcpServiceHash , err := util .ObjectHash (map [string ]interface {}{
395419 "containerImage" : instance .Spec .ContainerImage ,
396420 "mcpContainerImage" : instance .Spec .MCP .ContainerImage ,
397- "mcpConfig" : openstackclient .MCPConfigYAML (instance .Spec .CaBundleSecretName , instance .Spec .CaBundleSecretName != "" ),
398421 "configVarsHash" : configVarsHash ,
399422 })
400423 if err != nil {
0 commit comments