Skip to content

Commit f0918cb

Browse files
Akrogclaude
andcommitted
MCP Use Keystone Application Credentials
Initial implementation of the MCP deployment uses the credentials from the `openstackclient` pod, which means that we are not the owners of that secret, just the copy we make in the `openstack-lightspeed` namespace, so those credentials could be removed/deleted and that would break our `openstack-cli` tool. In this patch we change the credentials and we leverage the `KeystoneApplicationCredential` CR to get our own credentials. Credential Rotation is handled by the code as well. Jira: OSPRH-27075 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent ed884ef commit f0918cb

36 files changed

Lines changed: 1452 additions & 73 deletions

api/v1beta1/conditions.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,12 @@ const (
7777
// OpenStackLightspeedMCPServerWaitingOpenStack
7878
OpenStackLightspeedMCPServerWaitingOpenStack = "MCP server deployed, waiting for OpenStackControlPlane to become ready"
7979

80+
// OpenStackLightspeedMCPServerCreatingUser
81+
OpenStackLightspeedMCPServerCreatingUser = "Creating OpenStack service user"
82+
83+
// OpenStackLightspeedMCPServerWaitingAC
84+
OpenStackLightspeedMCPServerWaitingAC = "Waiting for application credential secret"
85+
8086
// OpenStackLightspeedMCPServerDisabledMessage
8187
OpenStackLightspeedMCPServerDisabledMessage = "RHOS MCP server is disabled (rhos_mcps feature flag not set)"
8288

api/v1beta1/openstacklightspeed_types.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -228,6 +228,11 @@ type OpenStackLightspeedStatus struct {
228228
// OpenStackReady indicates whether an OpenStackControlPlane was detected and
229229
// is ready. When true, the OpenStack MCP tools are included in lightspeed-stack config.
230230
OpenStackReady bool `json:"openStackReady,omitempty"`
231+
232+
// +optional
233+
// ApplicationCredentialSecret is the name of the current AC secret in the
234+
// OpenStack namespace. Tracked for rotation detection.
235+
ApplicationCredentialSecret string `json:"applicationCredentialSecret,omitempty"`
231236
}
232237

233238
// +kubebuilder:object:root=true

bundle/manifests/lightspeed.openstack.org_openstacklightspeeds.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ spec:
204204
ActiveOCPRAGVersion contains the OCP version being used for RAG configuration
205205
Will be one of: "4.16", "4.18", "latest", or empty if OCP RAG is disabled
206206
type: string
207+
applicationCredentialSecret:
208+
description: |-
209+
ApplicationCredentialSecret is the name of the current AC secret in the
210+
OpenStack namespace. Tracked for rotation detection.
211+
type: string
207212
conditions:
208213
description: Conditions
209214
items:

bundle/manifests/openstack-lightspeed-operator.clusterserviceversion.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,7 +178,13 @@ spec:
178178
resources:
179179
- secrets
180180
verbs:
181+
- create
182+
- delete
181183
- get
184+
- list
185+
- patch
186+
- update
187+
- watch
182188
- apiGroups:
183189
- ""
184190
resourceNames:
@@ -223,6 +229,24 @@ spec:
223229
- get
224230
- list
225231
- watch
232+
- apiGroups:
233+
- keystone.openstack.org
234+
resources:
235+
- keystoneapplicationcredentials
236+
verbs:
237+
- create
238+
- delete
239+
- get
240+
- list
241+
- patch
242+
- update
243+
- watch
244+
- apiGroups:
245+
- keystone.openstack.org
246+
resources:
247+
- keystoneapplicationcredentials/status
248+
verbs:
249+
- get
226250
- apiGroups:
227251
- lightspeed.openstack.org
228252
resources:

cmd/main.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -255,6 +255,11 @@ func getDynamicWatchCRDs() (map[schema.GroupVersionKind]*atomic.Bool, error) {
255255
Version: "v1beta1",
256256
Kind: "OpenStackControlPlane",
257257
}: new(atomic.Bool),
258+
{
259+
Group: "keystone.openstack.org",
260+
Version: "v1beta1",
261+
Kind: "KeystoneApplicationCredential",
262+
}: new(atomic.Bool),
258263
}
259264

260265
return dynamicWatchCRDs, nil

config/crd/bases/lightspeed.openstack.org_openstacklightspeeds.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,11 @@ spec:
204204
ActiveOCPRAGVersion contains the OCP version being used for RAG configuration
205205
Will be one of: "4.16", "4.18", "latest", or empty if OCP RAG is disabled
206206
type: string
207+
applicationCredentialSecret:
208+
description: |-
209+
ApplicationCredentialSecret is the name of the current AC secret in the
210+
OpenStack namespace. Tracked for rotation detection.
211+
type: string
207212
conditions:
208213
description: Conditions
209214
items:

config/rbac/role.yaml

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,13 @@ rules:
1717
resources:
1818
- secrets
1919
verbs:
20+
- create
21+
- delete
2022
- get
23+
- list
24+
- patch
25+
- update
26+
- watch
2127
- apiGroups:
2228
- ""
2329
resourceNames:
@@ -62,6 +68,24 @@ rules:
6268
- get
6369
- list
6470
- watch
71+
- apiGroups:
72+
- keystone.openstack.org
73+
resources:
74+
- keystoneapplicationcredentials
75+
verbs:
76+
- create
77+
- delete
78+
- get
79+
- list
80+
- patch
81+
- update
82+
- watch
83+
- apiGroups:
84+
- keystone.openstack.org
85+
resources:
86+
- keystoneapplicationcredentials/status
87+
verbs:
88+
- get
6589
- apiGroups:
6690
- lightspeed.openstack.org
6791
resources:

go.mod

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ require (
88
github.com/onsi/gomega v1.39.0
99
github.com/openshift/api v3.9.0+incompatible // from lib-common
1010
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.0
11+
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.0
1112
github.com/operator-framework/api v0.37.0
1213
k8s.io/api v0.34.2
1314
k8s.io/apiextensions-apiserver v0.34.2
@@ -21,6 +22,8 @@ require (
2122
// must be consistent within modules and service operators
2223
replace github.com/openshift/api => github.com/openshift/api v0.0.0-20250711200046-c86d80652a9e
2324

25+
require k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
26+
2427
require (
2528
cel.dev/expr v0.24.0 // indirect
2629
github.com/Masterminds/semver/v3 v3.4.0 // indirect
@@ -48,6 +51,7 @@ require (
4851
github.com/google/go-cmp v0.7.0 // indirect
4952
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 // indirect
5053
github.com/google/uuid v1.6.0 // indirect
54+
github.com/gophercloud/gophercloud v1.14.1 // indirect
5155
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.0 // indirect
5256
github.com/inconshreveable/mousetrap v1.1.0 // indirect
5357
github.com/josharian/intern v1.0.0 // indirect
@@ -102,7 +106,6 @@ require (
102106
k8s.io/component-base v0.34.2 // indirect
103107
k8s.io/klog/v2 v2.130.1 // indirect
104108
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
105-
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect
106109
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.33.0 // indirect
107110
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
108111
sigs.k8s.io/randfill v1.0.0 // indirect

go.sum

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@ github.com/google/pprof v0.0.0-20250403155104-27863c87afa6 h1:BHT72Gu3keYf3ZEu2J
7171
github.com/google/pprof v0.0.0-20250403155104-27863c87afa6/go.mod h1:boTsfXsheKC2y+lKOCMpSfarhxDeIzfZG1jqGcPl3cA=
7272
github.com/google/uuid v1.6.0 h1:NIvaJDMOsjHA8n1jAhLSgzrAzy1Hgr+hNrb57e+94F0=
7373
github.com/google/uuid v1.6.0/go.mod h1:TIyPZe4MgqvfeYDBFedMoGGpEw/LqOeaOT+nhxU+yHo=
74+
github.com/gophercloud/gophercloud v1.14.1 h1:DTCNaTVGl8/cFu58O1JwWgis9gtISAFONqpMKNg/Vpw=
75+
github.com/gophercloud/gophercloud v1.14.1/go.mod h1:aAVqcocTSXh2vYFZ1JTvx4EQmfgzxRcNupUfxZbBNDM=
7476
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.0 h1:+epNPbD5EqgpEMm5wrl4Hqts3jZt8+kYaqUisuuIGTk=
7577
github.com/grpc-ecosystem/grpc-gateway/v2 v2.27.0/go.mod h1:Zanoh4+gvIgluNqcfMVTJueD4wSS5hT7zTt4Mrutd90=
7678
github.com/inconshreveable/mousetrap v1.1.0 h1:wN+x4NVGpMsO7ErUn/mUI3vEoE6Jt13X2s0bqwp9tc8=
@@ -113,6 +115,8 @@ github.com/openshift/api v0.0.0-20250711200046-c86d80652a9e h1:E1OdwSpqWuDPCedyU
113115
github.com/openshift/api v0.0.0-20250711200046-c86d80652a9e/go.mod h1:Shkl4HanLwDiiBzakv+con/aMGnVE2MAGvoKp5oyYUo=
114116
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.0 h1:2TD4hi+MLt67jKxJUs2tuBKFMxibrLJQqKqhsTMsHeQ=
115117
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.0/go.mod h1:rgpcv2tLD+/vudXx/gpIQSTuRpk4GOxHx84xwfvQalM=
118+
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.0 h1:8BniQwsPk8qjqoniLFDLnBEJgA0FLOwIrPDv93URiMo=
119+
github.com/openstack-k8s-operators/lib-common/modules/openstack v0.6.0/go.mod h1:tfMa+ochq7Dyilq9hQr2CEPfPtsj6IUgMmMqi4CWDmo=
116120
github.com/operator-framework/api v0.37.0 h1:2XCMWitBnumtJTqzip6LQKUwpM2pXVlt3gkpdlkbaCE=
117121
github.com/operator-framework/api v0.37.0/go.mod h1:NZs4vB+Jiamyv3pdPDjZtuC4U7KX0eq4z2r5hKY5fUA=
118122
github.com/pkg/errors v0.9.1 h1:FEBLx1zS214owpjy7qsBeixbURkuhQAwrK5UwLGTwt4=
@@ -196,6 +200,7 @@ go.yaml.in/yaml/v3 v3.0.4/go.mod h1:DhzuOOF2ATzADvBadXxruRBLzYTpT36CKvDb3+aBEFg=
196200
golang.org/x/crypto v0.0.0-20190308221718-c2843e01d9a2/go.mod h1:djNgcEr1/C05ACkg1iLfiJU5Ep61QUkGW8qpdssI0+w=
197201
golang.org/x/crypto v0.0.0-20191011191535-87dc89f01550/go.mod h1:yigFU9vqHzYiE8UmvKecakEJjdnWj3jj499lnFckfCI=
198202
golang.org/x/crypto v0.0.0-20200622213623-75b288015ac9/go.mod h1:LzIPMQfyMNhhGPhUkYOs5KpL4U8rLKemX1yGLhDgUto=
203+
golang.org/x/crypto v0.0.0-20220829220503-c86fa9a7ed90/go.mod h1:IxCIyHEi3zRg3s0A5j5BB6A9Jmi73HwBIUl50j+osU4=
199204
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b h1:M2rDM6z3Fhozi9O7NWsxAkg/yqS/lQJ6PmkyIV3YP+o=
200205
golang.org/x/exp v0.0.0-20250620022241-b7579e27df2b/go.mod h1:3//PLf8L/X+8b4vuAfHzxeRUl04Adcb341+IGKfnqS8=
201206
golang.org/x/mod v0.2.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA=
@@ -206,6 +211,7 @@ golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn
206211
golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
207212
golang.org/x/net v0.0.0-20200226121028-0de0cce0169b/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s=
208213
golang.org/x/net v0.0.0-20201021035429-f5854403a974/go.mod h1:sp8m0HH+o8qH0wwXwYZr8TS3Oi6o0r6Gce1SSxlDquU=
214+
golang.org/x/net v0.0.0-20211112202133-69e39bad7dc2/go.mod h1:9nx3DQGgdP8bBQD5qxJ1jj9UTztislL4KSBs9R2vV5Y=
209215
golang.org/x/net v0.43.0 h1:lat02VYK2j4aLzMzecihNvTlJNQUq316m2Mr9rnM6YE=
210216
golang.org/x/net v0.43.0/go.mod h1:vhO1fvI4dGsIjh73sWfUVjj3N7CA9WkKJNQm2svM6Jg=
211217
golang.org/x/oauth2 v0.30.0 h1:dnDm7JmhM45NNpd8FDDeLhK6FwqbOf4MLCM9zb1BOHI=
@@ -218,13 +224,18 @@ golang.org/x/sync v0.16.0/go.mod h1:1dzgHSNfp02xaA81J2MS99Qcpr2w7fw1gpm99rleRqA=
218224
golang.org/x/sys v0.0.0-20190215142949-d0b11bdaac8a/go.mod h1:STP8DvDyc/dI5b8T5hshtkjS+E42TnysNCUPdjciGhY=
219225
golang.org/x/sys v0.0.0-20190412213103-97732733099d/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
220226
golang.org/x/sys v0.0.0-20200930185726-fdedc70b468f/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
227+
golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
228+
golang.org/x/sys v0.0.0-20210423082822-04245dca01da/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs=
229+
golang.org/x/sys v0.0.0-20210615035016-665e8c7367d1/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
221230
golang.org/x/sys v0.0.0-20220715151400-c0bba94af5f8/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg=
222231
golang.org/x/sys v0.35.0 h1:vz1N37gP5bs89s7He8XuIYXpyY0+QlsKmzipCbUtyxI=
223232
golang.org/x/sys v0.35.0/go.mod h1:BJP2sWEmIv4KK5OTEluFJCKSidICx8ciO85XgH3Ak8k=
233+
golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo=
224234
golang.org/x/term v0.34.0 h1:O/2T7POpk0ZZ7MAzMeWFSg6S5IpWd/RXDlM9hgM3DR4=
225235
golang.org/x/term v0.34.0/go.mod h1:5jC53AEywhIVebHgPVeg0mj8OD3VO9OzclacVrqpaAw=
226236
golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ=
227237
golang.org/x/text v0.3.3/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
238+
golang.org/x/text v0.3.6/go.mod h1:5Zoc/QRtKVWzQhOtBMvqHzDpF6irO9z98xDceosuGiQ=
228239
golang.org/x/text v0.28.0 h1:rhazDwis8INMIwQ4tpjLDzUhx6RlXqZNPEM0huQojng=
229240
golang.org/x/text v0.28.0/go.mod h1:U8nCwOR8jO/marOQ0QbDiOngZVEBB7MAiitBuMjXiNU=
230241
golang.org/x/time v0.12.0 h1:ScB/8o8olJvc+CQPWrK3fPZNfh7qgwCrY0zJmoEQLSE=
@@ -256,6 +267,7 @@ gopkg.in/evanphx/json-patch.v4 v4.12.0 h1:n6jtcsulIzXPJaxegRbvFNNrZDjbij7ny3gmSP
256267
gopkg.in/evanphx/json-patch.v4 v4.12.0/go.mod h1:p8EYWUEYMpynmqDbY58zCKCFZw8pRWMG4EsWvDvM72M=
257268
gopkg.in/inf.v0 v0.9.1 h1:73M5CoZyi3ZLMOyDlQh031Cx6N9NDJ2Vvfl76EDAgDc=
258269
gopkg.in/inf.v0 v0.9.1/go.mod h1:cWUDdTG/fYaXco+Dcufb5Vnc6Gp2YChqWtbxRZE0mXw=
270+
gopkg.in/yaml.v2 v2.4.0/go.mod h1:RDklbk79AGWmwhnvt/jBztapEOGDOx6ZbXqjP6csGnQ=
259271
gopkg.in/yaml.v3 v3.0.0-20200313102051-9f266ea9e77c/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
260272
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
261273
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=

internal/controller/common.go

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,15 @@ func OpenStackControlPlaneGVK() schema.GroupVersionKind {
240240
}
241241
}
242242

243+
// KeystoneApplicationCredentialGVK returns the GroupVersionKind for KeystoneApplicationCredential.
244+
func KeystoneApplicationCredentialGVK() schema.GroupVersionKind {
245+
return schema.GroupVersionKind{
246+
Group: KeystoneApplicationCredentialGroup,
247+
Version: KeystoneApplicationCredentialVersion,
248+
Kind: KeystoneApplicationCredentialKind,
249+
}
250+
}
251+
243252
// IsDynamicCRDReadyByGVK checks whether the given GVK is being watched and has
244253
// been observed as ready by the dynamic watch.
245254
func IsDynamicCRDReadyByGVK(

0 commit comments

Comments
 (0)