Skip to content

Commit 0e4e747

Browse files
committed
Add support for External Keystone Service
This patch adds a new `ExternalKeystoneAPI` property to KeystoneAPI to enable the use of an existing Keystone Service that is external to the OpenShift environment used to run this operator. For example, a multi-region deployment where one region is running a centralized Keystone service can use this to deploy additional regions that can use the centralized Keystone service without the need to run their own instance of Keystone. Assisted-by: Cursor (Auto Model)
1 parent 593df0a commit 0e4e747

File tree

8 files changed

+270
-63
lines changed

8 files changed

+270
-63
lines changed

api/bases/keystone.openstack.org_keystoneapis.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ spec:
9898
description: EnableSecureRBAC - Enable Consistent and Secure RBAC
9999
policies
100100
type: boolean
101+
externalKeystoneAPI:
102+
default: false
103+
description: ExternalKeystoneAPI - Enable use of external Keystone
104+
API endpoints instead of deploying a local Keystone API
105+
type: boolean
101106
extraMounts:
102107
default: []
103108
description: ExtraMounts containing conf files

api/v1beta1/conditions.go

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,4 +111,25 @@ const (
111111

112112
// KeystoneServiceOSUserReadyErrorMessage
113113
KeystoneServiceOSUserReadyErrorMessage = "Keystone Service user error occured %s"
114+
115+
//
116+
// External Keystone API condition messages
117+
//
118+
// ExternalKeystoneAPIDBMessage
119+
ExternalKeystoneAPIDBMessage = "External Keystone API configured - database is not managed by this operator"
120+
121+
// ExternalKeystoneAPIDBAccountMessage
122+
ExternalKeystoneAPIDBAccountMessage = "External Keystone API configured - database account is not managed by this operator"
123+
124+
// ExternalKeystoneAPIRabbitMQTransportURLMessage
125+
ExternalKeystoneAPIRabbitMQTransportURLMessage = "External Keystone API configured - RabbitMQ is not managed by this operator"
126+
127+
// ExternalKeystoneAPIMemcachedReadyMessage
128+
ExternalKeystoneAPIMemcachedReadyMessage = "External Keystone API configured - memcached is not managed by this operator"
129+
130+
// ExternalKeystoneAPIServiceConfigReadyMessage
131+
ExternalKeystoneAPIServiceMessage = "External Keystone API configured - service is not managed by this operator"
132+
133+
// ExternalKeystoneAPINetworkAttachmentsReadyMessage
134+
ExternalKeystoneAPINetworkAttachmentsReadyMessage = "External Keystone API configured - network attachments are not managed by this operator"
114135
)

api/v1beta1/keystoneapi.go

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ import (
2626
"github.com/openstack-k8s-operators/lib-common/modules/common/endpoint"
2727
"github.com/openstack-k8s-operators/lib-common/modules/common/helper"
2828
"github.com/openstack-k8s-operators/lib-common/modules/common/secret"
29-
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
3029
"sigs.k8s.io/controller-runtime/pkg/client"
3130
"sigs.k8s.io/controller-runtime/pkg/event"
3231
"sigs.k8s.io/controller-runtime/pkg/predicate"
@@ -122,6 +121,7 @@ func GetAdminServiceClient(
122121
ctx context.Context,
123122
h *helper.Helper,
124123
keystoneAPI *KeystoneAPI,
124+
endpointInterface ...endpoint.Endpoint,
125125
) (*openstack.OpenStack, ctrl.Result, error) {
126126
os, ctrlResult, err := GetScopedAdminServiceClient(
127127
ctx,
@@ -130,6 +130,7 @@ func GetAdminServiceClient(
130130
&gophercloud.AuthScope{
131131
System: true,
132132
},
133+
endpointInterface...,
133134
)
134135
if err != nil {
135136
return nil, ctrlResult, err
@@ -144,9 +145,15 @@ func GetScopedAdminServiceClient(
144145
h *helper.Helper,
145146
keystoneAPI *KeystoneAPI,
146147
scope *gophercloud.AuthScope,
148+
endpointInterface ...endpoint.Endpoint,
147149
) (*openstack.OpenStack, ctrl.Result, error) {
148-
// get public endpoint as authurl from keystone instance
149-
authURL, err := keystoneAPI.GetEndpoint(endpoint.EndpointInternal)
150+
// get endpoint as authurl from keystone instance
151+
// default to internal endpoint if not specified
152+
epInterface := endpoint.EndpointInternal
153+
if len(endpointInterface) > 0 {
154+
epInterface = endpoint.Endpoint(endpointInterface[0])
155+
}
156+
authURL, err := keystoneAPI.GetEndpoint(epInterface)
150157
if err != nil {
151158
return nil, ctrl.Result{}, err
152159
}
@@ -163,7 +170,7 @@ func GetScopedAdminServiceClient(
163170
h,
164171
keystoneAPI.Spec.TLS.CaBundleSecretName,
165172
10*time.Second,
166-
tls.InternalCABundleKey)
173+
interfaceBundleKeys[epInterface])
167174
if err != nil {
168175
return nil, ctrl.Result{}, err
169176
}

api/v1beta1/keystoneapi_types.go

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,14 @@ const (
5353
APIDefaultTimeout = 60
5454
)
5555

56+
var (
57+
// interfaceBundleKeys maps endpoint winterfaces to their corresponding key in the CA bundle secret
58+
interfaceBundleKeys = map[endpoint.Endpoint]string{
59+
endpoint.EndpointInternal: tls.InternalCABundleKey,
60+
endpoint.EndpointPublic: tls.CABundleKey,
61+
}
62+
)
63+
5664
// KeystoneAPISpec defines the desired state of KeystoneAPI
5765
type KeystoneAPISpec struct {
5866
KeystoneAPISpecCore `json:",inline"`
@@ -213,6 +221,11 @@ type KeystoneAPISpecCore struct {
213221
// This is only needed when multiple realms are federated.
214222
// Config files mount path is set to /var/lib/httpd/metadata/
215223
FederatedRealmConfig string `json:"federatedRealmConfig"`
224+
225+
// +kubebuilder:validation:Optional
226+
// +kubebuilder:default=false
227+
// ExternalKeystoneAPI - Enable use of external Keystone API endpoints instead of deploying a local Keystone API
228+
ExternalKeystoneAPI bool `json:"externalKeystoneAPI"`
216229
}
217230

218231
// APIOverrideSpec to override the generated manifest of several child resources.

config/crd/bases/keystone.openstack.org_keystoneapis.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,11 @@ spec:
9898
description: EnableSecureRBAC - Enable Consistent and Secure RBAC
9999
policies
100100
type: boolean
101+
externalKeystoneAPI:
102+
default: false
103+
description: ExternalKeystoneAPI - Enable use of external Keystone
104+
API endpoints instead of deploying a local Keystone API
105+
type: boolean
101106
extraMounts:
102107
default: []
103108
description: ExtraMounts containing conf files

0 commit comments

Comments
 (0)