Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 18 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,10 @@ CATALOG_IMG ?= $(IMAGE_TAG_BASE)-catalog:$(TAG)
CATALOG_NAME ?= openstack-lightspeed-catalog
CATALOG_CHANNEL ?= alpha

# OpenShift internal registry support for local development/testing.
OCP_REGISTRY_NAMESPACE ?= openstack-lightspeed
OCP_INTERNAL_REGISTRY ?= image-registry.openshift-image-registry.svc:5000

# BUNDLE_IMG defines the image:tag used for the bundle.
# You can use it as an arg. (E.g make bundle-build BUNDLE_IMG=<some-registry>/<project-name-bundle>:<tag>)
BUNDLE_IMG ?= $(IMAGE_TAG_BASE)-bundle:$(TAG)
Expand Down Expand Up @@ -281,6 +285,20 @@ kuttl-test: kuttl ## Run kuttl tests
.PHONY: kuttl-test-run
kuttl-test-run: kuttl openstack-lightspeed-deploy kuttl-test openstack-lightspeed-undeploy

.PHONY: ocp-registry-push
ocp-registry-push: ## Push images to the OpenShift internal registry.
Comment thread
lpiwowar marked this conversation as resolved.
bash scripts/ocp-registry-push.sh $(CONTAINER_TOOL) $(OCP_REGISTRY_NAMESPACE) $(IMG) $(CATALOG_IMG)

.PHONY: ocp-catalog-build
ocp-catalog-build: opm ## Build a catalog image for the OpenShift internal registry.
bash scripts/ocp-catalog-build.sh $(CONTAINER_TOOL) $(BUNDLE_IMG) $(CATALOG_IMG) $(OPM)

.PHONY: kuttl-test-ocp
kuttl-test-ocp: IMG = $(OCP_INTERNAL_REGISTRY)/$(OCP_REGISTRY_NAMESPACE)/operator:latest
kuttl-test-ocp: BUNDLE_IMG = $(OCP_INTERNAL_REGISTRY)/openshift-marketplace/operator-bundle:$(TAG)
kuttl-test-ocp: CATALOG_IMG = $(OCP_INTERNAL_REGISTRY)/openshift-marketplace/operator-catalog:$(TAG)
kuttl-test-ocp: docker-build bundle bundle-build ocp-catalog-build ocp-registry-push kuttl-test-run

# go-install-tool will 'go install' any package with custom target and name of binary, if it doesn't exist
# $1 - target path with name of binary
# $2 - package url which can be installed
Expand Down
47 changes: 42 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -226,14 +226,51 @@ pre-commit run --all-files
KUTTL (KUbernetes Test TooL) tests validate the operator's behavior in a real
OpenShift environment.

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

Once you are ready you can run the KUTTL tests using:
- `kubectl-kuttl`, `diff` and `oc` binaries exist and are in the `PATH`.
- An OpenShift cluster is up and running (e.g., one deployed with `crc`).
- `oc` CLI tool can access the OpenShift cluster and is logged in.
- The OpenStack Lightspeed operator to be tested is installed and running in the
OpenShift cluster in the `openstack-lightspeed` namespace.

Using the `kuttl-test` directly is uncommon, as we have 2 helpful targets:

- `kuttl-test-run`: Given a catalog image location deploys OpenStack Lightspeed
on the OpenShift cluster, runs the tests (using `kuttl-test`), and removes
OpenStack Lightspeed.

- `kuttl-test-ocp`: Builds the operator, bundle and catalog images, pushes them
to the OpenShift cluster internal registry, and then runs the kuttl tests
(using `kuttl-test-run`).

In both cases it will check that the `kubectl-kuttl` binary is present in the
system and download it if it's not (target `kuttl`) and both need the
`openstack-lightspeed` namespace to be empty or non-existing to prevent
collisions.

For the `kuttl-test-run` target the images need to be available in an image
registry accessible by the OpenShift cluster. We can build these images
ourselves or use images built by others, in any case variable `CATALOG_IMG`
must point to the catalog image before running `kuttl-test-run`.

Using `kuttl-test-ocp` is useful to build and test everything, but it's too
wasteful if we are going to run kuttl tests multiple times, where
`kuttl-test-run` is better as it doesn't rebuild the images on each run.

A useful option when working on kuttl tests, without changes on the operator
itself, is to use `kuttl-test-ocp` the first time:

```bash
make kuttl-test-ocp
```

And then set `CATALOG_IMG` and use the `kuttl-test-run` target in
consecutive runs:

```bash
export CATALOG_IMG=image-registry.openshift-image-registry.svc:5000/openshift-marketplace/operator-catalog:latest
make kuttl-test-run
```

Expand Down
12 changes: 12 additions & 0 deletions api/v1beta1/openstacklightspeed_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,12 @@ const (
// PostgresContainerImage is the fall-back container image for PostgreSQL
PostgresContainerImage = "registry.redhat.io/rhel9/postgresql-16:latest"

// ConsoleContainerImage is the fall-back container image for the Console Plugin (PatternFly 6, OCP >= 4.19)
ConsoleContainerImage = "registry.redhat.io/openshift-lightspeed/lightspeed-console-plugin-rhel9:1.0.12"

// ConsoleContainerImagePF5 is the fall-back console image for PatternFly 5 (OCP < 4.19)
ConsoleContainerImagePF5 = "registry.redhat.io/openshift-lightspeed/lightspeed-console-plugin-pf5-rhel9:1.0.12"

// MaxTokensForResponseDefault is the default maximum number of tokens that should be used for response
MaxTokensForResponseDefault = 2048
)
Expand Down Expand Up @@ -186,6 +192,8 @@ type OpenStackLightspeedDefaults struct {
LCoreImageURL string
ExporterImageURL string
PostgresImageURL string
ConsoleImageURL string
ConsoleImagePF5URL string
MaxTokensForResponse int
}

Expand All @@ -203,6 +211,10 @@ func SetupDefaults() {
"RELATED_IMAGE_EXPORTER_IMAGE_URL_DEFAULT", ExporterContainerImage),
PostgresImageURL: util.GetEnvVar(
"RELATED_IMAGE_POSTGRES_IMAGE_URL_DEFAULT", PostgresContainerImage),
ConsoleImageURL: util.GetEnvVar(
"RELATED_IMAGE_CONSOLE_IMAGE_URL_DEFAULT", ConsoleContainerImage),
ConsoleImagePF5URL: util.GetEnvVar(
"RELATED_IMAGE_CONSOLE_PF5_IMAGE_URL_DEFAULT", ConsoleContainerImagePF5),
MaxTokensForResponse: MaxTokensForResponseDefault,
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -162,6 +162,18 @@ spec:
- get
- list
- watch
- apiGroups:
- console.openshift.io
resources:
- consoleplugins
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- lightspeed.openstack.org
resources:
Expand All @@ -188,6 +200,15 @@ spec:
- get
- patch
- update
- apiGroups:
- operator.openshift.io
resources:
- consoles
verbs:
- get
- list
- update
- watch
- apiGroups:
- operators.coreos.com
resources:
Expand Down
6 changes: 6 additions & 0 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,8 @@ import (
metricsserver "sigs.k8s.io/controller-runtime/pkg/metrics/server"
"sigs.k8s.io/controller-runtime/pkg/webhook"

consolev1 "github.com/openshift/api/console/v1"
openshiftv1 "github.com/openshift/api/operator/v1"
operatorsv1alpha1 "github.com/operator-framework/api/pkg/operators/v1alpha1"

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

utilruntime.Must(apiv1beta1.AddToScheme(scheme))

utilruntime.Must(consolev1.AddToScheme(scheme))

utilruntime.Must(openshiftv1.AddToScheme(scheme))
Comment thread
lpiwowar marked this conversation as resolved.
// +kubebuilder:scaffold:scheme
}

Expand Down
21 changes: 21 additions & 0 deletions config/rbac/role.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,18 @@ rules:
- get
- list
- watch
- apiGroups:
- console.openshift.io
resources:
- consoleplugins
verbs:
- create
- delete
- get
- list
- patch
- update
- watch
- apiGroups:
- lightspeed.openstack.org
resources:
Expand All @@ -46,6 +58,15 @@ rules:
- get
- patch
- update
- apiGroups:
- operator.openshift.io
resources:
- consoles
verbs:
- get
- list
- update
- watch
- apiGroups:
- operators.coreos.com
resources:
Expand Down
11 changes: 8 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,20 @@ require (
github.com/go-logr/logr v1.4.3
github.com/onsi/ginkgo/v2 v2.27.5
github.com/onsi/gomega v1.39.0
github.com/openshift/api v3.9.0+incompatible // from lib-common
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.0
github.com/operator-framework/api v0.37.0
k8s.io/api v0.34.2
k8s.io/apimachinery v0.34.3
k8s.io/client-go v0.34.2
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397
sigs.k8s.io/controller-runtime v0.22.4
sigs.k8s.io/yaml v1.6.0
)

// from https://github.com/openstack-k8s-operators/lib-common/blob/main/modules/common/go.mod
// must be consistent within modules and service operators
replace github.com/openshift/api => github.com/openshift/api v0.0.0-20250711200046-c86d80652a9e

require (
cel.dev/expr v0.24.0 // indirect
github.com/Masterminds/semver/v3 v3.4.0 // indirect
Expand Down Expand Up @@ -91,15 +97,14 @@ require (
gopkg.in/evanphx/json-patch.v4 v4.12.0 // indirect
gopkg.in/inf.v0 v0.9.1 // indirect
gopkg.in/yaml.v3 v3.0.1 // indirect
k8s.io/api v0.34.2 // indirect
k8s.io/apiextensions-apiserver v0.34.2 // indirect
k8s.io/apiserver v0.34.2 // indirect
k8s.io/component-base v0.34.2 // indirect
k8s.io/klog/v2 v2.130.1 // indirect
k8s.io/kube-openapi v0.0.0-20250710124328-f3f2b991d03b // indirect
k8s.io/utils v0.0.0-20250604170112-4c0f3b243397 // indirect
sigs.k8s.io/apiserver-network-proxy/konnectivity-client v0.33.0 // indirect
sigs.k8s.io/json v0.0.0-20241014173422-cfa47c3a1cc8 // indirect
sigs.k8s.io/randfill v1.0.0 // indirect
sigs.k8s.io/structured-merge-diff/v6 v6.3.0 // indirect
sigs.k8s.io/yaml v1.6.0 // indirect
)
2 changes: 2 additions & 0 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,8 @@ github.com/onsi/ginkgo/v2 v2.27.5 h1:ZeVgZMx2PDMdJm/+w5fE/OyG6ILo1Y3e+QX4zSR0zTE
github.com/onsi/ginkgo/v2 v2.27.5/go.mod h1:ArE1D/XhNXBXCBkKOLkbsb2c81dQHCRcF5zwn/ykDRo=
github.com/onsi/gomega v1.39.0 h1:y2ROC3hKFmQZJNFeGAMeHZKkjBL65mIZcvrLQBF9k6Q=
github.com/onsi/gomega v1.39.0/go.mod h1:ZCU1pkQcXDO5Sl9/VVEGlDyp+zm0m1cmeG5TOzLgdh4=
github.com/openshift/api v0.0.0-20250711200046-c86d80652a9e h1:E1OdwSpqWuDPCedyUt0GEdoAE+r5TXy7YS21yNEo+2U=
github.com/openshift/api v0.0.0-20250711200046-c86d80652a9e/go.mod h1:Shkl4HanLwDiiBzakv+con/aMGnVE2MAGvoKp5oyYUo=
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.0 h1:2TD4hi+MLt67jKxJUs2tuBKFMxibrLJQqKqhsTMsHeQ=
github.com/openstack-k8s-operators/lib-common/modules/common v0.6.0/go.mod h1:rgpcv2tLD+/vudXx/gpIQSTuRpk4GOxHx84xwfvQalM=
github.com/operator-framework/api v0.37.0 h1:2XCMWitBnumtJTqzip6LQKUwpM2pXVlt3gkpdlkbaCE=
Expand Down
11 changes: 11 additions & 0 deletions internal/controller/assets/console_locales_rewrite.awk
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
idx = index($0, "\": ")
if (idx > 0) {
key_part = substr($0, 1, idx + 2)
val_part = substr($0, idx + 3)
gsub(/OpenShift/, "OpenStack", val_part)
gsub(/openshift/, "openstack", val_part)
gsub(/OPENSHIFT/, "OPENSTACK", val_part)
printf "%s%s\n", key_part, val_part
} else { print }
}
22 changes: 22 additions & 0 deletions internal/controller/assets/console_nginx.conf.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@

pid /tmp/nginx/nginx.pid;
error_log /dev/stdout info;
events {}
http {
client_body_temp_path /tmp/nginx/client_body;
proxy_temp_path /tmp/nginx/proxy;
fastcgi_temp_path /tmp/nginx/fastcgi;
uwsgi_temp_path /tmp/nginx/uwsgi;
scgi_temp_path /tmp/nginx/scgi;
access_log /dev/stdout;
include /etc/nginx/mime.types;
default_type application/octet-stream;
keepalive_timeout 65;
server {
listen %[1]d ssl;
listen [::]:%[1]d ssl;
ssl_certificate /var/cert/tls.crt;
ssl_certificate_key /var/cert/tls.key;
root /usr/share/nginx/html;
}
}
Loading
Loading