-
Notifications
You must be signed in to change notification settings - Fork 144
[multiple] Discover and configure Glance with Ceph RGW secrets #3169
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
evallesp
merged 1 commit into
openstack-k8s-operators:main
from
maximsava12:glance-ceph-s3-backend
Jan 14, 2026
+218
−0
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
fultonj marked this conversation as resolved.
Show resolved
Hide resolved
fultonj marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,60 @@ | ||
| --- | ||
| # Copyright Red Hat, Inc. | ||
| # All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
| # not use this file except in compliance with the License. You may obtain | ||
| # a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| # License for the specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| - name: Set fact for glance S3 backend secrets | ||
| ansible.builtin.set_fact: | ||
| ceph_s3_access_key: "{{ cifmw_ceph_client_s3_glance_user['keys'][0]['access_key'] }}" | ||
| ceph_s3_secret_key: "{{ cifmw_ceph_client_s3_glance_user['keys'][0]['secret_key'] }}" | ||
| ceph_s3_bucket: "glance-s3-bucket" | ||
| ceph_s3_endpoint: "{{ cifmw_ceph_client_s3_internal_swift_url }}" | ||
| when: | ||
| - cifmw_ceph_client_s3_glance_user is defined | ||
| - cifmw_ceph_client_s3_internal_swift_url is defined | ||
| no_log: true | ||
|
|
||
| - name: Generate Glance S3 backend secrets using Ceph RGW credentials | ||
| ansible.builtin.template: | ||
| src: templates/k8s_ceph_rgw_glance_secret.j2 | ||
| dest: k8s_ceph_rgw_glance_secret.yaml | ||
| mode: "0600" | ||
| force: true | ||
| when: | ||
| - ceph_s3_access_key is defined | ||
| - ceph_s3_secret_key is defined | ||
| no_log: true | ||
| register: reg_k8s_ceph_rgw_glance_secret | ||
|
|
||
| - name: Create glance S3 backend secrets | ||
| kubernetes.core.k8s: | ||
| kubeconfig: "{{ cifmw_openshift_kubeconfig }}" | ||
| api_key: "{{ cifmw_openshift_token | default(omit)}}" | ||
| context: "{{ cifmw_openshift_context | default(omit) }}" | ||
| namespace: openstack | ||
| state: present | ||
| apply: true | ||
| force: true | ||
| src: k8s_ceph_rgw_glance_secret.yaml | ||
| register: k8s_glance_s3_secret | ||
| delegate_to: localhost | ||
| no_log: true | ||
| when: reg_k8s_ceph_rgw_glance_secret is not skipped | ||
|
|
||
| - name: Delete the rendered secret file | ||
| ansible.builtin.file: | ||
| path: k8s_ceph_rgw_glance_secret.yaml | ||
| state: absent | ||
| delegate_to: localhost | ||
| when: k8s_glance_s3_secret | default(true) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
13 changes: 13 additions & 0 deletions
13
roles/cifmw_ceph_client/templates/k8s_ceph_rgw_glance_secret.j2
fultonj marked this conversation as resolved.
Show resolved
Hide resolved
|
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| # Glance secrets used to configure glance with ceph S3 backend | ||
| apiVersion: v1 | ||
| kind: Secret | ||
| metadata: | ||
| name: s3glance | ||
| stringData: | ||
| s3glance.conf: | | ||
| [default_backend] | ||
| s3_store_host = {{ ceph_s3_endpoint }} | ||
| s3_store_access_key = {{ ceph_s3_access_key }} | ||
| s3_store_secret_key = {{ ceph_s3_secret_key }} | ||
| s3_store_bucket = {{ ceph_s3_bucket }} | ||
| s3_store_cacert = "/etc/pki/tls/certs/ca-bundle.crt" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,125 @@ | ||
| --- | ||
| # Copyright 2025 Red Hat, Inc. | ||
| # All Rights Reserved. | ||
| # | ||
| # Licensed under the Apache License, Version 2.0 (the "License"); you may | ||
| # not use this file except in compliance with the License. You may obtain | ||
| # a copy of the License at | ||
| # | ||
| # http://www.apache.org/licenses/LICENSE-2.0 | ||
| # | ||
| # Unless required by applicable law or agreed to in writing, software | ||
| # distributed under the License is distributed on an "AS IS" BASIS, WITHOUT | ||
| # WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the | ||
| # License for the specific language governing permissions and limitations | ||
| # under the License. | ||
|
|
||
| - name: Create glance S3 RGW user and fetch object-store endpoint | ||
| when: cifmw_cephadm_rgw_s3_glance | default(false) | bool | ||
fultonj marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| block: | ||
| - name: Refresh ceph_cli | ||
| ansible.builtin.include_tasks: ceph_cli.yml | ||
| vars: | ||
| ceph_command: "radosgw-admin" | ||
|
|
||
| - name: Wait for RGW daemons to be running | ||
| ansible.builtin.command: | ||
| cmd: "{{ cifmw_cephadm_ceph_cli }} orch ps --daemon-type rgw --format json" | ||
| register: rgw_daemon_status | ||
| become: true | ||
| changed_when: false | ||
| failed_when: false | ||
| until: > | ||
| rgw_daemon_status.rc == 0 and | ||
| (rgw_daemon_status.stdout | default('[]') | from_json) | | ||
| selectattr('status_desc', 'equalto', 'running') | | ||
| list | length > 0 | ||
| retries: 30 | ||
| delay: 10 | ||
|
|
||
| - name: Check if Ceph S3 glance user exists | ||
| ansible.builtin.command: | ||
| cmd: >- | ||
| {{ cifmw_cephadm_ceph_cli }} user info --uid glance | ||
| no_log: true | ||
| become: true | ||
| ignore_errors: true | ||
| changed_when: false | ||
| register: cifmw_ceph_s3_glance_user_check | ||
| when: cifmw_cephadm_ceph_cli is defined | ||
|
|
||
| - name: Create Ceph S3 glance user | ||
| ansible.builtin.command: | ||
| cmd: >- | ||
| {{ cifmw_cephadm_ceph_cli }} user create | ||
| --uid="glance" | ||
| --display-name="Glance S3 User" | ||
| no_log: true | ||
| become: true | ||
| when: | ||
| - cifmw_ceph_s3_glance_user_check is not skipped | ||
evallesp marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| - cifmw_ceph_s3_glance_user_check.rc != 0 | ||
| register: glance_rgw_user_create | ||
| retries: 3 | ||
| delay: 5 | ||
| until: glance_rgw_user_create.rc == 0 | ||
|
|
||
| - name: Get RGW glance user info | ||
| ansible.builtin.command: | ||
| cmd: >- | ||
| {{ cifmw_cephadm_ceph_cli }} user info --uid="glance" | ||
| become: true | ||
| no_log: true | ||
| changed_when: false | ||
| register: ceph_rgw_glance_user_info | ||
|
|
||
| - name: Show RGW daemon status on failure | ||
| when: ceph_rgw_glance_user_info.rc != 0 | ||
| block: | ||
| - name: Get RGW daemon status for debugging | ||
| ansible.builtin.command: | ||
| cmd: "{{ cifmw_cephadm_ceph_cli }} orch ps --daemon-type rgw" | ||
| become: true | ||
| register: rgw_debug_status | ||
| changed_when: false | ||
|
|
||
| - name: Display RGW status | ||
| ansible.builtin.debug: | ||
| msg: "RGW daemon status: {{ rgw_debug_status.stdout }}" | ||
|
|
||
| - name: Fail with context | ||
| ansible.builtin.fail: | ||
| msg: | | ||
| Failed to fetch glance user info after creation. | ||
| User creation result: {{ glance_rgw_user_create | default('not attempted') }} | ||
| RGW daemon status shown above. | ||
|
|
||
| - name: Set facts RGW glance user | ||
| ansible.builtin.set_fact: | ||
| cifmw_ceph_s3_glance_user: "{{ ceph_rgw_glance_user_info.stdout | from_json }}" | ||
| when: | ||
| - ceph_rgw_glance_user_info is defined | ||
| - ceph_rgw_glance_user_info.rc == 0 | ||
| no_log: true | ||
|
|
||
| - name: Get OpenStack internal object-store endpoints | ||
| cifmw.general.ci_script: | ||
| extra_args: | ||
| KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}" | ||
| output_dir: "{{ cifmw_cephadm_basedir }}/artifacts" | ||
| script: |- | ||
| oc -n {{ cifmw_cephadm_ns }} rsh openstackclient openstack endpoint list --service object-store --interface internal -f value -c URL | ||
| delegate_to: localhost | ||
| register: object_store_endpoint_raw | ||
| when: | ||
| - cifmw_openshift_kubeconfig is defined | ||
| - cifmw_cephadm_basedir is defined | ||
| - cifmw_cephadm_rgw_s3_glance is defined | ||
|
|
||
| - name: Extract base URL without path | ||
| ansible.builtin.set_fact: | ||
| rgw_internal_url: >- | ||
| {{ | ||
| object_store_endpoint_raw.stdout | ||
| | regex_replace('(/swift.*)$', '') | ||
| }} | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.