Skip to content

Commit 0a68dfd

Browse files
Merge pull request #101 from Akrog/lcore-console
OLS console
2 parents f51da6b + ba3edf2 commit 0a68dfd

24 files changed

Lines changed: 1407 additions & 10 deletions

Makefile

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,10 @@ CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:$(TAG)
4242
CATALOG_NAME ?= openstack-lightspeed-catalog
4343
CATALOG_CHANNEL ?= alpha
4444

45+
# OpenShift internal registry support for local development/testing.
46+
OCP_REGISTRY_NAMESPACE ?= openstack-lightspeed
47+
OCP_INTERNAL_REGISTRY ?= image-registry.openshift-image-registry.svc:5000
48+
4549
# BUNDLE_IMG defines the image:tag used for the bundle.
4650
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
4751
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:$(TAG)
@@ -281,6 +285,20 @@ kuttl-test: kuttl ## Run kuttl tests
281285
.PHONY: kuttl-test-run
282286
kuttl-test-run: kuttl openstack-lightspeed-deploy kuttl-test openstack-lightspeed-undeploy
283287

288+
.PHONY: ocp-registry-push
289+
ocp-registry-push: ## Push images to the OpenShift internal registry.
290+
bash scripts/ocp-registry-push.sh $(CONTAINER_TOOL) $(OCP_REGISTRY_NAMESPACE) $(IMG) $(CATALOG_IMG)
291+
292+
.PHONY: ocp-catalog-build
293+
ocp-catalog-build: opm ## Build a catalog image for the OpenShift internal registry.
294+
bash scripts/ocp-catalog-build.sh $(CONTAINER_TOOL) $(BUNDLE_IMG) $(CATALOG_IMG) $(OPM)
295+
296+
.PHONY: kuttl-test-ocp
297+
kuttl-test-ocp: IMG = $(OCP_INTERNAL_REGISTRY)/$(OCP_REGISTRY_NAMESPACE)/operator:latest
298+
kuttl-test-ocp: BUNDLE_IMG = $(OCP_INTERNAL_REGISTRY)/openshift-marketplace/operator-bundle:$(TAG)
299+
kuttl-test-ocp: CATALOG_IMG = $(OCP_INTERNAL_REGISTRY)/openshift-marketplace/operator-catalog:$(TAG)
300+
kuttl-test-ocp: docker-build bundle bundle-build ocp-catalog-build ocp-registry-push kuttl-test-run
301+
284302
# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
285303
# $1 - target path with name of binary
286304
# $2 - package url which can be installed

README.md

Lines changed: 42 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -226,14 +226,51 @@ pre-commit run --all-files
226226
KUTTL (KUbernetes Test TooL) tests validate the operator's behavior in a real
227227
OpenShift environment.
228228

229-
Before running the tests ensure that:
230-
- `oc` CLI tool is available in your PATH and you can access an OpenShift cluster
231-
(e.g., deployed with `crc`) with it
232-
- The `openshift-lightspeed` namespace is empty or non-existing to prevent collisions
229+
Kuttl tests are run using the `kuttl-test` make target, which has some
230+
requirements:
233231

234-
Once you are ready you can run the KUTTL tests using:
232+
- `kubectl-kuttl`, `diff` and `oc` binaries exist and are in the `PATH`.
233+
- An OpenShift cluster is up and running (e.g., one deployed with `crc`).
234+
- `oc` CLI tool can access the OpenShift cluster and is logged in.
235+
- The OpenStack Lightspeed operator to be tested is installed and running in the
236+
OpenShift cluster in the `openstack-lightspeed` namespace.
237+
238+
Using the `kuttl-test` directly is uncommon, as we have 2 helpful targets:
239+
240+
- `kuttl-test-run`: Given a catalog image location deploys OpenStack Lightspeed
241+
on the OpenShift cluster, runs the tests (using `kuttl-test`), and removes
242+
OpenStack Lightspeed.
243+
244+
- `kuttl-test-ocp`: Builds the operator, bundle and catalog images, pushes them
245+
to the OpenShift cluster internal registry, and then runs the kuttl tests
246+
(using `kuttl-test-run`).
247+
248+
In both cases it will check that the `kubectl-kuttl` binary is present in the
249+
system and download it if it's not (target `kuttl`) and both need the
250+
`openstack-lightspeed` namespace to be empty or non-existing to prevent
251+
collisions.
252+
253+
For the `kuttl-test-run` target the images need to be available in an image
254+
registry accessible by the OpenShift cluster. We can build these images
255+
ourselves or use images built by others, in any case variable `CATALOG_IMG`
256+
must point to the catalog image before running `kuttl-test-run`.
257+
258+
Using `kuttl-test-ocp` is useful to build and test everything, but it's too
259+
wasteful if we are going to run kuttl tests multiple times, where
260+
`kuttl-test-run` is better as it doesn't rebuild the images on each run.
261+
262+
A useful option when working on kuttl tests, without changes on the operator
263+
itself, is to use `kuttl-test-ocp` the first time:
264+
265+
```bash
266+
make kuttl-test-ocp
267+
```
268+
269+
And then set `CATALOG_IMG` and use the `kuttl-test-run` target in
270+
consecutive runs:
235271

236272
```bash
273+
export CATALOG_IMG=image-registry.openshift-image-registry.svc:5000/openshift-marketplace/operator-catalog:latest
237274
make kuttl-test-run
238275
```
239276

api/v1beta1/openstacklightspeed_types.go

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ const (
3838
// PostgresContainerImage is the fall-back container image for PostgreSQL
3939
PostgresContainerImage = "registry.redhat.io/rhel9/postgresql-16:latest"
4040

41+
// ConsoleContainerImage is the fall-back container image for the Console Plugin (PatternFly 6, OCP >= 4.19)
42+
ConsoleContainerImage = "registry.redhat.io/openshift-lightspeed/lightspeed-console-plugin-rhel9:1.0.12"
43+
44+
// ConsoleContainerImagePF5 is the fall-back console image for PatternFly 5 (OCP < 4.19)
45+
ConsoleContainerImagePF5 = "registry.redhat.io/openshift-lightspeed/lightspeed-console-plugin-pf5-rhel9:1.0.12"
46+
4147
// MaxTokensForResponseDefault is the default maximum number of tokens that should be used for response
4248
MaxTokensForResponseDefault = 2048
4349
)
@@ -186,6 +192,8 @@ type OpenStackLightspeedDefaults struct {
186192
LCoreImageURL string
187193
ExporterImageURL string
188194
PostgresImageURL string
195+
ConsoleImageURL string
196+
ConsoleImagePF5URL string
189197
MaxTokensForResponse int
190198
}
191199

@@ -203,6 +211,10 @@ func SetupDefaults() {
203211
"RELATED_IMAGE_EXPORTER_IMAGE_URL_DEFAULT", ExporterContainerImage),
204212
PostgresImageURL: util.GetEnvVar(
205213
"RELATED_IMAGE_POSTGRES_IMAGE_URL_DEFAULT", PostgresContainerImage),
214+
ConsoleImageURL: util.GetEnvVar(
215+
"RELATED_IMAGE_CONSOLE_IMAGE_URL_DEFAULT", ConsoleContainerImage),
216+
ConsoleImagePF5URL: util.GetEnvVar(
217+
"RELATED_IMAGE_CONSOLE_PF5_IMAGE_URL_DEFAULT", ConsoleContainerImagePF5),
206218
MaxTokensForResponse: MaxTokensForResponseDefault,
207219
}
208220

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

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,18 @@ spec:
162162
- get
163163
- list
164164
- watch
165+
- apiGroups:
166+
- console.openshift.io
167+
resources:
168+
- consoleplugins
169+
verbs:
170+
- create
171+
- delete
172+
- get
173+
- list
174+
- patch
175+
- update
176+
- watch
165177
- apiGroups:
166178
- lightspeed.openstack.org
167179
resources:
@@ -188,6 +200,15 @@ spec:
188200
- get
189201
- patch
190202
- update
203+
- apiGroups:
204+
- operator.openshift.io
205+
resources:
206+
- consoles
207+
verbs:
208+
- get
209+
- list
210+
- update
211+
- watch
191212
- apiGroups:
192213
- operators.coreos.com
193214
resources:

cmd/main.go

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ import (
3838
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
3939
"sigs.k8s.io/controller-runtime/pkg/webhook"
4040

41+
consolev1 "github.com/openshift/api/console/v1"
42+
openshiftv1 "github.com/openshift/api/operator/v1"
4143
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"
4244

4345
apiv1beta1 "github.com/openstack-lightspeed/operator/api/v1beta1"
@@ -56,6 +58,10 @@ func init() {
5658
utilruntime.Must(operatorsv1alpha1.AddToScheme(scheme))
5759

5860
utilruntime.Must(apiv1beta1.AddToScheme(scheme))
61+
62+
utilruntime.Must(consolev1.AddToScheme(scheme))
63+
64+
utilruntime.Must(openshiftv1.AddToScheme(scheme))
5965
// +kubebuilder:scaffold:scheme
6066
}
6167

config/rbac/role.yaml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,18 @@ rules:
2020
- get
2121
- list
2222
- watch
23+
- apiGroups:
24+
- console.openshift.io
25+
resources:
26+
- consoleplugins
27+
verbs:
28+
- create
29+
- delete
30+
- get
31+
- list
32+
- patch
33+
- update
34+
- watch
2335
- apiGroups:
2436
- lightspeed.openstack.org
2537
resources:
@@ -46,6 +58,15 @@ rules:
4658
- get
4759
- patch
4860
- update
61+
- apiGroups:
62+
- operator.openshift.io
63+
resources:
64+
- consoles
65+
verbs:
66+
- get
67+
- list
68+
- update
69+
- watch
4970
- apiGroups:
5071
- operators.coreos.com
5172
resources:

go.mod

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,20 @@ require (
66
github.com/go-logr/logr v1.4.3
77
github.com/onsi/ginkgo/v2 v2.27.5
88
github.com/onsi/gomega v1.39.0
9+
github.com/openshift/api v3.9.0+incompatible // from lib-common
910
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.0
1011
github.com/operator-framework/api v0.37.0
12+
k8s.io/api v0.34.2
1113
k8s.io/apimachinery v0.34.3
1214
k8s.io/client-go v0.34.2
13-
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
1415
sigs.k8s.io/controller-runtime v0.22.4
16+
sigs.k8s.io/yaml v1.6.0
1517
)
1618

19+
// from https://github.com/openstack-k8s-operators/lib-common/blob/main/modules/common/go.mod
20+
// must be consistent within modules and service operators
21+
replace github.com/openshift/api => github.com/openshift/api v0.0.0-20250711200046-c86d80652a9e
22+
1723
require (
1824
cel.dev/expr v0.24.0 // indirect
1925
github.com/Masterminds/semver/v3 v3.4.0 // indirect
@@ -91,15 +97,14 @@ require (
9197
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
9298
gopkg.in/inf.v0 v0.9.1 // indirect
9399
gopkg.in/yaml.v3 v3.0.1 // indirect
94-
k8s.io/api v0.34.2 // indirect
95100
k8s.io/apiextensions-apiserver v0.34.2 // indirect
96101
k8s.io/apiserver v0.34.2 // indirect
97102
k8s.io/component-base v0.34.2 // indirect
98103
k8s.io/klog/v2 v2.130.1 // indirect
99104
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
105+
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect
100106
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.33.0 // indirect
101107
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
102108
sigs.k8s.io/randfill v1.0.0 // indirect
103109
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
104-
sigs.k8s.io/yaml v1.6.0 // indirect
105110
)

go.sum

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,8 @@ github.com/onsi/ginkgo/v2 v2.27.5 h1:ZeVgZMx2PDMdJm/+w5fE/OyG6ILo1Y3e+QX4zSR0zTE
109109
github.com/onsi/ginkgo/v2 v2.27.5/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo=
110110
github.com/onsi/gomega v1.39.0 h1:y2ROC3hKFmQZJNFeGAMeHZKkjBL65mIZcvrLQBF9k6Q=
111111
github.com/onsi/gomega v1.39.0/go.mod h1:ZCU1pkQcXDO5Sl9/VVEGlDyp+zm0m1cmeG5TOzLgdh4=
112+
github.com/openshift/api v0.0.0-20250711200046-c86d80652a9e h1:E1OdwSpqWuDPCedyUt0GEdoAE+r5TXy7YS21yNEo+2U=
113+
github.com/openshift/api v0.0.0-20250711200046-c86d80652a9e/go.mod h1:Shkl4HanLwDiiBzakv+con/aMGnVE2MAGvoKp5oyYUo=
112114
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.0 h1:2TD4hi+MLt67jKxJUs2tuBKFMxibrLJQqKqhsTMsHeQ=
113115
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.0/go.mod h1:rgpcv2tLD+/vudXx/gpIQSTuRpk4GOxHx84xwfvQalM=
114116
github.com/operator-framework/api v0.37.0 h1:2XCMWitBnumtJTqzip6LQKUwpM2pXVlt3gkpdlkbaCE=
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
{
2+
idx = index($0, "\": ")
3+
if (idx > 0) {
4+
key_part = substr($0, 1, idx + 2)
5+
val_part = substr($0, idx + 3)
6+
gsub(/OpenShift/, "OpenStack", val_part)
7+
gsub(/openshift/, "openstack", val_part)
8+
gsub(/OPENSHIFT/, "OPENSTACK", val_part)
9+
printf "%s%s\n", key_part, val_part
10+
} else { print }
11+
}
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
2+
pid /tmp/nginx/nginx.pid;
3+
error_log /dev/stdout info;
4+
events {}
5+
http {
6+
client_body_temp_path /tmp/nginx/client_body;
7+
proxy_temp_path /tmp/nginx/proxy;
8+
fastcgi_temp_path /tmp/nginx/fastcgi;
9+
uwsgi_temp_path /tmp/nginx/uwsgi;
10+
scgi_temp_path /tmp/nginx/scgi;
11+
access_log /dev/stdout;
12+
include /etc/nginx/mime.types;
13+
default_type application/octet-stream;
14+
keepalive_timeout 65;
15+
server {
16+
listen %[1]d ssl;
17+
listen [::]:%[1]d ssl;
18+
ssl_certificate /var/cert/tls.crt;
19+
ssl_certificate_key /var/cert/tls.key;
20+
root /usr/share/nginx/html;
21+
}
22+
}

0 commit comments

Comments
 (0)