Skip to content

Commit cb67165

Browse files
committed
[hooks] Add install-openstack-lightspeed hook
This hook deploys the openstack lightspeed operator for OpenShift clusters. The openstack lightspeed operator automatically manages the OpenShift lightspeed operator as a dependency. FEATURES: - Deploys OpenStack Lightspeed operator via OLM - Configurable namespace (default: openshift-lightspeed) - Configurable host via cifmw_target_hook_host variable - CSV status check for reliable operator readiness - All parameters configurable via cifmw_* variables TECHNICAL DETAILS: - Tested on CRC. Signed-off-by: Malinga Tembo <[email protected]>
1 parent ffa7b99 commit cb67165

File tree

2 files changed

+133
-0
lines changed

2 files changed

+133
-0
lines changed

hooks/playbooks/README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,23 @@ on removing "import_playbook" usage in ci-framework project.
2424
### Output
2525
None
2626

27+
## install-openstack-lightspeed.yml
28+
Installs OpenShift Lightspeed and OpenStack Lightspeed operators on CRC cluster.
29+
This hook deploys both operators sequentially, setting up required namespaces,
30+
operator groups, catalog sources, and subscriptions.
31+
32+
### Input
33+
* `cifmw_openshift_lightspeed_namespace`: (String) Namespace for OpenShift Lightspeed operator. Defaults to `openshift-lightspeed`.
34+
* `cifmw_openshift_lightspeed_operator_group`: (String) OperatorGroup name for OpenShift Lightspeed. Defaults to `lightspeed-operator-group`.
35+
* `cifmw_openstack_lightspeed_namespace`: (String) Namespace for OpenStack Lightspeed operator. Defaults to `openstack-lightspeed`.
36+
* `cifmw_openstack_lightspeed_operator_group`: (String) OperatorGroup name for OpenStack Lightspeed. Defaults to `openstack-lightspeed-operator-group`.
37+
* `cifmw_openstack_lightspeed_catalog_image`: (String) Container image for OpenStack Lightspeed catalog source. Defaults to `quay.io/openstack-lightspeed/operator-catalog:latest`.
38+
* `cifmw_openstack_lightspeed_catalog_name`: (String) Name for OpenStack Lightspeed CatalogSource resource. Defaults to `openstack-lightspeed-catalog`.
39+
* `cifmw_openshift_kubeconfig`: (String) Path to kubeconfig file for OpenShift cluster. Defaults to `{{ ansible_env.HOME }}/.crc/machines/crc/kubeconfig`.
40+
41+
### Output
42+
None
43+
2744
## kustomize_cr.yml
2845
This hook enables customization of CR files, using oc kustomize.
2946
### Input
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
---
2+
3+
- name: Deploy OpenStack Lightspeed operator
4+
hosts: "{{ cifmw_target_hook_host | default('localhost') }}"
5+
connection: local
6+
vars:
7+
# OpenStack Lightspeed configuration
8+
# Note: Installing in openshift-lightspeed namespace to ensure compatibility
9+
openstack_lightspeed_namespace: "{{ cifmw_openstack_lightspeed_namespace | default('openshift-lightspeed') }}"
10+
openstack_lightspeed_operator_group: "{{ cifmw_openstack_lightspeed_operator_group | default('openstack-lightspeed-operator-group') }}"
11+
openstack_lightspeed_catalog_image: "{{ cifmw_openstack_lightspeed_catalog_image | default('quay.io/openstack-lightspeed/operator-catalog:latest') }}"
12+
openstack_lightspeed_catalog_name: "{{ cifmw_openstack_lightspeed_catalog_name | default('openstack-lightspeed-catalog') }}"
13+
14+
# Kubeconfig path
15+
cifmw_openshift_kubeconfig: "{{ ansible_env.HOME }}/.crc/machines/crc/kubeconfig"
16+
environment:
17+
KUBECONFIG: "{{ cifmw_openshift_kubeconfig }}"
18+
19+
tasks:
20+
# STEP 1: Deploy OpenStack Lightspeed catalog
21+
22+
- name: Create CatalogSource for OpenStack Lightspeed
23+
kubernetes.core.k8s:
24+
state: present
25+
definition:
26+
apiVersion: operators.coreos.com/v1alpha1
27+
kind: CatalogSource
28+
metadata:
29+
name: "{{ openstack_lightspeed_catalog_name }}"
30+
namespace: "openshift-marketplace"
31+
spec:
32+
sourceType: grpc
33+
image: "{{ openstack_lightspeed_catalog_image }}"
34+
displayName: "OpenStack Lightspeed Operator"
35+
publisher: "Red Hat"
36+
37+
- name: Wait for CatalogSource to be ready
38+
kubernetes.core.k8s_info:
39+
api_version: operators.coreos.com/v1alpha1
40+
kind: CatalogSource
41+
name: "{{ openstack_lightspeed_catalog_name }}"
42+
namespace: "openshift-marketplace"
43+
register: catalog_source
44+
failed_when: false
45+
until:
46+
- catalog_source.resources is defined
47+
- catalog_source.resources | length > 0
48+
- catalog_source.resources[0].status.connectionState.lastObservedState is defined
49+
- catalog_source.resources[0].status.connectionState.lastObservedState == "READY"
50+
retries: 30
51+
delay: 10
52+
53+
# STEP 2: Deploy OpenStack Lightspeed operator
54+
# Note: OpenStack Lightspeed operator will automatically install
55+
# and manage the OpenShift Lightspeed operator as a dependency
56+
57+
- name: Create namespace for OpenStack Lightspeed
58+
kubernetes.core.k8s:
59+
state: present
60+
definition:
61+
apiVersion: v1
62+
kind: Namespace
63+
metadata:
64+
name: "{{ openstack_lightspeed_namespace }}"
65+
66+
- name: Create OperatorGroup for OpenStack Lightspeed
67+
kubernetes.core.k8s:
68+
state: present
69+
definition:
70+
apiVersion: operators.coreos.com/v1
71+
kind: OperatorGroup
72+
metadata:
73+
name: "{{ openstack_lightspeed_operator_group }}"
74+
namespace: "{{ openstack_lightspeed_namespace }}"
75+
spec:
76+
targetNamespaces:
77+
- "{{ openstack_lightspeed_namespace }}"
78+
79+
- name: Subscribe to OpenStack Lightspeed operator
80+
kubernetes.core.k8s:
81+
state: present
82+
definition:
83+
apiVersion: operators.coreos.com/v1alpha1
84+
kind: Subscription
85+
metadata:
86+
name: "openstack-lightspeed-operator"
87+
namespace: "{{ openstack_lightspeed_namespace }}"
88+
spec:
89+
channel: "alpha"
90+
name: "openstack-lightspeed-operator"
91+
source: "{{ openstack_lightspeed_catalog_name }}"
92+
sourceNamespace: "openshift-marketplace"
93+
installPlanApproval: "Automatic"
94+
95+
- name: Wait for OpenStack Lightspeed CSV to be ready
96+
kubernetes.core.k8s_info:
97+
api_version: operators.coreos.com/v1alpha1
98+
kind: ClusterServiceVersion
99+
namespace: "{{ openstack_lightspeed_namespace }}"
100+
label_selectors:
101+
- "operators.coreos.com/openstack-lightspeed-operator.{{ openstack_lightspeed_namespace }}"
102+
register: osls_csv
103+
failed_when: false
104+
until:
105+
- osls_csv.resources is defined
106+
- osls_csv.resources | length > 0
107+
- osls_csv.resources[0].status.phase is defined
108+
- osls_csv.resources[0].status.phase == "Succeeded"
109+
retries: 30
110+
delay: 10
111+
112+
- name: Display deployment summary
113+
ansible.builtin.debug:
114+
msg:
115+
- "✓ OpenStack Lightspeed operator deployed in namespace: {{ openstack_lightspeed_namespace }}"
116+
- "✓ OpenShift Lightspeed operator will be automatically managed by OpenStack Lightspeed"

0 commit comments

Comments
 (0)