Skip to content

Commit 227b00b

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 227b00b

File tree

9 files changed

+291
-61
lines changed

9 files changed

+291
-61
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 & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ 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/service"
2930
"github.com/openstack-k8s-operators/lib-common/modules/common/tls"
3031
"sigs.k8s.io/controller-runtime/pkg/client"
3132
"sigs.k8s.io/controller-runtime/pkg/event"
@@ -122,6 +123,7 @@ func GetAdminServiceClient(
122123
ctx context.Context,
123124
h *helper.Helper,
124125
keystoneAPI *KeystoneAPI,
126+
endpointInterface ...service.Endpoint,
125127
) (*openstack.OpenStack, ctrl.Result, error) {
126128
os, ctrlResult, err := GetScopedAdminServiceClient(
127129
ctx,
@@ -130,6 +132,7 @@ func GetAdminServiceClient(
130132
&gophercloud.AuthScope{
131133
System: true,
132134
},
135+
endpointInterface...,
133136
)
134137
if err != nil {
135138
return nil, ctrlResult, err
@@ -144,9 +147,15 @@ func GetScopedAdminServiceClient(
144147
h *helper.Helper,
145148
keystoneAPI *KeystoneAPI,
146149
scope *gophercloud.AuthScope,
150+
endpointInterface ...service.Endpoint,
147151
) (*openstack.OpenStack, ctrl.Result, error) {
148-
// get public endpoint as authurl from keystone instance
149-
authURL, err := keystoneAPI.GetEndpoint(endpoint.EndpointInternal)
152+
// get endpoint as authurl from keystone instance
153+
// default to internal endpoint if not specified
154+
epInterface := endpoint.EndpointInternal
155+
if len(endpointInterface) > 0 {
156+
epInterface = endpoint.Endpoint(endpointInterface[0])
157+
}
158+
authURL, err := keystoneAPI.GetEndpoint(epInterface)
150159
if err != nil {
151160
return nil, ctrl.Result{}, err
152161
}

api/v1beta1/keystoneapi_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,18 @@ type KeystoneAPISpecCore struct {
213213
// This is only needed when multiple realms are federated.
214214
// Config files mount path is set to /var/lib/httpd/metadata/
215215
FederatedRealmConfig string `json:"federatedRealmConfig"`
216+
217+
// +kubebuilder:validation:Optional
218+
// +kubebuilder:default=false
219+
// ExternalKeystoneAPI - Enable use of external Keystone API endpoints instead of deploying a local Keystone API
220+
ExternalKeystoneAPI bool `json:"externalKeystoneAPI"`
221+
}
222+
223+
// ExternalKeystoneAPI defines the configuration for an external Keystone API
224+
type ExternalKeystoneAPI struct {
225+
// +kubebuilder:validation:Optional
226+
// Endpoints - Endpoint URLs for the external Keystone API
227+
Endpoints map[string]string `json:"endpoints,omitempty"`
216228
}
217229

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

api/v1beta1/zz_generated.deepcopy.go

Lines changed: 22 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

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)